@Override public Entry<K, V> firstEntry() { return isEmpty() ? null : entrySet().asList().get(0); }
@Override public Entry<K, V> lastEntry() { return isEmpty() ? null : entrySet().asList().get(size() - 1); }
@Override public Entry<K, V> firstEntry() { return isEmpty() ? null : entrySet().asList().get(0); }
@Override public List<Entry<String, Integer>> create(Object... elements) { ImmutableSortedMap.Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder(); for (Object o : elements) { @SuppressWarnings("unchecked") Entry<String, Integer> entry = (Entry<String, Integer>) o; builder.put(entry); } return builder.build().entrySet().asList(); } }
@Override public Entry<K, V> lastEntry() { return isEmpty() ? null : entrySet().asList().get(size() - 1); }
return sqlProperties.build().entrySet().stream() .map(entry -> new Property(new Identifier(entry.getKey()), entry.getValue())) .collect(toImmutableList());
final com.google.datastore.v1.Entity toPb() { com.google.datastore.v1.Entity.Builder entityPb = com.google.datastore.v1.Entity.newBuilder(); for (Map.Entry<String, Value<?>> entry : properties.entrySet()) { entityPb.putProperties(entry.getKey(), entry.getValue().toPb()); } if (key != null) { entityPb.setKey(key.toPb()); } return entityPb.build(); } }
for (Map.Entry<CorDef, Integer> entry : frame.corDefOutputs.entrySet()) { projects.add( RexInputRef.of2(entry.getValue(),
for (Map.Entry<CorDef, Integer> entry : frame.corDefOutputs.entrySet()) { projects.add( RexInputRef.of2(entry.getValue(),
: frame.corDefOutputs.entrySet()) { projects.add(RexInputRef.of2(entry.getValue(), newInputOutput));
: frame.corDefOutputs.entrySet()) { projects.add(RexInputRef.of2(entry.getValue(), newInputOutput));
: rightFrame.corDefOutputs.entrySet()) { corDefOutputs.put(entry.getKey(), entry.getValue() + newLeftFieldCount);
: rightFrame.corDefOutputs.entrySet()) { corDefOutputs.put(entry.getKey(), entry.getValue() + newLeftFieldCount);
for (Map.Entry<String, String> entry : tags.entrySet())
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 Iterable<Map.Entry<Cell, T>> getCells() { return Iterables.transform(columns.entrySet(), from -> Maps.immutableEntry(Cell.create(row, from.getKey()), from.getValue())); }
public void testToImmutableSortedMap() { Collector<Entry<String, Integer>, ?, ImmutableSortedMap<String, Integer>> collector = ImmutableSortedMap.toImmutableSortedMap( String.CASE_INSENSITIVE_ORDER, Entry::getKey, Entry::getValue); BiPredicate<ImmutableSortedMap<String, Integer>, ImmutableSortedMap<String, Integer>> equivalence = Equivalence.equals() .onResultOf(ImmutableSortedMap<String, Integer>::comparator) .and(Equivalence.equals().onResultOf(map -> map.entrySet().asList())) .and(Equivalence.equals()); ImmutableSortedMap<String, Integer> expected = ImmutableSortedMap.<String, Integer>orderedBy(String.CASE_INSENSITIVE_ORDER) .put("one", 1) .put("three", 3) .put("two", 2) .build(); CollectorTester.of(collector, equivalence) .expectCollects(expected, mapEntry("one", 1), mapEntry("two", 2), mapEntry("three", 3)); }
public List<LockWithClient> getLocks() { return lockHolders.entrySet() .stream() .map(input -> ImmutableLockWithClient.builder() .lockDescriptor(input.getKey()) .lockClient(input.getValue()) .build()) .collect(Collectors.toList()); }
@Test public void testReadMyDeletesColumnRangePagingTransaction() { Transaction t = startTransaction(); int totalPuts = 101; byte[] row = PtBytes.toBytes("row1"); // Record expected results using byte ordering ImmutableSortedMap.Builder<Cell, byte[]> writes = ImmutableSortedMap .orderedBy(Ordering.from(UnsignedBytes.lexicographicalComparator()).onResultOf(key -> key.getColumnName())); for (int i = 0 ; i < totalPuts ; i++) { put(t, "row1", "col" + i, "v" + i); if (i % 2 == 0) { writes.put(Cell.create(row, PtBytes.toBytes("col" + i)), PtBytes.toBytes("v" + i)); } } t.commit(); t = startTransaction(); for (int i = 0 ; i < totalPuts ; i++) { if (i % 2 == 1) { delete(t, "row1", "col" + i); } } Map<byte[], BatchingVisitable<Map.Entry<Cell, byte[]>>> columnRange = t.getRowsColumnRange(TEST_TABLE, ImmutableList.of(row), BatchColumnRangeSelection.create(PtBytes.EMPTY_BYTE_ARRAY, PtBytes.EMPTY_BYTE_ARRAY, 1)); List<Map.Entry<Cell, byte[]>> expected = ImmutableList.copyOf(writes.build().entrySet()); verifyMatchingResult(expected, row, columnRange); }
@Test public void testReadMyWritesColumnRangePagingTransaction() { Transaction t = startTransaction(); int totalPuts = 101; byte[] row = PtBytes.toBytes("row1"); // Record expected results using byte ordering ImmutableSortedMap.Builder<Cell, byte[]> writes = ImmutableSortedMap .orderedBy(Ordering.from(UnsignedBytes.lexicographicalComparator()).onResultOf(key -> key.getColumnName())); for (int i = 0 ; i < totalPuts ; i++) { put(t, "row1", "col" + i, "v" + i); if (i % 2 == 0) { writes.put(Cell.create(row, PtBytes.toBytes("col" + i)), PtBytes.toBytes("v" + i)); } } t.commit(); t = startTransaction(); for (int i = 0 ; i < totalPuts ; i++) { if (i % 2 == 1) { put(t, "row1", "col" + i, "t_v" + i); writes.put(Cell.create(row, PtBytes.toBytes("col" + i)), PtBytes.toBytes("t_v" + i)); } } Map<byte[], BatchingVisitable<Map.Entry<Cell, byte[]>>> columnRange = t.getRowsColumnRange(TEST_TABLE, ImmutableList.of(row), BatchColumnRangeSelection.create(PtBytes.EMPTY_BYTE_ARRAY, PtBytes.EMPTY_BYTE_ARRAY, 1)); List<Map.Entry<Cell, byte[]>> expected = ImmutableList.copyOf(writes.build().entrySet()); verifyMatchingResult(expected, row, columnRange); }