Skip to content

Commit

Permalink
CLEANUP: Collection Btree
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesecrust authored and jhpark816 committed Oct 10, 2024
1 parent 25bac40 commit 822d4cc
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 29 deletions.
12 changes: 6 additions & 6 deletions src/main/java/net/spy/memcached/collection/BTreeCount.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@

public class BTreeCount extends CollectionCount {

private static final String command = "bop count";
private static final String COMMAND = "bop count";

protected final String range;

protected final ElementFlagFilter elementFlagFilter;

public BTreeCount(long from, long to, ElementFlagFilter elementFlagFilter) {
this.range = String.valueOf(from) + ".." + String.valueOf(to);
this.range = from + ".." + to;
this.elementFlagFilter = elementFlagFilter;
}

Expand All @@ -37,13 +37,13 @@ public BTreeCount(byte[] from, byte[] to, ElementFlagFilter elementFlagFilter) {
}

public BTreeCount(long from, long to, ElementMultiFlagsFilter elementMultiFlagsFilter) {
this.range = String.valueOf(from) + ".." + String.valueOf(to);
this.elementFlagFilter = (ElementFlagFilter) 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 = (ElementFlagFilter) elementMultiFlagsFilter;
this.elementFlagFilter = elementMultiFlagsFilter;
}

public String stringify() {
Expand All @@ -64,6 +64,6 @@ public String stringify() {
}

public String getCommand() {
return command;
return COMMAND;
}
}
4 changes: 2 additions & 2 deletions src/main/java/net/spy/memcached/collection/BTreeCreate.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

public class BTreeCreate extends CollectionCreate {

private static final String command = "bop create";
private static final String COMMAND = "bop create";

public BTreeCreate(int flags, Integer expTime, Long maxCount,
CollectionOverflowAction overflowAction, Boolean readable, boolean noreply) {
super(CollectionType.btree, flags, expTime, maxCount, overflowAction, readable, noreply);
}

public String getCommand() {
return command;
return COMMAND;
}
}
16 changes: 8 additions & 8 deletions src/main/java/net/spy/memcached/collection/BTreeDelete.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

public class BTreeDelete extends CollectionDelete {

private static final String command = "bop delete";
private static final String COMMAND = "bop delete";
protected int count = -1;

protected ElementFlagFilter elementFlagFilter;
Expand All @@ -38,12 +38,12 @@ public BTreeDelete(long bkey, boolean noreply, boolean dropIfEmpty,
}

public BTreeDelete(long from, long to, boolean noreply) {
this.range = String.valueOf(from) + ".." + String.valueOf(to);
this.range = from + ".." + to;
this.noreply = noreply;
}

public BTreeDelete(long from, long to, int count, boolean noreply) {
this.range = String.valueOf(from) + ".." + String.valueOf(to);
this.range = from + ".." + to;
this.count = count;
this.noreply = noreply;
}
Expand Down Expand Up @@ -77,22 +77,22 @@ public BTreeDelete(long bkey, boolean noreply, boolean dropIfEmpty,
ElementMultiFlagsFilter elementMultiFlagsFilter) {
this(bkey, noreply);
this.dropIfEmpty = dropIfEmpty;
this.elementFlagFilter = (ElementFlagFilter) elementMultiFlagsFilter;
this.elementFlagFilter = elementMultiFlagsFilter;
}

public BTreeDelete(long from, long to, int count, boolean noreply, boolean dropIfEmpty,
ElementMultiFlagsFilter elementMultiFlagsFilter) {
this(from, to, count, noreply);
this.dropIfEmpty = dropIfEmpty;
this.elementFlagFilter = (ElementFlagFilter) elementMultiFlagsFilter;
this.elementFlagFilter = elementMultiFlagsFilter;
}

public BTreeDelete(byte[] bkey, boolean noreply, boolean dropIfEmpty,
ElementMultiFlagsFilter elementMultiFlagsFilter) {
this.range = BTreeUtil.toHex(bkey);
this.noreply = noreply;
this.dropIfEmpty = dropIfEmpty;
this.elementFlagFilter = (ElementFlagFilter) elementMultiFlagsFilter;
this.elementFlagFilter = elementMultiFlagsFilter;
}

public BTreeDelete(byte[] from, byte[] to, int count, boolean noreply, boolean dropIfEmpty,
Expand All @@ -101,7 +101,7 @@ public BTreeDelete(byte[] from, byte[] to, int count, boolean noreply, boolean d
this.count = count;
this.noreply = noreply;
this.dropIfEmpty = dropIfEmpty;
this.elementFlagFilter = (ElementFlagFilter) elementMultiFlagsFilter;
this.elementFlagFilter = elementMultiFlagsFilter;
}

@Override
Expand Down Expand Up @@ -138,7 +138,7 @@ public String stringify() {
}

public String getCommand() {
return command;
return COMMAND;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
public class BTreeFindPosition {

private static final String command = "bop position";
private static final String COMMAND = "bop position";

private final String bkey;
private final BTreeOrder order;
Expand Down Expand Up @@ -60,7 +60,7 @@ public String stringify() {
}

public String getCommand() {
return command;
return COMMAND;
}

public BTreeOrder getOrder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* - SERVER_ERROR
*/
public class BTreeFindPositionWithGet extends CollectionGet {
private static final String command = "bop pwg";
private static final String COMMAND = "bop pwg";

private final BKeyObject bkeyObject;
private final BTreeOrder order;
Expand Down Expand Up @@ -81,7 +81,7 @@ public String stringify() {
}

public String getCommand() {
return command;
return COMMAND;
}

public BKeyObject getBkeyObject() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/spy/memcached/collection/BTreeGet.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

public class BTreeGet extends CollectionGet {

private static final String command = "bop get";
private static final String COMMAND = "bop get";
protected int offset = -1;
protected int count = -1;
protected ElementFlagFilter elementFlagFilter;
Expand Down Expand Up @@ -117,7 +117,7 @@ public String stringify() {
}

public String getCommand() {
return command;
return COMMAND;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

public interface BTreeGetBulk<T> {

int headerCount = 3;
int HEADER_COUNT = 3;

void setKeySeparator(String keySeparator);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public String getCommand() {
}

public boolean headerReady(int spaceCount) {
return spaceCount == BTreeGetBulk.headerCount;
return spaceCount == BTreeGetBulk.HEADER_COUNT;
}

public int getDataLength() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ public class BTreeGetByPosition extends CollectionGet {

public static final int HEADER_EFLAG_POSITION = 1; // 0-based

private static final String command = "bop gbp";
private static final String COMMAND = "bop gbp";

private final BTreeOrder order;
private final String range;
private final int posFrom;
private final int posTo;
private BKeyObject bkey;
Expand All @@ -54,7 +53,7 @@ public BTreeGetByPosition(BTreeOrder order, int pos) {

public BTreeGetByPosition(BTreeOrder order, int posFrom, int posTo) {
this.order = order;
this.range = String.valueOf(posFrom) + ".." + String.valueOf(posTo);
this.range = posFrom + ".." + posTo;
this.posFrom = posFrom;
this.posTo = posTo;
this.eHeadCount = 2;
Expand Down Expand Up @@ -83,7 +82,7 @@ public String stringify() {
}

public String getCommand() {
return command;
return COMMAND;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public final void handleRead(ByteBuffer bb) {
String itemHeader = byteBuffer.toString();

String[] chunk = itemHeader.split(" ");
if (chunk.length == BTreeGetBulk.headerCount
if (chunk.length == BTreeGetBulk.HEADER_COUNT
&& chunk[2].startsWith("0x")) {
spaceCount--;
byteBuffer.write(b);
Expand Down

0 comments on commit 822d4cc

Please sign in to comment.