Skip to content

Commit

Permalink
CLEANUP: remove useless constructor and change parameter order in btr…
Browse files Browse the repository at this point in the history
…ee command class
  • Loading branch information
oliviarla authored and jhpark816 committed Jan 7, 2025
1 parent 4d950a3 commit 98b2ab7
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 58 deletions.
16 changes: 8 additions & 8 deletions src/main/java/net/spy/memcached/ArcusClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ public CollectionFuture<Map<Long, Element<Object>>> asyncBopGet(String key,
boolean withDelete,
boolean dropIfEmpty) {
BTreeUtil.validateBkey(bkey);
BTreeGet get = new BTreeGet(bkey, withDelete, dropIfEmpty, eFlagFilter);
BTreeGet get = new BTreeGet(bkey, eFlagFilter, withDelete, dropIfEmpty);
return asyncBopGet(key, get, collectionTranscoder);
}

Expand All @@ -1287,7 +1287,7 @@ public CollectionFuture<Map<Long, Element<Object>>> asyncBopGet(String key,
boolean withDelete,
boolean dropIfEmpty) {
BTreeUtil.validateBkey(from, to);
BTreeGet get = new BTreeGet(from, to, offset, count, withDelete, dropIfEmpty, eFlagFilter);
BTreeGet get = new BTreeGet(from, to, eFlagFilter, offset, count, withDelete, dropIfEmpty);
return asyncBopGet(key, get, collectionTranscoder);
}

Expand All @@ -1307,7 +1307,7 @@ public <T> CollectionFuture<Map<Long, Element<T>>> asyncBopGet(String key,
boolean dropIfEmpty,
Transcoder<T> tc) {
BTreeUtil.validateBkey(bkey);
BTreeGet get = new BTreeGet(bkey, withDelete, dropIfEmpty, eFlagFilter);
BTreeGet get = new BTreeGet(bkey, eFlagFilter, withDelete, dropIfEmpty);
return asyncBopGet(key, get, tc);
}

Expand All @@ -1329,7 +1329,7 @@ public <T> CollectionFuture<Map<Long, Element<T>>> asyncBopGet(String key,
boolean dropIfEmpty,
Transcoder<T> tc) {
BTreeUtil.validateBkey(from, to);
BTreeGet get = new BTreeGet(from, to, offset, count, withDelete, dropIfEmpty, eFlagFilter);
BTreeGet get = new BTreeGet(from, to, eFlagFilter, offset, count, withDelete, dropIfEmpty);
return asyncBopGet(key, get, tc);
}

Expand Down Expand Up @@ -2387,7 +2387,7 @@ public CollectionFuture<Map<ByteArrayBKey, Element<Object>>> asyncBopGet(
String key, byte[] bkey, ElementFlagFilter eFlagFilter,
boolean withDelete, boolean dropIfEmpty) {
BTreeUtil.validateBkey(bkey);
BTreeGet get = new BTreeGet(bkey, withDelete, dropIfEmpty, eFlagFilter);
BTreeGet get = new BTreeGet(bkey, eFlagFilter, withDelete, dropIfEmpty);
return asyncBopExtendedGet(key, get, collectionTranscoder);
}

Expand All @@ -2402,7 +2402,7 @@ public <T> CollectionFuture<Map<ByteArrayBKey, Element<T>>> asyncBopGet(
String key, byte[] bkey, ElementFlagFilter eFlagFilter,
boolean withDelete, boolean dropIfEmpty, Transcoder<T> tc) {
BTreeUtil.validateBkey(bkey);
BTreeGet get = new BTreeGet(bkey, withDelete, dropIfEmpty, eFlagFilter);
BTreeGet get = new BTreeGet(bkey, eFlagFilter, withDelete, dropIfEmpty);
return asyncBopExtendedGet(key, get, tc);
}

Expand All @@ -2418,7 +2418,7 @@ public CollectionFuture<Map<ByteArrayBKey, Element<Object>>> asyncBopGet(
String key, byte[] from, byte[] to, ElementFlagFilter eFlagFilter,
int offset, int count, boolean withDelete, boolean dropIfEmpty) {
BTreeUtil.validateBkey(from, to);
BTreeGet get = new BTreeGet(from, to, offset, count, withDelete, dropIfEmpty, eFlagFilter);
BTreeGet get = new BTreeGet(from, to, eFlagFilter, offset, count, withDelete, dropIfEmpty);
return asyncBopExtendedGet(key, get, collectionTranscoder);
}

Expand All @@ -2436,7 +2436,7 @@ public <T> CollectionFuture<Map<ByteArrayBKey, Element<T>>> asyncBopGet(
int count, boolean withDelete, boolean dropIfEmpty,
Transcoder<T> tc) {
BTreeUtil.validateBkey(from, to);
BTreeGet get = new BTreeGet(from, to, offset, count, withDelete, dropIfEmpty, eFlagFilter);
BTreeGet get = new BTreeGet(from, to, eFlagFilter, offset, count, withDelete, dropIfEmpty);
return asyncBopExtendedGet(key, get, tc);
}

Expand Down
10 changes: 0 additions & 10 deletions src/main/java/net/spy/memcached/collection/BTreeCount.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,6 @@ public BTreeCount(byte[] from, byte[] to, ElementFlagFilter elementFlagFilter) {
this.elementFlagFilter = elementFlagFilter;
}

public BTreeCount(long from, long to, ElementMultiFlagsFilter elementMultiFlagsFilter) {
this.range = from + ".." + to;
this.elementFlagFilter = elementMultiFlagsFilter;
}

public BTreeCount(byte[] from, byte[] to, ElementMultiFlagsFilter elementMultiFlagsFilter) {
this.range = BTreeUtil.toHex(from) + ".." + BTreeUtil.toHex(to);
this.elementFlagFilter = elementMultiFlagsFilter;
}

public String stringify() {
if (str != null) {
return str;
Expand Down
44 changes: 20 additions & 24 deletions src/main/java/net/spy/memcached/collection/BTreeGet.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ public class BTreeGet extends CollectionGet {
protected ElementFlagFilter elementFlagFilter;
private boolean reverse = false;

private BTreeGet(String range,
boolean delete, boolean dropIfEmpty,
ElementFlagFilter elementFlagFilter) {
private BTreeGet(String range, ElementFlagFilter elementFlagFilter,
boolean delete, boolean dropIfEmpty) {
this.range = range;
this.delete = delete;
this.dropIfEmpty = dropIfEmpty;
Expand All @@ -39,40 +38,37 @@ private BTreeGet(String range,
this.eFlagIndex = 1;
}

public BTreeGet(long bkey,
boolean delete, boolean dropIfEmpty,
ElementFlagFilter elementFlagFilter) {
this(String.valueOf(bkey), delete, dropIfEmpty, elementFlagFilter);
public BTreeGet(long bkey, ElementFlagFilter elementFlagFilter,
boolean delete, boolean dropIfEmpty) {
this(String.valueOf(bkey), elementFlagFilter, delete, dropIfEmpty);
}

public BTreeGet(byte[] bkey,
boolean delete, boolean dropIfEmpty,
ElementFlagFilter elementFlagFilter) {
this(BTreeUtil.toHex(bkey), delete, dropIfEmpty, elementFlagFilter);
public BTreeGet(byte[] bkey, ElementFlagFilter elementFlagFilter,
boolean delete, boolean dropIfEmpty) {
this(BTreeUtil.toHex(bkey), elementFlagFilter, delete, dropIfEmpty);
}

private BTreeGet(String range, boolean reverse, int offset,
int count, boolean delete, boolean dropIfEmpty,
ElementFlagFilter elementFlagFilter) {
this(range, delete, dropIfEmpty, elementFlagFilter);
private BTreeGet(String range, boolean reverse, ElementFlagFilter elementFlagFilter,
int offset, int count, boolean delete, boolean dropIfEmpty) {
this(range, elementFlagFilter, delete, dropIfEmpty);
this.offset = offset;
this.count = count;
this.reverse = reverse;
}

public BTreeGet(long from, long to, int offset, int count,
boolean delete, boolean dropIfEmpty,
ElementFlagFilter elementFlagFilter) {
this(from + ".." + to, from > to,
offset, count, delete, dropIfEmpty, elementFlagFilter);
public BTreeGet(long from, long to, ElementFlagFilter elementFlagFilter,
int offset, int count,
boolean delete, boolean dropIfEmpty) {
this(from + ".." + to, from > to, elementFlagFilter,
offset, count, delete, dropIfEmpty);
}

public BTreeGet(byte[] from, byte[] to, int offset, int count,
boolean delete, boolean dropIfEmpty,
ElementFlagFilter elementFlagFilter) {
public BTreeGet(byte[] from, byte[] to, ElementFlagFilter elementFlagFilter,
int offset, int count,
boolean delete, boolean dropIfEmpty) {
this(BTreeUtil.toHex(from) + ".." + BTreeUtil.toHex(to),
BTreeUtil.compareByteArraysInLexOrder(from, to) > 0,
offset, count, delete, dropIfEmpty, elementFlagFilter);
elementFlagFilter, offset, count, delete, dropIfEmpty);
}

public boolean isReversed() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/manual/net/spy/memcached/MultibyteKeyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ void ExtendedBTreeGetOperationImplTest() {
byte[] to = new byte[]{10, 10};
try {
opFact.collectionGet(MULTIBYTE_KEY,
new BTreeGet(from, to, 0, 0, false, false, ElementFlagFilter.DO_NOT_FILTER),
new BTreeGet(from, to, ElementFlagFilter.DO_NOT_FILTER, 0, 0, false, false),
new CollectionGetOperation.Callback() {
@Override
public void gotData(String bkey, int flags, byte[] data, byte[] eflag) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,25 @@ class ProtocolBTreeGetTest {

@Test
void testStringify() {
assertEquals("10 drop", (new BTreeGet(bkey, true, true,
ElementFlagFilter.DO_NOT_FILTER)).stringify());
assertEquals("10 delete", (new BTreeGet(bkey, true,
false, ElementFlagFilter.DO_NOT_FILTER)).stringify());
assertEquals("10", (new BTreeGet(bkey, false, true,
ElementFlagFilter.DO_NOT_FILTER)).stringify());
assertEquals("10", (new BTreeGet(bkey, false, false,
ElementFlagFilter.DO_NOT_FILTER)).stringify());
assertEquals("10 drop", (new BTreeGet(bkey, ElementFlagFilter.DO_NOT_FILTER,
true, true)).stringify());
assertEquals("10 delete", (new BTreeGet(bkey, ElementFlagFilter.DO_NOT_FILTER,
true, false)).stringify());
assertEquals("10", (new BTreeGet(bkey, ElementFlagFilter.DO_NOT_FILTER,
false, true)).stringify());
assertEquals("10", (new BTreeGet(bkey, ElementFlagFilter.DO_NOT_FILTER,
false, false)).stringify());

assertEquals("10..20 1 1 delete", (new BTreeGet(10, 20,
1, 1, true, false, ElementFlagFilter.DO_NOT_FILTER))
ElementFlagFilter.DO_NOT_FILTER,
1, 1, true, false))
.stringify());
assertEquals("10..20 1 1 drop", (new BTreeGet(10, 20, 1,
1, true, true, ElementFlagFilter.DO_NOT_FILTER)).stringify());
assertEquals("10..20 1 1", (new BTreeGet(10, 20, 1, 1,
false, true, ElementFlagFilter.DO_NOT_FILTER)).stringify());
assertEquals("10..20 1 1", (new BTreeGet(10, 20, 1, 1,
false, false, ElementFlagFilter.DO_NOT_FILTER)).stringify());
assertEquals("10..20 1 1 drop", (new BTreeGet(10, 20,
ElementFlagFilter.DO_NOT_FILTER, 1,
1, true, true)).stringify());
assertEquals("10..20 1 1", (new BTreeGet(10, 20, ElementFlagFilter.DO_NOT_FILTER,
1, 1, false, true)).stringify());
assertEquals("10..20 1 1", (new BTreeGet(10, 20, ElementFlagFilter.DO_NOT_FILTER,
1, 1, false, false)).stringify());
}
}

0 comments on commit 98b2ab7

Please sign in to comment.