tkalkirill commented on code in PR #1526:
URL: https://github.com/apache/ignite-3/pull/1526#discussion_r1071195665
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/raft/MetaStorageListener.java:
##########
@@ -253,19 +254,27 @@ public void
onWrite(Iterator<CommandClosure<WriteCommand>> iter) {
IgniteUuid cursorId = rangeCmd.cursorId();
- Cursor<Entry> cursor = (rangeCmd.revUpperBound() != -1)
+ Cursor<Entry> cursor = rangeCmd.revUpperBound() != -1
? storage.range(rangeCmd.keyFrom(), rangeCmd.keyTo(),
rangeCmd.revUpperBound(), rangeCmd.includeTombstones())
: storage.range(rangeCmd.keyFrom(), rangeCmd.keyTo(),
rangeCmd.includeTombstones());
- cursors.put(
- cursorId,
- new CursorMeta(
- cursor,
- CursorType.RANGE,
- rangeCmd.requesterNodeId(),
- rangeCmd.batchSize()
- )
- );
+ var meta = new CursorMeta(cursor, CursorType.RANGE,
rangeCmd.requesterNodeId(), rangeCmd.batchSize());
Review Comment:
I think `metaCursor` would be a better name.
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/server/raft/MetaStorageListener.java:
##########
@@ -253,19 +254,27 @@ public void
onWrite(Iterator<CommandClosure<WriteCommand>> iter) {
IgniteUuid cursorId = rangeCmd.cursorId();
- Cursor<Entry> cursor = (rangeCmd.revUpperBound() != -1)
+ Cursor<Entry> cursor = rangeCmd.revUpperBound() != -1
? storage.range(rangeCmd.keyFrom(), rangeCmd.keyTo(),
rangeCmd.revUpperBound(), rangeCmd.includeTombstones())
: storage.range(rangeCmd.keyFrom(), rangeCmd.keyTo(),
rangeCmd.includeTombstones());
- cursors.put(
- cursorId,
- new CursorMeta(
- cursor,
- CursorType.RANGE,
- rangeCmd.requesterNodeId(),
- rangeCmd.batchSize()
- )
- );
+ var meta = new CursorMeta(cursor, CursorType.RANGE,
rangeCmd.requesterNodeId(), rangeCmd.batchSize());
+
+ cursors.put(cursorId, meta);
+
+ clo.result(cursorId);
+ } else if (command instanceof PrefixCommand) {
+ var prefixCmd = (PrefixCommand) command;
+
+ IgniteUuid cursorId = prefixCmd.cursorId();
+
+ Cursor<Entry> cursor = prefixCmd.revUpperBound() == -1
+ ? storage.prefix(prefixCmd.prefix(),
prefixCmd.includeTombstones())
+ : storage.prefix(prefixCmd.prefix(),
prefixCmd.revUpperBound(), prefixCmd.includeTombstones());
+
+ var meta = new CursorMeta(cursor, CursorType.RANGE,
prefixCmd.requesterNodeId(), prefixCmd.batchSize());
+
+ cursors.put(cursorId, meta);
Review Comment:
I think `metaCursor` would be a better name.
##########
modules/metastorage/src/main/java/org/apache/ignite/internal/metastorage/impl/MetaStorageManagerImpl.java:
##########
@@ -676,17 +676,15 @@ public Cursor<Entry> range(ByteArray keyFrom, @Nullable
ByteArray keyTo) throws
* @see ByteArray
* @see Entry
*/
- public @NotNull Cursor<Entry> prefixWithAppliedRevision(@NotNull ByteArray
keyPrefix) throws NodeStoppingException {
+ public Cursor<Entry> prefixWithAppliedRevision(ByteArray keyPrefix) throws
NodeStoppingException {
if (!busyLock.enterBusy()) {
Review Comment:
U can use
`org.apache.ignite.internal.util.IgniteUtils#inBusyLock(org.apache.ignite.internal.util.IgniteSpinBusyLock,
java.util.function.Supplier<T>)`
##########
modules/metastorage/src/testFixtures/java/org/apache/ignite/internal/metastorage/server/SimpleInMemoryKeyValueStorage.java:
##########
@@ -359,21 +360,30 @@ public StatementResult invoke(If iif) {
}
}
- /** {@inheritDoc} */
@Override
public Cursor<Entry> range(byte[] keyFrom, byte[] keyTo, boolean
includeTombstones) {
synchronized (mux) {
return new RangeCursor(keyFrom, keyTo, rev, includeTombstones);
}
}
- /** {@inheritDoc} */
@Override
public Cursor<Entry> range(byte[] keyFrom, byte[] keyTo, long
revUpperBound, boolean includeTombstones) {
return new RangeCursor(keyFrom, keyTo, revUpperBound,
includeTombstones);
}
- /** {@inheritDoc} */
+ @Override
+ public Cursor<Entry> prefix(byte[] prefix, boolean includeTombstones) {
+ synchronized (mux) {
Review Comment:
Maybe you should add `synchronized` for `prefix`* methods header, for
example `public synchronized Cursor<Entry> prefix(...)`?
--
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]