Skip to content

Commit

Permalink
fix: apply limits of count and offset
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviarla committed Dec 11, 2023
1 parent 6f41298 commit 1a25795
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 23 deletions.
15 changes: 8 additions & 7 deletions docs/07-btree-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1070,11 +1070,11 @@ asyncBopPipedUpdateBulk(String key, List<Element<Object>> elements)

## B+Tree Element 일괄 조회

다수의 b+tree들 각각에 대해 from부터 to까지의 bkey를 가진 elements를 탐색하면서,
eFlagFilter 조건을 만족하는 elements 중 offset 위치부터 count 개수만큼 조회한다.
다수의 b+tree에 각각 조회 요청을 보내 bkey가 from부터 to사이에 존재하며 eFlagFilter 조건을 만족하는 elements 중 offset 위치부터 count 개수만큼 조회한다.
각 b+tree에서 조회한 element는 최대 count개이며, 주어진 b+tree들에서 조회한 element 개수의 총합은 0부터 (count * keyList.size())개가 될 수 있다.

```java
CollectionGetBulkFuturee<Map<String, BTreeGetResult<Long, Object>>>
CollectionGetBulkFuture<Map<String, BTreeGetResult<Long, Object>>>
asyncBopGetBulk(List<String> keyList, long from, long to, ElementFlagFilter eFlagFilter, int offset, int count)
CollectionGetBulkFuture<Map<String, BTreeGetResult<ByteArrayBKey, Object>>>
asyncBopGetBulk(List<String> keyList, byte[] from, byte[] to, ElementFlagFilter eFlagFilter, int offset, int count)
Expand All @@ -1085,6 +1085,7 @@ asyncBopGetBulk(List<String> keyList, byte[] from, byte[] to, ElementFlagFilter
- eFlagFilter: eflag에 대한 filter 조건
- eflag filter 조건을 지정하지 않으려면, ElementFlagFilter.DO_NOT_FILTER를 입력한다.
- offset, count: bkey range와 eflag filter 조건을 만족하는 elements에서 실제 조회할 element의 offset과 count 지정
- **count 값은 1 이상 50 이하여야 한다.**


수행 결과는 future 객체를 통해 Map\<Stirng, BTreeGetResult\<Bkey, Object\>\>을 얻으며,
Expand Down Expand Up @@ -1213,8 +1214,8 @@ missed keys에 대한 DB 조회가 offset으로 skip된 element를 가지는 경
이전에 조회된 bkey 값을 바탕으로 bkey range를 재조정하여 사용할 수 있다.

여러 b+tree들에 대해 sort-merge get을 수행하는 함수는 아래와 같다.
여러 b+tree들로 부터 from부터 to까지의 bkey를 가지고 있으면서 eflag filter조건을 만족하는 element를 찾아
sort merge하면서, count개의 element를 조회한다.
여러 b+tree들에서 bkey가 from부터 to사이에 해당하며 eflag filter조건을 만족하는 element들을 sort merge하면서,
count개 까지 element를 조회한다.

```java
SMGetFuture<List<SMGetElement<Object>>>
Expand All @@ -1228,8 +1229,8 @@ asyncBopSortMergeGet(List<String> keyList, byte[] from, byte[] to, ElementFlagFi
- eFlagFilter: eflag에 대한 filter 조건
- eflag filter 조건을 지정하지 않으려면, ElementFlagFilter.DO_NOT_FILTER를 입력한다.
- count: bkey range와 eflag filter 조건을 만족하는 elements에서 실제 조회할 element의 count 지정
- **제약 조건으로 1000이하이어야 한다.**
- 이는 sort-merge get 연산이 부담이 너무 크지 않은 연산으로 제한하기 위한 것이다.
- **count 값은 1 이상 1000이하이어야 한다.**
- 이는 sort-merge get 연산을 부담이 너무 크지 않은 연산으로 제한하기 위해서이다.
- smgetMode: smget에 대해서 mode를 지정하는 flag
- unique 조회 또는 duplicate 조회를 지정한다.

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/net/spy/memcached/ArcusClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -3917,6 +3917,9 @@ public <T> CollectionGetBulkFuture<Map<String, BTreeGetResult<Long, T>>> asyncBo
if (offset < 0) {
throw new IllegalArgumentException("Offset must be 0 or positive integer.");
}
if (count < 1) {
throw new IllegalArgumentException("Count must be larger than 0.");
}
if (count > MAX_GETBULK_ELEMENT_COUNT) {
throw new IllegalArgumentException("Count must not exceed a maximum of "
+ MAX_GETBULK_ELEMENT_COUNT + ".");
Expand Down Expand Up @@ -3955,6 +3958,9 @@ public <T> CollectionGetBulkFuture<Map<String, BTreeGetResult<ByteArrayBKey, T>>
if (offset < 0) {
throw new IllegalArgumentException("Offset must be 0 or positive integer.");
}
if (count < 1) {
throw new IllegalArgumentException("Count must be larger than 0.");
}
if (count > MAX_GETBULK_ELEMENT_COUNT) {
throw new IllegalArgumentException("Count must not exceed a maximum of "
+ MAX_GETBULK_ELEMENT_COUNT + ".");
Expand Down
42 changes: 26 additions & 16 deletions src/main/java/net/spy/memcached/ArcusClientIF.java
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,8 @@ <T> CollectionFuture<Map<Integer, CollectionOperationStatus>> asyncSopPipedInser
* @param to bkey index to
* @param eFlagFilter element flag filter
* @param offset 0-base offset
* @param count number of returning values (0 to all)
* @param count number of returning values. must be larger than 0.
* {@code offset + count} must not be more than 1000.
* @return a future that will hold the return value list of the fetch.
*/
SMGetFuture<List<SMGetElement<Object>>> asyncBopSortMergeGet(
Expand All @@ -1418,7 +1419,7 @@ SMGetFuture<List<SMGetElement<Object>>> asyncBopSortMergeGet(
* @param from bkey index from
* @param to bkey index to
* @param eFlagFilter element flag filter
* @param count number of returning values (0 to all)
* @param count number of returning values. must be larger than 0 and not more than 1000.
* @param smgetMode smgetMode
* @return a future that will hold the return value list of the fetch.
*/
Expand Down Expand Up @@ -1913,7 +1914,8 @@ <T> CollectionFuture<Map<ByteArrayBKey, Element<T>>> asyncBopGet(
* @param to bkey index to
* @param eFlagFilter element flag filter
* @param offset 0-base offset
* @param count number of returning values (0 to all)
* @param count number of returning values. must be larger than 0.
* {@code offset + count} must not be more than 1000.
* @return a future that will hold the return value list of the fetch.
*/
SMGetFuture<List<SMGetElement<Object>>> asyncBopSortMergeGet(
Expand All @@ -1928,7 +1930,7 @@ SMGetFuture<List<SMGetElement<Object>>> asyncBopSortMergeGet(
* @param from bkey index from
* @param to bkey index to
* @param eFlagFilter element flag filter
* @param count number of returning values (0 to all)
* @param count number of returning values. must be larger than 0 and not more than 1000.
* @param smgetMode smgetMode
* @return a future that will hold the return value list of the fetch.
*/
Expand Down Expand Up @@ -1971,14 +1973,16 @@ <T> Future<Map<String, CollectionOperationStatus>> asyncBopInsertBulk(
byte[] eFlag, T value, CollectionAttributes attributesForCreate, Transcoder<T> tc);

/**
* Get elements from each b+tree.
* Get elements from multiple b+trees.
*
* @param keyList key list of b+tree
* @param from bkey from
* @param to bkey to
* @param eFlagFilter element flag filter
* @param offset 0-based offset (max = 50)
* @param count number of returning values (0 to all) (max = 200)
* @param offset 0-based offset. must be 0 or positive.
* @param count number of elements to retrieve from each b+tree.
* must be larger than 0 and not more than 50.
* total number of returning elements could be 0 to (count * keyList.size()).
* @return future indicating result of each b+tree
*/
CollectionGetBulkFuture<Map<String, BTreeGetResult<ByteArrayBKey, Object>>>
Expand All @@ -1987,15 +1991,17 @@ <T> Future<Map<String, CollectionOperationStatus>> asyncBopInsertBulk(
ElementFlagFilter eFlagFilter, int offset, int count);

/**
* Get elements from each b+tree.
* Get elements from multiple b+trees.
*
* @param <T> the expected class of the value
* @param keyList key list of b+tree
* @param from bkey from
* @param to bkey to
* @param eFlagFilter element flag filter
* @param offset 0-based offset (max = 50)
* @param count number of returning values (0 to all) (max = 200)
* @param offset 0-based offset. must be 0 or positive.
* @param count number of elements to retrieve from each b+tree.
* must be larger than 0 and not more than 50.
* total number of returning elements could be 0 to (count * keyList.size()).
* @param tc transcoder to decode value
* @return future indicating result of each b+tree
*/
Expand All @@ -2005,30 +2011,34 @@ <T> CollectionGetBulkFuture<Map<String, BTreeGetResult<ByteArrayBKey, T>>> async
Transcoder<T> tc);

/**
* Get elements from each b+tree.
* Get elements from multiple b+trees.
*
* @param keyList key list of b+tree
* @param from bkey from
* @param to bkey to
* @param eFlagFilter element flag filter
* @param offset 0-based offset (max = 50)
* @param count number of returning values (0 to all) (max = 200)
* @param offset 0-based offset. must be 0 or positive.
* @param count number of elements to retrieve from each b+tree.
* must be larger than 0 and not more than 50.
* total number of returning elements could be 0 to (count * keyList.size()).
* @return future indicating result of each b+tree
*/
CollectionGetBulkFuture<Map<String, BTreeGetResult<Long, Object>>> asyncBopGetBulk(
List<String> keyList, long from, long to,
ElementFlagFilter eFlagFilter, int offset, int count);

/**
* Get elements from each b+tree.
* Get elements from multiple b+trees.
*
* @param <T> the expected class of the value
* @param keyList key list of b+tree
* @param from bkey from
* @param to bkey to
* @param eFlagFilter element flag filter
* @param offset 0-based offset (max = 50)
* @param count number of returning values (0 to all) (max = 200)
* @param offset 0-based offset. must be 0 or positive.
* @param count number of elements to retrieve from each b+tree.
* must be larger than 0 and not more than 50.
* total number of returning elements could be 0 to (count * keyList.size()).
* @param tc transcoder to decode value
* @return future indicating result of each b+tree
*/
Expand Down

0 comments on commit 1a25795

Please sign in to comment.