@Test public void testPutAll() throws IOException, URISyntaxException { DiskBasedMap<String, HoodieRecord> records = new DiskBasedMap<>(basePath); List<IndexedRecord> iRecords = SchemaTestUtil.generateHoodieTestRecords(0, 100); Map<String, HoodieRecord> recordMap = new HashMap<>(); iRecords.forEach(r -> { String key = ((GenericRecord) r).get(HoodieRecord.RECORD_KEY_METADATA_FIELD).toString(); String partitionPath = ((GenericRecord) r).get(HoodieRecord.PARTITION_PATH_METADATA_FIELD).toString(); HoodieRecord value = new HoodieRecord<>(new HoodieKey(key, partitionPath), new HoodieAvroPayload(Option.of((GenericRecord) r))); recordMap.put(key, value); }); records.putAll(recordMap); assertTrue(records.sizeOfFileOnDiskInBytes() > 0); for (Map.Entry<String, HoodieRecord> entry : records.entrySet()) { assertTrue(recordMap.containsKey(entry.getKey())); } }
@Override public void putAll(Map<? extends T, ? extends R> m) { for (Map.Entry<? extends T, ? extends R> entry : m.entrySet()) { put(entry.getKey(), entry.getValue(), false); } flushToDisk(); }
DiskBasedMap implements Map<T, R>, Iterable<R> { @Override public void putAll(Map<? extends T, ? extends R> m) { for (Map.Entry<? extends T, ? extends R> entry : m.entrySet()) { put(entry.getKey(), entry.getValue(), false); } flushToDisk(); } }
DiskBasedMap implements Map<T, R>, Iterable<R> { @Override public void putAll(Map<? extends T, ? extends R> m) { for (Map.Entry<? extends T, ? extends R> entry : m.entrySet()) { put(entry.getKey(), entry.getValue(), false); } flushToDisk(); } DiskBasedMap(String baseFilePath); }
DiskBasedMap implements Map<T, R>, Iterable<R> { @Override public void putAll(Map<? extends T, ? extends R> m) { for (Map.Entry<? extends T, ? extends R> entry : m.entrySet()) { put(entry.getKey(), entry.getValue(), false); } flushToDisk(); } DiskBasedMap(String baseFilePath); @Override Iterator<R> iterator(); long sizeOfFileOnDiskInBytes(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override R get(Object key); static R get(ValueMetadata entry, RandomAccessFile file); @Override R put(T key, R value); @Override R remove(Object key); @Override void putAll(Map<? extends T, ? extends R> m); @Override void clear(); @Override Set<T> keySet(); @Override Collection<R> values(); Stream<R> valueStream(); @Override Set<Entry<T, R>> entrySet(); }
DiskBasedMap implements Map<T, R>, Iterable<R> { @Override public void putAll(Map<? extends T, ? extends R> m) { for (Map.Entry<? extends T, ? extends R> entry : m.entrySet()) { put(entry.getKey(), entry.getValue(), false); } flushToDisk(); } DiskBasedMap(String baseFilePath); @Override Iterator<R> iterator(); long sizeOfFileOnDiskInBytes(); @Override int size(); @Override boolean isEmpty(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @Override R get(Object key); static R get(ValueMetadata entry, RandomAccessFile file); @Override R put(T key, R value); @Override R remove(Object key); @Override void putAll(Map<? extends T, ? extends R> m); @Override void clear(); @Override Set<T> keySet(); @Override Collection<R> values(); Stream<R> valueStream(); @Override Set<Entry<T, R>> entrySet(); static final int BUFFER_SIZE; }