@Override public String toString() { // The detail of idToSegments is intentionally ignored because it is usually large return "ImmutableDruidDataSource{" + "name='" + name + "', # of segments='" + idToSegments.size() + "', properties='" + properties + "'}"; }
@Override public void forEach(BiConsumer<? super K, ? super V> action) { checkNotNull(action); ImmutableList<K> keyList = keySet.asList(); for (int i = 0; i < size(); i++) { action.accept(keyList.get(i), valueList.get(i)); } }
/** * This method returns a {@code ImmutableSortedMap}, consisting of the entries whose keys are * greater than (or equal to, if {@code inclusive}) {@code fromKey}. * * <p>The {@link SortedMap#tailMap} documentation states that a submap of a submap throws an * {@link IllegalArgumentException} if passed a {@code fromKey} less than an earlier {@code * fromKey}. However, this method doesn't throw an exception in that situation, but instead keeps * the original {@code fromKey}. * * @since 12.0 */ @Override public ImmutableSortedMap<K, V> tailMap(K fromKey, boolean inclusive) { return getSubMap(keySet.tailIndex(checkNotNull(fromKey), inclusive), size()); }
@Override public void forEach(BiConsumer<? super K, ? super V> action) { checkNotNull(action); ImmutableList<K> keyList = keySet.asList(); for (int i = 0; i < size(); i++) { action.accept(keyList.get(i), valueList.get(i)); } }
@Override public Entry<K, V> lastEntry() { return isEmpty() ? null : entrySet().asList().get(size() - 1); }
/** * This method returns a {@code ImmutableSortedMap}, consisting of the entries whose keys are * greater than (or equal to, if {@code inclusive}) {@code fromKey}. * * <p>The {@link SortedMap#tailMap} documentation states that a submap of a submap throws an * {@link IllegalArgumentException} if passed a {@code fromKey} less than an earlier {@code * fromKey}. However, this method doesn't throw an exception in that situation, but instead keeps * the original {@code fromKey}. * * @since 12.0 */ @Override public ImmutableSortedMap<K, V> tailMap(K fromKey, boolean inclusive) { return getSubMap(keySet.tailIndex(checkNotNull(fromKey), inclusive), size()); }
@Override public Entry<K, V> lastEntry() { return isEmpty() ? null : entrySet().asList().get(size() - 1); }
private ImmutableSortedMap<K, V> getSubMap(int fromIndex, int toIndex) { if (fromIndex == 0 && toIndex == size()) { return this; } else if (fromIndex == toIndex) { return emptyMap(comparator()); } else { return new ImmutableSortedMap<>( keySet.getSubSet(fromIndex, toIndex), valueList.subList(fromIndex, toIndex)); } }
private ImmutableSortedMap<K, V> getSubMap(int fromIndex, int toIndex) { if (fromIndex == 0 && toIndex == size()) { return this; } else if (fromIndex == toIndex) { return emptyMap(comparator()); } else { return new ImmutableSortedMap<>( keySet.getSubSet(fromIndex, toIndex), valueList.subList(fromIndex, toIndex)); } }
for (Map.Entry<Integer, RexLiteral> entry : omittedConstants.descendingMap().entrySet()) { postProjects.add(entry.getKey() + frame.corDefOutputs.size(), entry.getValue());
for (Map.Entry<Integer, RexLiteral> entry : omittedConstants.descendingMap().entrySet()) { postProjects.add(entry.getKey() + frame.corDefOutputs.size(), entry.getValue());
public byte[] serializeEvent(DataPointEvent dataPointEvent) { //Todo: Create some adaptive value here, keep stats on if the buffer increases and slowely increase it ByteArrayDataOutput dataOutput = ByteStreams.newDataOutput(64); dataOutput.writeUTF(dataPointEvent.getMetricName()); dataOutput.writeInt(dataPointEvent.getTtl()); dataOutput.writeLong(dataPointEvent.getDataPoint().getTimestamp()); dataOutput.writeUTF(dataPointEvent.getDataPoint().getDataStoreDataType()); try { dataPointEvent.getDataPoint().writeValueToBuffer(dataOutput); } catch (IOException e) { logger.error("Error serializing DataPoint", e); } dataOutput.writeInt(dataPointEvent.getTags().size()); for (Map.Entry<String, String> entry : dataPointEvent.getTags().entrySet()) { dataOutput.writeUTF(entry.getKey()); dataOutput.writeUTF(entry.getValue()); } return dataOutput.toByteArray(); }
public T getOnlyColumnValue() { Preconditions.checkState(columns.size() == 1, "Works only when the row result has a single column value."); return Iterables.getOnlyElement(columns.values()); }
public Set<Cell> getCellSet() { Set<Cell> cells = Sets.newHashSetWithExpectedSize(columns.size()); for (byte[] column : columns.keySet()) { cells.add(Cell.create(row, column)); } return cells; }
@Override public String toString() { // The detail of idToSegments is intentionally ignored because it is usually large return "ImmutableDruidDataSource{" + "name='" + name + "', # of segments='" + idToSegments.size() + "', properties='" + properties + "'}"; }
@Override public String toString() { // The detail of idToSegments is intentionally ignored because it is usually large return "ImmutableDruidDataSource{" + "name='" + name + "', # of segments='" + idToSegments.size() + "', properties='" + properties + "'}"; }
assertEquals(ENTITY2.getKey(), entity.getKey()); assertEquals(20, entity.getLong("age")); assertEquals(1, entity.getProperties().size()); assertFalse(results4.hasNext());
private ImmutableSortedSet<K> createKeySet() { if (isEmpty()) { return ImmutableSortedSet.emptySet(comparator); } // TODO: For better performance, don't create a separate array. Object[] array = new Object[size()]; for (int i = fromIndex; i < toIndex; i++) { array[i - fromIndex] = entries[i].getKey(); } return new RegularImmutableSortedSet<K>(array, comparator); }
private ImmutableSortedSet<K> createKeySet() { if (isEmpty()) { return ImmutableSortedSet.emptySet(comparator); } // TODO: For better performance, don't create a separate array. Object[] array = new Object[size()]; for (int i = fromIndex; i < toIndex; i++) { array[i - fromIndex] = entries[i].getKey(); } return new RegularImmutableSortedSet<K>(array, comparator); }
public void test_toMap() { ImmutableSortedMap<Currency, Double> test = MultiCurrencyAmount.of(CA1, CA2).toMap(); assertEquals(test.size(), 2); assertEquals(test.containsKey(CA1.getCurrency()), true); assertEquals(test.containsKey(CA2.getCurrency()), true); assertEquals(test.get(CA1.getCurrency()), Double.valueOf(CA1.getAmount())); assertEquals(test.get(CA2.getCurrency()), Double.valueOf(CA2.getAmount())); }