sumitagrawl commented on code in PR #8203:
URL: https://github.com/apache/ozone/pull/8203#discussion_r2121303997
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/metadata/DatanodeTable.java:
##########
@@ -89,6 +89,21 @@ public void deleteWithBatch(BatchOperation batch, KEY key)
"version.");
}
+ @Override
+ public KeyValueSpliterator<KEY, VALUE> spliterator(int maxParallelism,
boolean closeOnException) {
+ throw new UnsupportedOperationException("Iterating tables directly is not"
+
+ " supported for datanode containers due to differing schema " +
Review Comment:
default implementation can throw exception as not supported, no need to add
for all cases.
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBTable.java:
##########
@@ -357,4 +385,37 @@ && get(startKey) == null) {
}
return result;
}
+
+ private KeyValueSpliterator<byte[], byte[]> newByteArraySpliterator(byte[]
prefix, byte[] startKey,
+ int maxParallelism, boolean closeOnException) throws IOException {
+ if (initializeThreadSafeIterator) {
Review Comment:
no use of initializeThreadSafeIterator, if else are same, no need have this
condition
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBStore.java:
##########
@@ -82,13 +83,14 @@ public class RDBStore implements DBStore {
long maxDbUpdatesSizeThreshold,
boolean createCheckpointDirs,
ConfigurationSource configuration,
- boolean enableRocksDBMetrics)
+ boolean enableRocksDBMetrics, boolean
initializeReferenceCountedIterator)
throws IOException {
Preconditions.checkNotNull(dbFile, "DB file location cannot be null");
Preconditions.checkNotNull(families);
Preconditions.checkArgument(!families.isEmpty());
this.maxDbUpdatesSizeThreshold = maxDbUpdatesSizeThreshold;
+ this.initializeReferenceCountedIterator =
initializeReferenceCountedIterator;
Review Comment:
this name should be initializeThreadSafeIterator as being the config and
used with this context.
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/TypedTable.java:
##########
@@ -640,9 +667,17 @@ public void seekToLast() {
@Override
public KeyValue<KEY, VALUE> seek(KEY key) throws IOException {
+ UncheckedAutoCloseable closeable = null;
try (AutoCloseSupplier<RAW> rawKey = convert(key)) {
- final KeyValue<RAW, RAW> result = rawIterator.seek(rawKey.get());
+ RawKeyValue<RAW> result = rawIterator.seek(rawKey.get());
Review Comment:
instead of iterator telling keyValue as closable, RawKeyValue itself can
tell as closable or its derived one.
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBTable.java:
##########
@@ -210,20 +215,43 @@ public void deleteWithBatch(BatchOperation batch, byte[]
key)
}
@Override
- public TableIterator<byte[], KeyValue<byte[], byte[]>> iterator()
+ public BaseDBTableIterator<byte[], ? extends RawKeyValue<byte[]>> iterator()
throws IOException {
return iterator((byte[])null);
}
@Override
- public TableIterator<byte[], KeyValue<byte[], byte[]>> iterator(byte[]
prefix)
+ public BaseDBTableIterator<byte[], ? extends RawKeyValue<byte[]>>
iterator(byte[] prefix)
throws IOException {
- return new RDBStoreByteArrayIterator(db.newIterator(family, false), this,
- prefix);
+ if (initializeThreadSafeIterator) {
+ return new
ReferenceCountedRDBStoreByteArrayIterator(db.newIterator(family, false), this,
prefix);
+ }
+ return new RDBStoreByteArrayIterator(db.newIterator(family, false), this,
prefix);
+ }
+
+ @Override
+ public KeyValueSpliterator<byte[], byte[]> spliterator(int maxParallelism,
boolean closeOnException)
+ throws IOException {
+ return spliterator(null, null, maxParallelism, closeOnException);
+ }
+
+ @Override
+ public KeyValueSpliterator<byte[], byte[]> spliterator(byte[] startKey,
byte[] prefix, int maxParallelism,
+ boolean closeOnException) throws IOException {
+ return newByteArraySpliterator(prefix, startKey, maxParallelism,
closeOnException);
}
- TableIterator<CodecBuffer, KeyValue<CodecBuffer, CodecBuffer>> iterator(
+ BaseDBTableIterator<CodecBuffer, ? extends RawKeyValue<CodecBuffer>>
iterator(
CodecBuffer prefix) throws IOException {
+ return iterator(prefix, 1);
+ }
+
+ BaseDBTableIterator<CodecBuffer, ? extends RawKeyValue<CodecBuffer>>
iterator(
+ CodecBuffer prefix, int maxNumberOfBuffers) throws IOException {
+ if (initializeThreadSafeIterator) {
Review Comment:
IMO, we do not need support ReferenceCountedRDBStoreCodecBufferIterator as
if required performance with parallel, can use SplitIterator as provided
separately
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/DBStoreBuilder.java:
##########
@@ -226,7 +226,7 @@ public RDBStore build() throws IOException {
return new RDBStore(dbFile, rocksDBOption, statistics, writeOptions,
tableConfigs,
openReadOnly, dbJmxBeanNameName, enableCompactionDag,
maxDbUpdatesSizeThreshold, createCheckpointDirs, configuration,
- enableRocksDbMetrics);
+ enableRocksDbMetrics,
rocksDBConfiguration.isThreadSafeIteratorEnabled());
Review Comment:
we should not define configuration as threadsafe or not as we are not
exposing SDK to be integrated to other solution. Ozone should work as thread
safe in usages, may be some layer is not threadsafe.
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBTable.java:
##########
@@ -210,20 +215,43 @@ public void deleteWithBatch(BatchOperation batch, byte[]
key)
}
@Override
- public TableIterator<byte[], KeyValue<byte[], byte[]>> iterator()
+ public BaseDBTableIterator<byte[], ? extends RawKeyValue<byte[]>> iterator()
throws IOException {
return iterator((byte[])null);
}
@Override
- public TableIterator<byte[], KeyValue<byte[], byte[]>> iterator(byte[]
prefix)
+ public BaseDBTableIterator<byte[], ? extends RawKeyValue<byte[]>>
iterator(byte[] prefix)
throws IOException {
- return new RDBStoreByteArrayIterator(db.newIterator(family, false), this,
- prefix);
+ if (initializeThreadSafeIterator) {
+ return new
ReferenceCountedRDBStoreByteArrayIterator(db.newIterator(family, false), this,
prefix);
Review Comment:
ReferenceCountedRDBStoreByteArrayIterator -- not getting weather this have
any thread safety issue. generally data is read to new byte[] and not using
shared Buffer in CodecBuffer, so what kind of thread safety its providing ?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]