You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2022/03/08 09:50:05 UTC
[GitHub] [ozone] guihecheng opened a new pull request #3176: HDDS-6428. [Merge rocksdb in datanode] Add prefix iterator support to RDBTable.
guihecheng opened a new pull request #3176:
URL: https://github.com/apache/ozone/pull/3176
## What changes were proposed in this pull request?
Add prefix iterator support to RDBTable.
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-6428
## How was this patch tested?
new ut added.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] guihecheng commented on a change in pull request #3176: HDDS-6428. [Merge rocksdb in datanode] Add prefix iterator support to RDBTable.
Posted by GitBox <gi...@apache.org>.
guihecheng commented on a change in pull request #3176:
URL: https://github.com/apache/ozone/pull/3176#discussion_r832962856
##########
File path: hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBStoreIterator.java
##########
@@ -69,7 +81,9 @@ private void setCurrentEntry() {
@Override
public boolean hasNext() {
- return rocksDBIterator.isValid();
+ return rocksDBIterator.isValid() &&
+ (prefix == null || Arrays.equals(
+ Arrays.copyOf(rocksDBIterator.key(), prefix.length), prefix));
Review comment:
Ah, that's a good idea to prevent copy, thanks~
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] guihecheng commented on pull request #3176: HDDS-6428. [Merge rocksdb in datanode] Add prefix iterator support to RDBTable.
Posted by GitBox <gi...@apache.org>.
guihecheng commented on pull request #3176:
URL: https://github.com/apache/ozone/pull/3176#issuecomment-1065037032
@mukul1987 descriptions updated above, thanks~
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] nandakumar131 commented on a change in pull request #3176: HDDS-6428. [Merge rocksdb in datanode] Add prefix iterator support to RDBTable.
Posted by GitBox <gi...@apache.org>.
nandakumar131 commented on a change in pull request #3176:
URL: https://github.com/apache/ozone/pull/3176#discussion_r832793846
##########
File path: hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBTable.java
##########
@@ -57,6 +57,7 @@
private final ColumnFamilyHandle handle;
private final WriteOptions writeOptions;
private final RDBMetrics rdbMetrics;
+ private int prefixLength;
Review comment:
We don't need to have _prefixLength_ associated with RDBTable. Prefix is something which should be passed as an argument. It is not applicable at table level.
For _getRangeKVs_ calls we can use _MetadataKeyFilters.MetadataKeyFilter_ for passing prefix to be matched.
If we need the Iterator optimized prefix filter to be used, we can add a new _getSequentialRangeKVs_ method which also takes prefix as an argument. (Since we cannot use _MetadataKeyFilters.MetadataKeyFilter_ as prefix filter for Iterator creation)
##########
File path: hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/Table.java
##########
@@ -153,6 +153,20 @@ default VALUE getReadCopy(KEY key) throws IOException {
*/
TableIterator<KEY, ? extends KeyValue<KEY, VALUE>> iterator();
+ /**
+ * Returns a prefixed iterator for this metadata store.
+ * @param prefix
+ * @return
+ */
+ TableIterator<KEY, ? extends KeyValue<KEY, VALUE>> iterator(KEY prefix)
+ throws IOException;
+
+ /**
+ * Set the fixed key prefix length.
+ * @param length
+ */
+ void setFixedPrefixLength(int length);
Review comment:
We should not set prefix length at _Table_ level.
##########
File path: hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBStoreIterator.java
##########
@@ -69,7 +81,9 @@ private void setCurrentEntry() {
@Override
public boolean hasNext() {
- return rocksDBIterator.isValid();
+ return rocksDBIterator.isValid() &&
+ (prefix == null || Arrays.equals(
+ Arrays.copyOf(rocksDBIterator.key(), prefix.length), prefix));
Review comment:
Can we avoid _Arrays.copyOf_ here as the value is not modified/passed outside. We can implement our own comparison logic instead.
```suggestion
private static boolean startsWith(byte[] prefix, byte[] value) {
if (prefix==null)
return true;
if (value==null)
return false;
int length = prefix.length;
if (value.length < length)
return false;
for (int i=0; i<length; i++)
if (prefix[i] != value[i])
return false;
return true;
}
```
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] guihecheng commented on pull request #3176: HDDS-6428. [Merge rocksdb in datanode] Add prefix iterator support to RDBTable.
Posted by GitBox <gi...@apache.org>.
guihecheng commented on pull request #3176:
URL: https://github.com/apache/ozone/pull/3176#issuecomment-1076358571
Hi @nandakumar131 , I'm sorry that I have to do a force push since I did a rebase on HDDS-3630, because the new changes will conflict with the merged HDDS-6404.
Here I did remove the `setFixedPrefixLength` at table level, but to pass the necessary prefix to the rocksdb, I have to add a new parameter to the interfaces `getRangeKVs ` and `getSequentialRangeKVs `.
Originally I tends to extract the prefix in the `startKey` with the `prefixLength`, but it is not good.
And I tried to extract the prefix from the KeyFilters, but the prefix should go through a proper the codec classes in `TypedTable`, but the KeyFilter has its own way to manage positive and negative prefixes, which is hard to refactor.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] guihecheng commented on a change in pull request #3176: HDDS-6428. [Merge rocksdb in datanode] Add prefix iterator support to RDBTable.
Posted by GitBox <gi...@apache.org>.
guihecheng commented on a change in pull request #3176:
URL: https://github.com/apache/ozone/pull/3176#discussion_r833042668
##########
File path: hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBTable.java
##########
@@ -57,6 +57,7 @@
private final ColumnFamilyHandle handle;
private final WriteOptions writeOptions;
private final RDBMetrics rdbMetrics;
+ private int prefixLength;
Review comment:
OK...I found it not so easy to pass then extract prefix using the `MetadataKeyFilters.MetadataKeyFilter`, because the KeyFilter interface doesn't offer convenient interface for that and hard to refactor. And also we haven't introduced the fixed-length prefix stuff for schemaV3 keys and we can't assume the char encoding in general purpose classes like `MetadataKeyFilters.MetadataKeyFilter` or `RDBTable`.
I'm trying to add a new parameter `prefix` to the `getRangeKVs` & `getSequentialRangeKVs` interfaces.
I feel that it is painful to do so, but I would like to have abstracted interfaces for all schemas instead of `if-else` checks in each call place.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] guihecheng commented on a change in pull request #3176: HDDS-6428. [Merge rocksdb in datanode] Add prefix iterator support to RDBTable.
Posted by GitBox <gi...@apache.org>.
guihecheng commented on a change in pull request #3176:
URL: https://github.com/apache/ozone/pull/3176#discussion_r833042668
##########
File path: hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBTable.java
##########
@@ -57,6 +57,7 @@
private final ColumnFamilyHandle handle;
private final WriteOptions writeOptions;
private final RDBMetrics rdbMetrics;
+ private int prefixLength;
Review comment:
OK...I found it not so easy to pass then extract prefix using the `MetadataKeyFilters.MetadataKeyFilter`, because the KeyFilter interface doesn't offer convenient interface for that and hard to refactor. And also we haven't introduced the fixed-length prefix stuff for schemaV3 keys and we can't assume the char encoding in general purpose classes like `MetadataKeyFilters.MetadataKeyFilter` or `RDBTable`.
I'm trying to add a new parameter `prefix` to the `getRangeKVs` & `getSequentialRangeKVs` interfaces.
I feel that it is painful to do so, but I would like to have abstracted interfaces for all schemas instead of `if-else` checks.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] nandakumar131 merged pull request #3176: HDDS-6428. [Merge rocksdb in datanode] Add prefix iterator support to RDBTable.
Posted by GitBox <gi...@apache.org>.
nandakumar131 merged pull request #3176:
URL: https://github.com/apache/ozone/pull/3176
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] mukul1987 commented on pull request #3176: HDDS-6428. [Merge rocksdb in datanode] Add prefix iterator support to RDBTable.
Posted by GitBox <gi...@apache.org>.
mukul1987 commented on pull request #3176:
URL: https://github.com/apache/ozone/pull/3176#issuecomment-1064941124
@guihecheng can we please add an example of entries in the table which we expect ? And what is the need for fixed prefix length support, that will help in reviewing this further.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] guihecheng commented on pull request #3176: HDDS-6428. [Merge rocksdb in datanode] Add prefix iterator support to RDBTable.
Posted by GitBox <gi...@apache.org>.
guihecheng commented on pull request #3176:
URL: https://github.com/apache/ozone/pull/3176#issuecomment-1064948166
@mukul1987 Oh, sure, I'll add more descriptions about the sample prefixed keys after rocksdb-merge and explain the need to have fixed length prefixes soon.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] guihecheng commented on a change in pull request #3176: HDDS-6428. [Merge rocksdb in datanode] Add prefix iterator support to RDBTable.
Posted by GitBox <gi...@apache.org>.
guihecheng commented on a change in pull request #3176:
URL: https://github.com/apache/ozone/pull/3176#discussion_r832964862
##########
File path: hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/RDBTable.java
##########
@@ -57,6 +57,7 @@
private final ColumnFamilyHandle handle;
private final WriteOptions writeOptions;
private final RDBMetrics rdbMetrics;
+ private int prefixLength;
Review comment:
Yes, it is better to prevent a prefixLength set at the table level.
Here I tried to have unified interface for different schemas, so I'll try to use the `MetadataKeyFilters.MetadataKeyFilter` to pass prefix but not introducing new method dedicated for schema v3.
##########
File path: hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/utils/db/Table.java
##########
@@ -153,6 +153,20 @@ default VALUE getReadCopy(KEY key) throws IOException {
*/
TableIterator<KEY, ? extends KeyValue<KEY, VALUE>> iterator();
+ /**
+ * Returns a prefixed iterator for this metadata store.
+ * @param prefix
+ * @return
+ */
+ TableIterator<KEY, ? extends KeyValue<KEY, VALUE>> iterator(KEY prefix)
+ throws IOException;
+
+ /**
+ * Set the fixed key prefix length.
+ * @param length
+ */
+ void setFixedPrefixLength(int length);
Review comment:
Sure
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org