-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
355 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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
55 changes: 55 additions & 0 deletions
55
cloudata-keyvalue/src/main/java/com/cloudata/keyvalue/web/KeyValueQuery.java
This file contains 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,55 @@ | |||
package com.cloudata.keyvalue.web; | |||
|
|||
import java.nio.ByteBuffer; | |||
|
|||
import com.cloudata.keyvalue.btree.Btree; | |||
import com.cloudata.keyvalue.btree.EntryListener; | |||
import com.cloudata.keyvalue.btree.ReadOnlyTransaction; | |||
|
|||
public class KeyValueQuery { | |||
|
|||
private final Btree btree; | |||
private final ByteBuffer start; | |||
|
|||
public KeyValueQuery(Btree btree) { | |||
this.btree = btree; | |||
this.start = null; | |||
} | |||
|
|||
public KeyValueResultset execute() { | |||
ReadOnlyTransaction txn = null; | |||
KeyValueResultset cursor = null; | |||
|
|||
try { | |||
txn = btree.beginReadOnly(); | |||
|
|||
cursor = new KeyValueResultset(txn); | |||
txn = null; | |||
} finally { | |||
if (txn != null) { | |||
txn.close(); | |||
} | |||
} | |||
|
|||
return cursor; | |||
} | |||
|
|||
public class KeyValueResultset implements AutoCloseable { | |||
private final ReadOnlyTransaction txn; | |||
|
|||
public KeyValueResultset(ReadOnlyTransaction txn) { | |||
this.txn = txn; | |||
} | |||
|
|||
public void walk(EntryListener entryListener) { | |||
txn.walk(btree, start, entryListener); | |||
} | |||
|
|||
@Override | |||
public void close() { | |||
txn.close(); | |||
} | |||
|
|||
} | |||
|
|||
} |
Oops, something went wrong.