/** This used to be the old signature, changed now to {@link #getKey(List)} */ @Deprecated public List<Object> getKey(TableMetadata metadata) { return getKey(metadata.getColumnMetadata()); }
/** * Returns a map over {@code rows}, where the key is the key of the {@link Row} and the value is a * list of {@link Row}s with that key. */ @VisibleForTesting static Map<List<Object>, List<Row>> buildMap(Rows rows, List<ColumnMetadata> metadata) { Map<List<Object>, List<Row>> map = new HashMap<>(); Iterator<Row> iterator = rows.iterator(); while (iterator.hasNext()) { Row row = iterator.next(); map.computeIfAbsent(row.getKey(metadata), k -> new LinkedList<>()).add(row); } return map; }
@Test public void getKey() { Row row = initRowThree(); List<ColumnMetadata> metadataNoKeys = initMetadataThree(false, false, false, false, false, false); List<ColumnMetadata> metadataOneKey = initMetadataThree(false, true, false, false, false, false); List<ColumnMetadata> metadataTwoKeys = initMetadataThree(true, false, true, false, false, false); assertThat(row.getKey(metadataNoKeys), equalTo(ImmutableList.of())); assertThat(row.getKey(metadataOneKey), equalTo(ImmutableList.of("value2"))); assertThat(row.getKey(metadataTwoKeys), equalTo(ImmutableList.of("value1", "value3"))); }
while (baseRows.hasNext()) { Row baseRow = baseRows.next(); Object baseKey = baseRow.getKey(inputMetadata.getColumnMetadata()); baseKeys.add(baseKey); List<Row> deltaRows = deltaMap.get(baseKey); while (deltaRows.hasNext()) { Row deltaRow = deltaRows.next(); Object deltaKey = deltaRow.getKey(inputMetadata.getColumnMetadata()); if (baseKeys.contains(deltaKey)) { continue;