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.CFAccRamAttachmentTagTable.java

public CFAccAttachmentTagBuff[] readDerivedByAttIdx(CFAccAuthorization Authorization, long TenantId,
        long AttachmentId) {
    final String S_ProcName = "CFAccRamAttachmentTag.readDerivedByAttIdx() ";
    CFAccAttachmentTagByAttIdxKey key = schema.getFactoryAttachmentTag().newAttIdxKey();
    key.setRequiredTenantId(TenantId);/*from   ww  w.  j av  a 2s .  c  o m*/
    key.setRequiredAttachmentId(AttachmentId);

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

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

public CFAccAttachmentTagBuff[] readDerivedByTagIdx(CFAccAuthorization Authorization, long TenantId,
        long TagId) {
    final String S_ProcName = "CFAccRamAttachmentTag.readDerivedByTagIdx() ";
    CFAccAttachmentTagByTagIdxKey key = schema.getFactoryAttachmentTag().newTagIdxKey();
    key.setRequiredTenantId(TenantId);//www. ja va2  s.co  m
    key.setRequiredTagId(TagId);

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

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

public CFAccAccountContactBuff[] readDerivedByCtctIdx(CFAccAuthorization Authorization, long TenantId,
        long ContactId) {
    final String S_ProcName = "CFAccRamAccountContact.readDerivedByCtctIdx() ";
    CFAccAccountContactByCtctIdxKey key = schema.getFactoryAccountContact().newCtctIdxKey();
    key.setRequiredTenantId(TenantId);/*www.j av a2 s.c  om*/
    key.setRequiredContactId(ContactId);

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

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

public CFAccAccountContactBuff[] readDerivedByTenantIdx(CFAccAuthorization Authorization, long TenantId) {
    final String S_ProcName = "CFAccRamAccountContact.readDerivedByTenantIdx() ";
    CFAccAccountContactByTenantIdxKey key = schema.getFactoryAccountContact().newTenantIdxKey();
    key.setRequiredTenantId(TenantId);//from  w  w w  .  j  a  va 2  s  .  c o m

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

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

public CFAccAttachmentTagBuff[] readDerivedByTenantIdx(CFAccAuthorization Authorization, long TenantId) {
    final String S_ProcName = "CFAccRamAttachmentTag.readDerivedByTenantIdx() ";
    CFAccAttachmentTagByTenantIdxKey key = schema.getFactoryAttachmentTag().newTenantIdxKey();
    key.setRequiredTenantId(TenantId);/*from   w w  w .j ava2s. com*/

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

From source file:eagle.log.entity.meta.IndexDefinition.java

private byte[] generateUniqueIndexRowkey(byte[][] indexValues, int[] partitionHashCodes,
        SortedMap<Integer, Integer> tagMap) {
    final int prefixHashCode = indexPrefix.hashCode();
    int totalLength = 4;
    totalLength += (partitionHashCodes != null) ? (4 * partitionHashCodes.length) : 0;

    totalLength += (2 * indexValues.length);
    for (int i = 0; i < indexValues.length; ++i) {
        final byte[] value = indexValues[i];
        totalLength += value.length;/*from   w  w  w . ja v  a  2  s .c om*/
    }
    if (tagMap != null && (!tagMap.isEmpty())) {
        totalLength += tagMap.size() * 8;
    }

    int offset = 0;
    final byte[] rowkey = new byte[totalLength];

    // 1. set prefix
    ByteUtil.intToBytes(prefixHashCode, rowkey, offset);
    offset += 4;

    // 2. set partition
    if (partitionHashCodes != null) {
        for (Integer partitionHashCode : partitionHashCodes) {
            ByteUtil.intToBytes(partitionHashCode, rowkey, offset);
            offset += 4;
        }
    }

    // 3. set index values
    for (int i = 0; i < columns.length; ++i) {
        ByteUtil.shortToBytes((short) indexValues[i].length, rowkey, offset);
        offset += 2;
        for (int j = 0; j < indexValues[i].length; ++j) {
            rowkey[offset++] = indexValues[i][j];
        }
    }

    // Check if it's non clustered index, then set the tag/value hash code
    if (tagMap != null && (!tagMap.isEmpty())) {
        // 4. set tag key/value hashes
        for (Map.Entry<Integer, Integer> entry : tagMap.entrySet()) {
            ByteUtil.intToBytes(entry.getKey(), rowkey, offset);
            offset += 4;
            ByteUtil.intToBytes(entry.getValue(), rowkey, offset);
            offset += 4;
        }
    }

    return rowkey;
}

From source file:edu.umd.cfar.lamp.viper.util.Range.java

/**
 * @see edu.umd.cfar.lamp.viper.util.IntervalIndexList#firstBefore(java.lang.Comparable)
 *///from   w  w w. j av a  2 s .  c o m
public Comparable firstBefore(Comparable oldStart) {
    SortedMap head = spans.headMap(oldStart);
    if (head.size() > 0) {
        return (Comparable) head.lastKey();
    }
    return null;
}

From source file:edu.umd.cfar.lamp.viper.util.Range.java

public Comparable firstBeforeOrAt(Comparable oldStart) {
    if (spans.containsKey(oldStart)) {
        return oldStart;
    }//ww w  .j a  va  2  s.com
    SortedMap head = spans.headMap(oldStart);
    if (head.size() > 0) {
        return (Comparable) head.lastKey();
    }
    return null;
}

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

@Test
public void executeInsightQueriesByDate1() throws IOException, JSONException {
    // 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<Date, JsonArray> results = executeInsightQueriesByDate(
            createFixedResponseFacebookClient("multiResponse_2metrics_1date.json"), TEST_PAGE_OBJECT,
            toStringSet("page_fans", "page_fans_gender"), Period.DAY, Collections.singleton(d20101205_0000pst));
    Assert.assertNotNull(results);
    assertEquals(1, results.size());
    JsonArray ja = results.get(d20101205_0000pst);
    Assert.assertNotNull(ja);
    // not ideal that this test requires on a stable JsonArray.toString()
    String expectedJson = "[{\"metric\":\"page_fans\",\"value\":3777},{\"metric\":\"page_fans_gender\",\"value\":{\"U\":58,\"F\":1656,\"M\":2014}}]";
    JSONAssert.assertEquals(expectedJson, ja.toString(), JSONCompareMode.NON_EXTENSIBLE);
}

From source file:edu.umd.cfar.lamp.viper.util.Range.java

/**
 * @see java.util.Set#contains(java.lang.Object)
 *//*from w ww.ja v  a2  s  .com*/
public boolean contains(Object o) {
    if (spans.size() == 0) {
        return false;
    } else if (o instanceof Comparable) {
        SortedMap m = spans.headMap(o);
        if (m.size() > 0) {
            Comparable e = (Comparable) m.get(m.lastKey());
            if (e.compareTo(o) > 0) {
                return true;
            }
        }
        m = spans.tailMap(o);
        if (m.size() > 0) {
            Comparable s = (Comparable) m.firstKey();
            return s.compareTo(o) == 0;
        }
        return false;
    } else {
        return withinRange((Interval) o);
    }
}