-
Notifications
You must be signed in to change notification settings - Fork 588
HDDS-8497. Add leading zeroes on to report table to optimize get Pagecall of Snapdiff #4722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ec7a218
HDDS-8497. Add leading zeroes on to report table to optimize get Page…
swamirishi b17518f
HDDS-8497. Close readoptions
swamirishi 2ab1812
Merge remote-tracking branch 'apache/master' into HEAD
swamirishi ecab686
HDDS-8497. Address review comments
swamirishi 6e578eb
HDDS-8497. Address review comments
swamirishi e86fc93
HDDS-8497. Fix checkstyle
swamirishi 303ded1
HDDS-8497: Fix failures
swamirishi 6247b3b
HDDS-8497: Address review comments
swamirishi 4143ba5
Merge remote-tracking branch 'apache/master' into HEAD
swamirishi 242bed8
Merge remote-tracking branch 'apache/master' into HEAD
swamirishi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,11 +20,16 @@ | |
|
|
||
| import java.io.IOException; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
| import javax.annotation.Nonnull; | ||
|
|
||
| import java.util.NoSuchElementException; | ||
|
|
||
| import org.apache.hadoop.hdds.utils.db.CodecRegistry; | ||
| import org.apache.hadoop.hdds.utils.db.managed.ManagedReadOptions; | ||
| import org.apache.hadoop.hdds.utils.db.managed.ManagedRocksDB; | ||
| import org.apache.hadoop.hdds.utils.db.managed.ManagedRocksIterator; | ||
| import org.apache.hadoop.hdds.utils.db.managed.ManagedSlice; | ||
| import org.apache.hadoop.util.ClosableIterator; | ||
| import org.rocksdb.ColumnFamilyHandle; | ||
| import org.rocksdb.RocksDBException; | ||
|
|
@@ -39,11 +44,11 @@ public class RocksDbPersistentMap<K, V> implements PersistentMap<K, V> { | |
| private final Class<K> keyType; | ||
| private final Class<V> valueType; | ||
|
|
||
| public RocksDbPersistentMap(ManagedRocksDB db, | ||
| ColumnFamilyHandle columnFamilyHandle, | ||
| CodecRegistry codecRegistry, | ||
| Class<K> keyType, | ||
| Class<V> valueType) { | ||
| public RocksDbPersistentMap(@Nonnull ManagedRocksDB db, | ||
| @Nonnull ColumnFamilyHandle columnFamilyHandle, | ||
| @Nonnull CodecRegistry codecRegistry, | ||
| @Nonnull Class<K> keyType, | ||
| @Nonnull Class<V> valueType) { | ||
| this.db = db; | ||
| this.columnFamilyHandle = columnFamilyHandle; | ||
| this.codecRegistry = codecRegistry; | ||
|
|
@@ -87,9 +92,36 @@ public void remove(K key) { | |
| } | ||
|
|
||
| @Override | ||
| public ClosableIterator<Map.Entry<K, V>> iterator() { | ||
| ManagedRocksIterator iterator = | ||
| new ManagedRocksIterator(db.get().newIterator(columnFamilyHandle)); | ||
| public ClosableIterator<Map.Entry<K, V>> iterator(Optional<K> lowerBound, | ||
swamirishi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Optional<K> upperBound) { | ||
|
Comment on lines
+95
to
+96
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please do not declare parameters with |
||
| final ManagedReadOptions readOptions = new ManagedReadOptions(); | ||
| ManagedRocksIterator iterator; | ||
| final ManagedSlice lowerBoundSlice; | ||
| final ManagedSlice upperBoundSlice; | ||
| try { | ||
| if (lowerBound.isPresent()) { | ||
| lowerBoundSlice = new ManagedSlice( | ||
| codecRegistry.asRawData(lowerBound.get())); | ||
| readOptions.setIterateLowerBound(lowerBoundSlice); | ||
| } else { | ||
| lowerBoundSlice = null; | ||
| } | ||
|
|
||
| if (upperBound.isPresent()) { | ||
| upperBoundSlice = new ManagedSlice( | ||
| codecRegistry.asRawData(upperBound.get())); | ||
| readOptions.setIterateUpperBound(upperBoundSlice); | ||
| } else { | ||
| upperBoundSlice = null; | ||
| } | ||
| } catch (IOException exception) { | ||
| // TODO: [SNAPSHOT] Fail gracefully. | ||
| throw new RuntimeException(exception); | ||
| } | ||
|
|
||
| iterator = ManagedRocksIterator.managed( | ||
| db.get().newIterator(columnFamilyHandle, readOptions)); | ||
|
|
||
| iterator.get().seekToFirst(); | ||
|
|
||
| return new ClosableIterator<Map.Entry<K, V>>() { | ||
|
|
@@ -138,6 +170,13 @@ public V setValue(V value) { | |
| @Override | ||
| public void close() { | ||
| iterator.close(); | ||
| readOptions.close(); | ||
| if (upperBoundSlice != null) { | ||
| upperBoundSlice.close(); | ||
| } | ||
| if (lowerBoundSlice != null) { | ||
| lowerBoundSlice.close(); | ||
| } | ||
| } | ||
| }; | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.