Example usage for java.util SortedMap size

List of usage examples for java.util SortedMap size

Introduction

In this page you can find the example usage for java.util SortedMap size.

Prototype

int size();

Source Link

Document

Returns the number of key-value mappings in this map.

Usage

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamAccountTable.java

public CFAccAccountBuff[] readDerivedByRollupAcctIdx(CFAccAuthorization Authorization, Long RollupTenantId,
        Long RollupAccountId) {//from   w w w  .  j av a 2s  .c o m
    final String S_ProcName = "CFAccRamAccount.readDerivedByRollupAcctIdx() ";
    CFAccAccountByRollupAcctIdxKey key = schema.getFactoryAccount().newRollupAcctIdxKey();
    key.setOptionalRollupTenantId(RollupTenantId);
    key.setOptionalRollupAccountId(RollupAccountId);

    CFAccAccountBuff[] recArray;
    if (dictByRollupAcctIdx.containsKey(key)) {
        SortedMap<CFAccAccountPKey, CFAccAccountBuff> subdictRollupAcctIdx = dictByRollupAcctIdx.get(key);
        recArray = new CFAccAccountBuff[subdictRollupAcctIdx.size()];
        Iterator<CFAccAccountBuff> iter = subdictRollupAcctIdx.values().iterator();
        int idx = 0;
        while (iter.hasNext()) {
            recArray[idx++] = iter.next();
        }
    } else {
        recArray = new CFAccAccountBuff[0];
    }
    return (recArray);
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgClient.CFAccXMsgClientAccountConfigTable.java

public CFAccAccountConfigBuff[] readDerivedByDefCcyIdx(CFAccAuthorization Authorization,
        short argDefaultCurrencyId) {
    final String S_ProcName = "readDerivedByDefCcyIdx";
    String rqst = CFAccXMsgSchemaMessageFormatter.formatRqstXmlPreamble()
            + "\n" + "\t" + CFAccXMsgAccountConfigMessageFormatter
                    .formatAccountConfigRqstReadByDefCcyIdx("\n\t\t\t", argDefaultCurrencyId)
            + "\n" + CFAccXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }/*  w  w w .ja  v a  2  s.c om*/
    CFAccXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAccAccountConfigPKey, ICFAccAccountConfigObj> sortedMap = (SortedMap<CFAccAccountConfigPKey, ICFAccAccountConfigObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAccAccountConfigBuff arr[] = new CFAccAccountConfigBuff[sz];
    Iterator<ICFAccAccountConfigObj> iter = sortedMap.values().iterator();
    ICFAccAccountConfigObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAccAccountConfigObj) iter.next();
        arr[idx] = cur.getAccountConfigBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgClient.CFAccXMsgClientAccountConfigTable.java

public CFAccAccountConfigBuff[] readDerivedByCustCtcLstIdx(CFAccAuthorization Authorization,
        Long argCustContactListTenantId, Long argCustContactListId) {
    final String S_ProcName = "readDerivedByCustCtcLstIdx";
    String rqst = CFAccXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAccXMsgAccountConfigMessageFormatter.formatAccountConfigRqstReadByCustCtcLstIdx("\n\t\t\t",
                    argCustContactListTenantId, argCustContactListId)
            + "\n" + CFAccXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }/*from   ww w . j  a  va  2 s .  c o m*/
    CFAccXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAccAccountConfigPKey, ICFAccAccountConfigObj> sortedMap = (SortedMap<CFAccAccountConfigPKey, ICFAccAccountConfigObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAccAccountConfigBuff arr[] = new CFAccAccountConfigBuff[sz];
    Iterator<ICFAccAccountConfigObj> iter = sortedMap.values().iterator();
    ICFAccAccountConfigObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAccAccountConfigObj) iter.next();
        arr[idx] = cur.getAccountConfigBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgClient.CFAccXMsgClientAccountConfigTable.java

public CFAccAccountConfigBuff[] readDerivedByEmpCtcLstIdx(CFAccAuthorization Authorization,
        Long argEmpContactListTenantId, Long argEmpContactListId) {
    final String S_ProcName = "readDerivedByEmpCtcLstIdx";
    String rqst = CFAccXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAccXMsgAccountConfigMessageFormatter.formatAccountConfigRqstReadByEmpCtcLstIdx("\n\t\t\t",
                    argEmpContactListTenantId, argEmpContactListId)
            + "\n" + CFAccXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }/*from  ww w  .  j  a  v  a2s .  co m*/
    CFAccXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAccAccountConfigPKey, ICFAccAccountConfigObj> sortedMap = (SortedMap<CFAccAccountConfigPKey, ICFAccAccountConfigObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAccAccountConfigBuff arr[] = new CFAccAccountConfigBuff[sz];
    Iterator<ICFAccAccountConfigObj> iter = sortedMap.values().iterator();
    ICFAccAccountConfigObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAccAccountConfigObj) iter.next();
        arr[idx] = cur.getAccountConfigBuff();
    }
    return (arr);
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccXMsgClient.CFAccXMsgClientAccountConfigTable.java

public CFAccAccountConfigBuff[] readDerivedByVendCtcLstIdx(CFAccAuthorization Authorization,
        Long argVendContactListTenantId, Long argVendContactListId) {
    final String S_ProcName = "readDerivedByVendCtcLstIdx";
    String rqst = CFAccXMsgSchemaMessageFormatter.formatRqstXmlPreamble() + "\n" + "\t"
            + CFAccXMsgAccountConfigMessageFormatter.formatAccountConfigRqstReadByVendCtcLstIdx("\n\t\t\t",
                    argVendContactListTenantId, argVendContactListId)
            + "\n" + CFAccXMsgSchemaMessageFormatter.formatRqstXmlPostamble();
    String rspn = schema.sendReceive(Authorization, rqst);
    if ((rspn == null) || (rspn.length() <= 0)) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "rspn");
    }/* ww w .  ja  va 2  s.  com*/
    CFAccXMsgRspnHandler responseHandler = schema.getResponseHandler();
    responseHandler.parseStringContents(rspn);
    CFLibRuntimeException exceptionRaised = responseHandler.getExceptionRaised();
    if (exceptionRaised != null) {
        throw exceptionRaised;
    }
    Object sortedMapObj = responseHandler.getSortedMapOfObjects();
    if (sortedMapObj == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0,
                "responseHandler.getSortedMapOfObjects");
    }
    SortedMap<CFAccAccountConfigPKey, ICFAccAccountConfigObj> sortedMap = (SortedMap<CFAccAccountConfigPKey, ICFAccAccountConfigObj>) sortedMapObj;
    int sz = sortedMap.size();
    CFAccAccountConfigBuff arr[] = new CFAccAccountConfigBuff[sz];
    Iterator<ICFAccAccountConfigObj> iter = sortedMap.values().iterator();
    ICFAccAccountConfigObj cur;
    for (int idx = 0; idx < sz; idx++) {
        cur = (ICFAccAccountConfigObj) iter.next();
        arr[idx] = cur.getAccountConfigBuff();
    }
    return (arr);
}

From source file:accumulo.balancer.GroupBalancer.java

/**
 * @return Examine current tserver and migrations and return true if balancing should occur.
 *///  w  w  w. j  a  v  a  2s  .com
protected boolean shouldBalance(SortedMap<TServerInstance, TabletServerStatus> current,
        Set<KeyExtent> migrations) {

    if (current.size() < 2) {
        return false;
    }

    for (KeyExtent keyExtent : migrations) {
        if (keyExtent.getTableId().equals(textTableId)) {
            return false;
        }
    }

    return true;
}

From source file:com.restfb.util.InsightUtilsTest.java

@Test
public void executeInsightQueriesByMetricByDate1() throws IOException {
    // note that the query that is passed to the FacebookClient WebRequestor is
    // ignored,//from   w  w w.  j  ava 2 s .  c o  m
    // so arguments of executeInsightQueriesByDate:
    // (String pageObjectId, Set<String> metrics, Period period)
    // are effectively ignored. In this test we are validating the
    // WebRequestor's json
    // is properly processed
    SortedMap<String, SortedMap<Date, Object>> results = executeInsightQueriesByMetricByDate(
            createFixedResponseFacebookClient("multiResponse_2metrics_1date.json"), TEST_PAGE_OBJECT,
            toStringSet("page_fans", "page_fans_gender"), Period.DAY, Collections.singleton(d20101205_0000pst));
    Assert.assertNotNull(results);
    assertEquals(2, results.size());

    SortedMap<Date, Object> metricResult = results.get("page_fans");
    assertEquals(1, metricResult.size());
    assertEquals(3777, metricResult.get(d20101205_0000pst));

    metricResult = results.get("page_fans_gender");
    assertEquals(1, metricResult.size());
    Object metricValue = metricResult.get(d20101205_0000pst);
    Assert.assertTrue(metricValue instanceof JsonObject);
    JsonObject o = (JsonObject) metricValue;
    assertEquals(58, o.getInt("U"));
    assertEquals(1656, o.getInt("F"));
    assertEquals(2014, o.getInt("M"));
}

From source file:com.restfb.util.InsightUtilsTest.java

@Test
public void executeInsightQueriesByDate2() throws IOException, ParseException, JSONException {
    // note that the query that is passed to the FacebookClient WebRequestor is
    // ignored,//from   ww  w  . j a v  a2 s. co  m
    // so arguments of executeInsightQueriesByDate:
    // (String pageObjectId, Set<String> metrics, Period period)
    // are effectively ignored. In this test we are validating the
    // WebRequestor's json
    // is properly processed

    Date d20030629_0000pst = sdfPST.parse("20030629_0000");
    Date d20030630_0000pst = sdfPST.parse("20030630_0000");
    Date d20030701_0000pst = sdfPST.parse("20030701_0000");
    Date d20030702_0000pst = sdfPST.parse("20030702_0000");
    // intentionally using (chaotic) HashSet to ensure implementation is
    // tolerant of that collection
    Set<Date> periodEndDates = new HashSet<Date>();
    periodEndDates.add(d20030629_0000pst);
    periodEndDates.add(d20030630_0000pst);
    periodEndDates.add(d20030701_0000pst);
    periodEndDates.add(d20030702_0000pst);

    SortedMap<Date, JsonArray> results = executeInsightQueriesByDate(
            createFixedResponseFacebookClient("multiResponse_2metrics_4dates.json"), TEST_PAGE_OBJECT,
            toStringSet("page_active_users", "page_tab_views_login_top_unique"), Period.DAY, periodEndDates);
    Assert.assertNotNull(results);
    assertEquals(4, results.size());
    // not ideal that this test requires on a stable JsonArray.toString()

    String expectedString;
    String actualString;

    expectedString = new JsonArray(
            "[{\"metric\":\"page_active_users\",\"value\":761},{\"metric\":\"page_tab_views_login_top_unique\",\"value\":{\"photos\":2,\"app_4949752878\":3,\"wall\":30}}]")
                    .toString();
    actualString = results.get(d20030629_0000pst).toString();
    JSONAssert.assertEquals(expectedString, actualString, JSONCompareMode.NON_EXTENSIBLE);

    expectedString = new JsonArray(
            "[{\"metric\":\"page_active_users\",\"value\":705},{\"metric\":\"page_tab_views_login_top_unique\",\"value\":{\"app_4949752878\":1,\"photos\":1,\"app_2373072738\":2,\"wall\":23}}]")
                    .toString();
    actualString = results.get(d20030630_0000pst).toString();
    JSONAssert.assertEquals(expectedString, actualString, JSONCompareMode.NON_EXTENSIBLE);

    expectedString = new JsonArray(
            "[{\"metric\":\"page_active_users\",\"value\":582},{\"metric\":\"page_tab_views_login_top_unique\",\"value\":{\"app_4949752878\":1,\"wall\":12}}]")
                    .toString();
    actualString = results.get(d20030701_0000pst).toString();
    JSONAssert.assertEquals(expectedString, actualString, JSONCompareMode.NON_EXTENSIBLE);

    expectedString = new JsonArray(
            "[{\"metric\":\"page_active_users\",\"value\":125},{\"metric\":\"page_tab_views_login_top_unique\",\"value\":{\"photos\":1,\"wall\":11}}]")
                    .toString();
    actualString = results.get(d20030702_0000pst).toString();
    JSONAssert.assertEquals(expectedString, actualString, JSONCompareMode.NON_EXTENSIBLE);
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamAddressTable.java

public CFAccAddressBuff[] readDerivedByTenantIdx(CFAccAuthorization Authorization, long TenantId) {
    final String S_ProcName = "CFAccRamAddress.readDerivedByTenantIdx() ";
    CFAccAddressByTenantIdxKey key = schema.getFactoryAddress().newTenantIdxKey();
    key.setRequiredTenantId(TenantId);/*from w  ww  . j  a  v  a  2s . c o  m*/

    CFAccAddressBuff[] recArray;
    if (dictByTenantIdx.containsKey(key)) {
        SortedMap<CFAccAddressPKey, CFAccAddressBuff> subdictTenantIdx = dictByTenantIdx.get(key);
        recArray = new CFAccAddressBuff[subdictTenantIdx.size()];
        Iterator<CFAccAddressBuff> iter = subdictTenantIdx.values().iterator();
        int idx = 0;
        while (iter.hasNext()) {
            recArray[idx++] = iter.next();
        }
    } else {
        recArray = new CFAccAddressBuff[0];
    }
    return (recArray);
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccRam.CFAccRamAddressTable.java

public CFAccAddressBuff[] readDerivedByCountryIdx(CFAccAuthorization Authorization, Short CountryId) {
    final String S_ProcName = "CFAccRamAddress.readDerivedByCountryIdx() ";
    CFAccAddressByCountryIdxKey key = schema.getFactoryAddress().newCountryIdxKey();
    key.setOptionalCountryId(CountryId);

    CFAccAddressBuff[] recArray;//w w w  . j  av  a 2s.co  m
    if (dictByCountryIdx.containsKey(key)) {
        SortedMap<CFAccAddressPKey, CFAccAddressBuff> subdictCountryIdx = dictByCountryIdx.get(key);
        recArray = new CFAccAddressBuff[subdictCountryIdx.size()];
        Iterator<CFAccAddressBuff> iter = subdictCountryIdx.values().iterator();
        int idx = 0;
        while (iter.hasNext()) {
            recArray[idx++] = iter.next();
        }
    } else {
        recArray = new CFAccAddressBuff[0];
    }
    return (recArray);
}