SegmentsOfInterval get(long timestamp) { return intervalToSegmentStates.get(timestamp); }
private void decrementBitmapOfSize(Integer size) { Integer current = sortedSizes.get(size); if (current == 1) { sortedSizes.remove(size); } else { sortedSizes.put(size, current - 1); } }
@Override public V get(Object key) { return delegate.get(checkValid(key)); }
private Long lastId(byte[] key) { Long lastId = null; byte[] txId = txIds.get(key); if (txId != null) { lastId = Long.valueOf(new String(txId)); } return lastId; }
/** * @param absIdx Reserved index. */ synchronized void release(long absIdx) { Integer cur = reserved.get(absIdx); assert cur != null && cur >= 1 : "cur=" + cur + ", absIdx=" + absIdx; if (cur == 1) reserved.remove(absIdx); else reserved.put(absIdx, cur - 1); } }
private void decrementArrayOfSize(int size, Class<?> arrayClass) { NavigableMap<Integer, Integer> sizes = getSizesForAdapter(arrayClass); Integer current = sizes.get(size); if (current == null) { throw new NullPointerException( "Tried to decrement empty size" + ", size: " + size + ", this: " + this); } if (current == 1) { sizes.remove(size); } else { sizes.put(size, current - 1); } }
private void decrementBitmapOfSize(Integer size, Bitmap removed) { Bitmap.Config config = removed.getConfig(); NavigableMap<Integer, Integer> sizes = getSizesForConfig(config); Integer current = sizes.get(size); if (current == null) { throw new NullPointerException("Tried to decrement empty size" + ", size: " + size + ", removed: " + logBitmap(removed) + ", this: " + this); } if (current == 1) { sizes.remove(size); } else { sizes.put(size, current - 1); } }
int getCurrentSize() { int currentSize = 0; for (Class<?> type : sortedSizes.keySet()) { for (Integer size : sortedSizes.get(type).keySet()) { ArrayAdapterInterface<?> adapter = getAdapterFromType(type); currentSize += size * sortedSizes.get(type).get(size) * adapter.getElementSizeInBytes(); } } return currentSize; }
@Override public void put(Bitmap bitmap) { int size = Util.getBitmapByteSize(bitmap); Key key = keyPool.get(size, bitmap.getConfig()); groupedMap.put(key, bitmap); NavigableMap<Integer, Integer> sizes = getSizesForConfig(bitmap.getConfig()); Integer current = sizes.get(key.size); sizes.put(key.size, current == null ? 1 : current + 1); }
@Override public void put(Bitmap bitmap) { int size = Util.getBitmapByteSize(bitmap); final Key key = keyPool.get(size); groupedMap.put(key, bitmap); Integer current = sortedSizes.get(key.size); sortedSizes.put(key.size, current == null ? 1 : current + 1); }
@Override public Iterable<Entry> getCurrentValue() throws IOException, InterruptedException { return new HBaseMapIterable(reader.getCurrentValue().getMap().get(edgestoreFamilyBytes)); }
@Override public synchronized <T> void put(T array) { @SuppressWarnings("unchecked") Class<T> arrayClass = (Class<T>) array.getClass(); ArrayAdapterInterface<T> arrayAdapter = getAdapterFromType(arrayClass); int size = arrayAdapter.getArrayLength(array); int arrayBytes = size * arrayAdapter.getElementSizeInBytes(); if (!isSmallEnoughForReuse(arrayBytes)) { return; } Key key = keyPool.get(size, arrayClass); groupedMap.put(key, array); NavigableMap<Integer, Integer> sizes = getSizesForAdapter(arrayClass); Integer current = sizes.get(key.size); sizes.put(key.size, current == null ? 1 : current + 1); currentSize += arrayBytes; evict(); }
@GwtIncompatible // NavigableMap public void testAsMapNavigableEmpty() { NavigableSet<String> strings = ImmutableSortedSet.of(); NavigableMap<String, Integer> map = Maps.asMap(strings, LENGTH_FUNCTION); assertThat(map.entrySet()).isEmpty(); assertTrue(map.isEmpty()); assertNull(map.get("five")); }
@Override public @Nullable Range<C> get(@Nullable Object key) { if (key instanceof Cut) { try { @SuppressWarnings("unchecked") // we catch CCE's Cut<C> cut = (Cut<C>) key; if (!lowerBoundWindow.contains(cut) || cut.compareTo(restriction.lowerBound) < 0 || cut.compareTo(restriction.upperBound) >= 0) { return null; } else if (cut.equals(restriction.lowerBound)) { // it might be present, truncated on the left Range<C> candidate = Maps.valueOrNull(rangesByLowerBound.floorEntry(cut)); if (candidate != null && candidate.upperBound.compareTo(restriction.lowerBound) > 0) { return candidate.intersection(restriction); } } else { Range<C> result = rangesByLowerBound.get(cut); if (result != null) { return result.intersection(restriction); } } } catch (ClassCastException e) { return null; } } return null; }
void verifyEdit(int familyNum, int putNum, Table table) throws IOException { Result r = table.get(createGet(familyNum, putNum)); byte[] family = FAMILIES[familyNum - 1]; byte[] qf = Bytes.toBytes("q" + familyNum); byte[] val = Bytes.toBytes("val" + familyNum + "-" + putNum); assertNotNull(("Missing Put#" + putNum + " for CF# " + familyNum), r.getFamilyMap(family)); assertNotNull(("Missing Put#" + putNum + " for CF# " + familyNum), r.getFamilyMap(family).get(qf)); assertTrue(("Incorrect value for Put#" + putNum + " for CF# " + familyNum), Arrays.equals(r.getFamilyMap(family).get(qf), val)); }
@Test public void checkVersionInfo() { Map<String, String> versions = new HashMap<>(); String key = VersionInfo.getVersion(); assertNotEquals("Unknown", key, "Looks like we don't know what version of storm we are"); versions.put(key, System.getProperty("java.class.path")); Map<String, Object> conf = new HashMap<>(); conf.put(Config.SUPERVISOR_WORKER_VERSION_CLASSPATH_MAP, versions); NavigableMap<String, IVersionInfo> alternativeVersions = Utils.getAlternativeVersionsMap(conf); assertEquals(1, alternativeVersions.size()); IVersionInfo found = alternativeVersions.get(key); assertNotNull(found); assertEquals(key, found.getVersion()); } }
assertNull(map.comparator()); assertEquals(ImmutableSortedMap.of("one", 3, "two", 3, "three", 5), map); assertNull(map.get("four")); strings.add("four"); assertEquals(ImmutableSortedMap.of("one", 3, "two", 3, "three", 5, "four", 4), map); assertEquals(Integer.valueOf(4), map.get("four")); SortedMap<String, Integer> headMap = map.headMap("two"); assertEquals(ImmutableSortedMap.of("four", 4, "one", 3, "three", 5), headMap);
@Test public void shouldComputeSortedIndexUpdatesOnTxStateWithAddedNodes() { // GIVEN addNodesToIndex( indexOn_1_1 ).withDefaultStringProperties( 42L ); addNodesToIndex( indexOn_1_1 ).withDefaultStringProperties( 43L ); addNodesToIndex( indexOn_1_1 ).withDefaultStringProperties( 41L ); // WHEN NavigableMap<ValueTuple,? extends LongDiffSets> diffSets = state.getSortedIndexUpdates( indexOn_1_1.schema() ); TreeMap<ValueTuple,LongDiffSets> expected = sortedAddedNodesDiffSets( 42, 41, 43 ); // THEN assertEquals( expected.keySet(), diffSets.keySet() ); for ( final ValueTuple key : expected.keySet() ) { assertEqualDiffSets( expected.get( key ), diffSets.get( key ) ); } }
NavigableMap<String, Integer> map = Maps.asMap(strings, LENGTH_FUNCTION); assertEquals(ImmutableMap.of("one", 3, "two", 3, "three", 5), map); assertEquals(Integer.valueOf(5), map.get("three")); assertNull(map.get("five")); assertThat(map.entrySet()) .containsExactly(mapEntry("one", 3), mapEntry("three", 5), mapEntry("two", 3))