private void readInlineTypes(long[] keyIds, LongObjectHashMap properties, ReadBuffer in, TypeInspector tx, InlineType inlineType) { for (long keyId : keyIds) { PropertyKey keyType = tx.getExistingPropertyKey(keyId); Object value = readInline(in, keyType, inlineType); if (value != null) properties.put(keyId, value); } }
private void readInlineTypes(long[] keyIds, LongObjectHashMap properties, ReadBuffer in, TypeInspector tx, InlineType inlineType) { for (long keyId : keyIds) { PropertyKey keyType = tx.getExistingPropertyKey(keyId); Object value = readInline(in, keyType, inlineType); if (value != null) properties.put(keyId, value); } }
/** * Creates a hash map from two index-aligned arrays of key-value pairs. */ public static <VType> LongObjectHashMap<VType> from(long[] keys, VType[] values) { if (keys.length != values.length) { throw new IllegalArgumentException("Arrays of keys and values must have an identical length."); } LongObjectHashMap<VType> map = new LongObjectHashMap<>(keys.length); for (int i = 0; i < keys.length; i++) { map.put(keys[i], values[i]); } return map; }
/** * Puts all key/value pairs from a given iterable into this map. */ @Override public int putAll(Iterable<? extends LongObjectCursor<? extends VType>> iterable){ final int count = size(); for (LongObjectCursor<? extends VType> c : iterable) { put(c.key, c.value); } return size() - count; }
/** * {@inheritDoc} */ @Override public int putAll(LongObjectAssociativeContainer<? extends VType> container) { final int count = size(); for (LongObjectCursor<? extends VType> c : container) { put(c.key, c.value); } return size() - count; }
/** * Marks this sequence number and returns {@code true} if it is seen before. */ boolean getAndSet(long value) { assert value >= 0; final long key = value / BIT_SET_SIZE; CountedBitSet bitset = bitSets.get(key); if (bitset == null) { bitset = new CountedBitSet(BIT_SET_SIZE); bitSets.put(key, bitset); } final int index = Math.toIntExact(value % BIT_SET_SIZE); final boolean wasOn = bitset.get(index); bitset.set(index); return wasOn; } }
public void add(long id, long ts, long value) { Entry<Long,Long> entry = new SimpleEntry<>(ts, value); Deque<Entry<Long,Long>> list = data.get(id); if (list == null) { list = new ConcurrentLinkedDeque<>(); } list.add(entry); while (ts - list.peekFirst().getKey() > RETAIN_INTERVAL) { list.removeFirst(); } data.put(id, list); }
/** * Creates a hash map from two index-aligned arrays of key-value pairs. */ public static <VType> LongObjectHashMap<VType> from(long[] keys, VType[] values) { if (keys.length != values.length) { throw new IllegalArgumentException("Arrays of keys and values must have an identical length."); } LongObjectHashMap<VType> map = new LongObjectHashMap<>(keys.length); for (int i = 0; i < keys.length; i++) { map.put(keys[i], values[i]); } return map; }
/** * <a href="http://trove4j.sourceforge.net">Trove</a>-inspired API method. An equivalent * of the following code: * <pre> * if (!map.containsKey(key)) map.put(value); * </pre> * * @param key The key of the value to check. * @param value The value to put if <code>key</code> does not exist. * @return <code>true</code> if <code>key</code> did not exist and <code>value</code> * was placed in the map. */ public boolean putIfAbsent(long key, VType value) { if (!containsKey(key)) { put(key, value); return true; } else { return false; } }
public ArrowBuf getManagedBuffer(int size) { ArrowBuf newBuf = allocator.buffer(size, this); managedBuffers.put(newBuf.memoryAddress(), newBuf); return newBuf; } }
private void readInlineTypes(long[] keyIds, LongObjectHashMap properties, ReadBuffer in, TypeInspector tx, InlineType inlineType) { for (long keyId : keyIds) { PropertyKey keyType = tx.getExistingPropertyKey(keyId); Object value = readInline(in, keyType, inlineType); if (value != null) properties.put(keyId, value); } }
/** * Puts all key/value pairs from a given iterable into this map. */ @Override public int putAll(Iterable<? extends LongObjectCursor<? extends VType>> iterable){ final int count = size(); for (LongObjectCursor<? extends VType> c : iterable) { put(c.key, c.value); } return size() - count; }
/** * {@inheritDoc} */ @Override public int putAll(LongObjectAssociativeContainer<? extends VType> container) { final int count = size(); for (LongObjectCursor<? extends VType> c : container) { put(c.key, c.value); } return size() - count; }
@Override public DrillBuf getManagedBuffer(int size) { DrillBuf newBuf = allocator.buffer(size, this); managedBuffers.put(newBuf.memoryAddress(), newBuf); return newBuf; } }
/** * Marks this sequence number and returns {@code true} if it is seen before. */ boolean getAndSet(long value) { assert value >= 0; final long key = value / BIT_SET_SIZE; CountedBitSet bitset = bitSets.get(key); if (bitset == null) { bitset = new CountedBitSet(BIT_SET_SIZE); bitSets.put(key, bitset); } final int index = Math.toIntExact(value % BIT_SET_SIZE); final boolean wasOn = bitset.get(index); bitset.set(index); return wasOn; } }
/** * Marks this sequence number and returns {@code true} if it is seen before. */ boolean getAndSet(long value) { assert value >= 0; final long key = value / BIT_SET_SIZE; CountedBitSet bitset = bitSets.get(key); if (bitset == null) { bitset = new CountedBitSet(BIT_SET_SIZE); bitSets.put(key, bitset); } final int index = Math.toIntExact(value % BIT_SET_SIZE); final boolean wasOn = bitset.get(index); bitset.set(index); return wasOn; } }