Skip to content

Commit

Permalink
CLEANUP: Remove redundant and inconsistent line in OperationImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
WonSteps authored and jhpark816 committed Apr 24, 2024
1 parent c865c7c commit 83fa941
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ public BTreeFindPosition getGet() {
public void handleLine(String line) {
getLogger().debug("Got line %s", line);

Integer position = null;

/* ENABLE_MIGRATION if */
if (hasNotMyKey(line)) {
addRedirectSingleKeyOperation(line, key);
Expand All @@ -88,17 +86,12 @@ public void handleLine(String line) {
assert stuff.length == 2;
assert "POSITION".equals(stuff[0]);

// FIXME exception-based conversion.
try {
// POSITION=<position>\r\n
position = Integer.parseInt(stuff[1]);
BTreeFindPositionOperation.Callback cb =
(BTreeFindPositionOperation.Callback) getCallback();
cb.gotData(position);
getCallback().receivedStatus(POSITION);
} catch (Exception e) {
// expected : <error_string>
}
// POSITION=<position>\r\n
int position = Integer.parseInt(stuff[1]);
BTreeFindPositionOperation.Callback cb =
(BTreeFindPositionOperation.Callback) getCallback();
cb.gotData(position);
getCallback().receivedStatus(POSITION);
} else {
OperationStatus status = matchStatus(line, NOT_FOUND, UNREADABLE,
BKEY_MISMATCH, TYPE_MISMATCH, NOT_FOUND_ELEMENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ public void handleLine(String line) {
getLogger().debug(status);
getCallback().receivedStatus(status);
transitionState(OperationState.COMPLETE);
return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public void handleLine(String line) {
setReadType(OperationReadType.DATA);
}
} else {
OperationStatus status = null;
OperationStatus status;
if (get.isUpdateIfExist()) {
status = matchStatus(line, UPSERT_AND_GET_STATUS_ON_LINE);
} else {
Expand All @@ -160,7 +160,6 @@ public void handleLine(String line) {
getLogger().debug(status);
getCallback().receivedStatus(status);
transitionState(OperationState.COMPLETE);
return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ public void handleLine(String line) {
getLogger().debug(status);
getCallback().receivedStatus(status);
transitionState(OperationState.COMPLETE);
return;
}
}

Expand Down Expand Up @@ -283,7 +282,7 @@ private void readValue(ByteBuffer bb) {
}
}

private final void readMissedKeys(ByteBuffer bb) {
private void readMissedKeys(ByteBuffer bb) {
int count = 0;
if (lookingFor == '\0' && data == null) {
while (bb.remaining() > 0) {
Expand Down Expand Up @@ -358,11 +357,10 @@ private final void readMissedKeys(ByteBuffer bb) {
byteBuffer.write(b);
}
}
return;
}
}

private final void readTrimmedKeys(ByteBuffer bb) {
private void readTrimmedKeys(ByteBuffer bb) {
int count = 0;
if (lookingFor == '\0' && data == null) {
while (bb.remaining() > 0) {
Expand Down Expand Up @@ -418,7 +416,6 @@ private final void readTrimmedKeys(ByteBuffer bb) {
byteBuffer.write(b);
}
}
return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public final Collection<String> getKeys() {

@Override
public final void handleLine(String line) {
/*
VALUE <key> <flags> <bytes> [<cas unique>]\r\n
<data block>\r\n
...
END\r\n
*/
if (line.equals("END")) {
getLogger().debug("Get complete!");
/* ENABLE_MIGRATION if */
Expand Down Expand Up @@ -188,9 +194,9 @@ public final void initialize() {
int numKeys = keys.size();
commandBuilder.append(cmd);
commandBuilder.append(' ');
commandBuilder.append(String.valueOf(lenKeys));
commandBuilder.append(lenKeys);
commandBuilder.append(' ');
commandBuilder.append(String.valueOf(numKeys));
commandBuilder.append(numKeys);
commandBuilder.append(RN_STRING);
commandBuilder.append(keysString);
commandBuilder.append(RN_STRING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public void handleLine(String line) {
getLogger().debug(status);
getCallback().receivedStatus(status);
transitionState(OperationState.COMPLETE);
return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ public void handleLine(String line) {
getLogger().debug(status);
getCallback().receivedStatus(status);
transitionState(OperationState.COMPLETE);
return;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ public CollectionMutateOperationImpl(String key, String subkey,

public void handleLine(String line) {

OperationStatus status = null;

/* ENABLE_REPLICATION if */
if (hasSwitchedOver(line)) {
receivedMoveOperations(line);
Expand All @@ -100,8 +98,9 @@ public void handleLine(String line) {
Long.valueOf(line);
getCallback().receivedStatus(new OperationStatus(true, line));
} catch (NumberFormatException e) {
status = matchStatus(line, NOT_FOUND, NOT_FOUND_ELEMENT, TYPE_MISMATCH, BKEY_MISMATCH,
UNREADABLE, OVERFLOWED, OUT_OF_RANGE);
OperationStatus status = matchStatus(line, NOT_FOUND, NOT_FOUND_ELEMENT,
UNREADABLE, OVERFLOWED, OUT_OF_RANGE,
TYPE_MISMATCH, BKEY_MISMATCH);

getLogger().debug(status);
getCallback().receivedStatus(status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ public void handleLine(String line) {
return;
}
/* ENABLE_MIGRATION end */

/*
ATTR <name>=<value>\r\n
ATTR <name>=<value>\r\n
...
END\r\n
*/
if (line.startsWith("ATTR ")) {
getLogger().debug("Got line %s", line);

Expand Down

0 comments on commit 83fa941

Please sign in to comment.