bvaradar commented on a change in pull request #600: Timeline Service with
Incremental View Syncing support
URL: https://github.com/apache/incubator-hudi/pull/600#discussion_r276859556
##########
File path:
hoodie-common/src/main/java/com/uber/hoodie/common/util/collection/DiskBasedMap.java
##########
@@ -155,16 +166,39 @@ public R get(Object key) {
if (entry == null) {
return null;
}
+ return get(entry);
+ }
+
+ private void close(RandomAccessFile file) {
+ if (file != null) {
+ try {
+ file.close();
+ } catch (IOException e) {
+ log.warn("Unable to close read pointer :", e);
+ }
+ }
+ }
+
+ private R get(ValueMetadata entry) {
+ RandomAccessFile file = getNewRandomAccessFile();
+ try {
+ return get(entry, file);
+ } finally {
+ close(file);
+ }
+ }
+
+ public static <R> R get(ValueMetadata entry, RandomAccessFile file) {
try {
- return SerializationUtils.<R>deserialize(SpillableMapUtils
- .readBytesFromDisk(readOnlyFileHandle, entry.getOffsetOfValue(),
entry.getSizeOfValue()));
+ return
SerializationUtils.deserialize(SpillableMapUtils.readBytesFromDisk(file,
+ entry.getOffsetOfValue(), entry.getSizeOfValue()));
} catch (IOException e) {
throw new HoodieIOException("Unable to readFromDisk Hoodie Record from
disk", e);
}
}
@Override
- public R put(T key, R value) {
+ public synchronized R put(T key, R value) {
Review comment:
This required synchronization because of single writer guarantee
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services