Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions src/main/java/net/spy/memcached/ArcusClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ public void complete() {
latch.countDown();
}

public void gotData(String subkey, int flags, byte[] data, byte[] eflag) {
public void gotData(String elementKey, int flags, byte[] data, byte[] eflag) {
cachedDataList.add(new CachedData(flags, data, tc.getMaxSize()));
}
});
Expand Down Expand Up @@ -711,7 +711,7 @@ public void complete() {
latch.countDown();
}

public void gotData(String subkey, int flags, byte[] data, byte[] eflag) {
public void gotData(String elementKey, int flags, byte[] data, byte[] eflag) {
cachedDataSet.add(new CachedData(flags, data, tc.getMaxSize()));
}
});
Expand Down Expand Up @@ -814,49 +814,49 @@ public void gotData(String mkey, int flags, byte[] data, byte[] eflag) {
* Public methods for collection items call this method.
*
* @param key collection item's key
* @param subkey element key (list index, b+tree bkey)
* @param elementKey element key (list index, b+tree bkey)
* @param collectionInsert operation parameters (value, eflags, attributes, and so on)
* @param tc transcoder to serialize and unserialize value
* @return future holding the success/failure of the operation
*/
private <T> CollectionFuture<Boolean> asyncCollectionInsert(String key,
String subkey,
String elementKey,
CollectionInsert<T> collectionInsert,
Transcoder<T> tc) {
CachedData co = tc.encode(collectionInsert.getValue());
collectionInsert.setFlags(co.getFlags());
return asyncCollectionInsert(key, subkey, collectionInsert, co);
return asyncCollectionInsert(key, elementKey, collectionInsert, co);
}

/**
* Generic insert operation for collection items.
* Public methods for collection items call this method.
*
* @param key collection item's key
* @param subkey element key (list index, b+tree bkey)
* @param elementKey element key (list index, b+tree bkey)
* @param collectionInsert operation parameters (value, eflags, attributes, and so on)
* @param co transcoded value
* @return future holding the success/failure of the operation
*/
<T> CollectionFuture<Boolean> asyncCollectionInsert(final String key,
final String subkey,
final String elementKey,
final CollectionInsert<T> collectionInsert,
final CachedData co) {
final CountDownLatch latch = new CountDownLatch(1);
final CollectionFuture<Boolean> rv = new CollectionFuture<>(
latch, operationTimeout);
Operation op = opFact.collectionInsert(key, subkey, collectionInsert,
Operation op = opFact.collectionInsert(key, elementKey, collectionInsert,
co.getData(), new OperationCallback() {
public void receivedStatus(OperationStatus status) {
CollectionOperationStatus cstatus = toCollectionOperationStatus(status);
rv.set(cstatus.isSuccess(), cstatus);
if (!cstatus.isSuccess()) {
getLogger().debug(
"Insertion to the collection failed : %s (type=%s, key=%s, subkey=%s, value=%s)",
"Insertion to the collection failed : %s (type=%s, key=%s, elementKey=%s, value=%s)",
cstatus.getMessage(),
collectionInsert.getClass().getName(),
key,
subkey,
elementKey,
collectionInsert.getValue());
}
}
Expand Down Expand Up @@ -910,27 +910,27 @@ public void complete() {
* Public methods for collection items call this method.
*
* @param key collection item's key
* @param subkey element key (list index, b+tree bkey)
* @param elementKey element key (list index, b+tree bkey)
* @param collectionExist operation parameters (element value and so on)
* @return future holding the success/failure of the operation
*/
private <T> CollectionFuture<Boolean> asyncCollectionExist(final String key, final String subkey,
private <T> CollectionFuture<Boolean> asyncCollectionExist(final String key, final String elementKey,
final CollectionExist collectionExist) {
final CountDownLatch latch = new CountDownLatch(1);
final CollectionFuture<Boolean> rv = new CollectionFuture<>(
latch, operationTimeout);
Operation op = opFact.collectionExist(key, subkey, collectionExist,
Operation op = opFact.collectionExist(key, elementKey, collectionExist,
new OperationCallback() {
public void receivedStatus(OperationStatus status) {
CollectionOperationStatus cstatus = toCollectionOperationStatus(status);
boolean isExist = CollectionResponse.EXIST == cstatus.getResponse();
rv.set(isExist, cstatus);
if (!cstatus.isSuccess()) {
getLogger().debug("Exist command to the collection failed : %s (type=%s, key=%s, subkey=%s)",
getLogger().debug("Exist command to the collection failed : %s (type=%s, key=%s, elementKey=%s)",
cstatus.getMessage(),
collectionExist.getClass().getName(),
key,
subkey);
elementKey);
}
}

Expand Down Expand Up @@ -1986,13 +1986,13 @@ public <T> CollectionFuture<Boolean> asyncMopUpdate(String key, String mkey,
* Public methods for collection items call this method.
*
* @param key collection item's key
* @param subkey element key (list index, b+tree bkey)
* @param elementKey element key (list index, b+tree bkey)
* @param collectionUpdate operation parameters (element value and so on)
* @param tc transcoder to serialize and unserialize value
* @return future holding the success/failure of the operation
*/
private <T> CollectionFuture<Boolean> asyncCollectionUpdate(
final String key, final String subkey,
final String key, final String elementKey,
final CollectionUpdate<T> collectionUpdate, Transcoder<T> tc) {

CachedData co = null;
Expand All @@ -2005,18 +2005,18 @@ private <T> CollectionFuture<Boolean> asyncCollectionUpdate(
final CollectionFuture<Boolean> rv = new CollectionFuture<>(
latch, operationTimeout);

Operation op = opFact.collectionUpdate(key, subkey, collectionUpdate,
Operation op = opFact.collectionUpdate(key, elementKey, collectionUpdate,
((co == null) ? null : co.getData()), new OperationCallback() {
public void receivedStatus(OperationStatus status) {
CollectionOperationStatus cstatus = toCollectionOperationStatus(status);
rv.set(cstatus.isSuccess(), cstatus);
if (!cstatus.isSuccess()) {
getLogger().debug(
"Insertion to the collection failed : %s (type=%s, key=%s, subkey=%s, value=%s)",
"Insertion to the collection failed : %s (type=%s, key=%s, elementKey=%s, value=%s)",
cstatus.getMessage(),
collectionUpdate.getClass().getName(),
key,
subkey,
elementKey,
collectionUpdate.getNewValue());
}
}
Expand Down Expand Up @@ -3233,18 +3233,18 @@ public CollectionFuture<Long> asyncBopDecr(String key, byte[] bkey,
* Generic increment/decrement operation for b+tree items. Public methods call this method.
*
* @param k b+tree item's key
* @param subkey element key
* @param elementKey element key
* @param collectionMutate operation parameters (increment amount and so on)
* @return future holding the incremented or decremented value
*/
private CollectionFuture<Long> asyncCollectionMutate(final String k, final String subkey,
private CollectionFuture<Long> asyncCollectionMutate(final String k, final String elementKey,
final CollectionMutate collectionMutate) {

final CountDownLatch latch = new CountDownLatch(1);

final CollectionFuture<Long> rv = new CollectionFuture<>(latch, operationTimeout);

Operation op = opFact.collectionMutate(k, subkey, collectionMutate,
Operation op = opFact.collectionMutate(k, elementKey, collectionMutate,
new OperationCallback() {

@Override
Expand All @@ -3256,14 +3256,14 @@ public void receivedStatus(OperationStatus status) {
} catch (NumberFormatException e) {
rv.set(null, new CollectionOperationStatus(false, status.getMessage(), CollectionResponse.EXCEPTION));

getLogger().debug("Key(%s), Bkey(%s) Unknown response : %s", k, subkey, status);
getLogger().debug("Key(%s), Bkey(%s) Unknown response : %s", k, elementKey, status);
}
return;
}

rv.set(null, new CollectionOperationStatus(status));

getLogger().debug("Key(%s), Bkey(%s) Unknown response : %s", k, subkey, status);
getLogger().debug("Key(%s), Bkey(%s) Unknown response : %s", k, elementKey, status);
}

@Override
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/net/spy/memcached/OperationFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,13 @@ CASOperation cas(StoreType t, String key, long casId, int flags,
* Insert operation for collection items.
*
* @param key collection item's key
* @param subkey element key (list index, b+tree bkey)
* @param elementKey element key (list index, b+tree bkey)
* @param collectionInsert operation parameters (value, eflags, attributes, and so on)
* @param data the serialized value
* @param cb the status callback
* @return a new CollectionInsertOperation
*/
CollectionInsertOperation collectionInsert(String key, String subkey,
CollectionInsertOperation collectionInsert(String key, String elementKey,
CollectionInsert<?> collectionInsert, byte[] data,
OperationCallback cb);

Expand Down Expand Up @@ -339,12 +339,12 @@ CollectionDeleteOperation collectionDelete(String key,
* Existence operation for collection items.
*
* @param key collection item's key
* @param subkey element key (list index, b+tree bkey)
* @param elementKey element key (list index, b+tree bkey)
* @param collectionExist operation parameters (element value and so on)
* @param cb the callback that will contain the results
* @return a new CollectionExistOperation
*/
CollectionExistOperation collectionExist(String key, String subkey,
CollectionExistOperation collectionExist(String key, String elementKey,
CollectionExist collectionExist, OperationCallback cb);

/**
Expand Down Expand Up @@ -421,13 +421,13 @@ CollectionCountOperation collectionCount(String key,
* Update operation for collection items.
*
* @param key collection item's key
* @param subkey element key (list index, b+tree bkey)
* @param elementKey element key (list index, b+tree bkey)
* @param collectionUpdate (element value and so on)
* @param data the serialized value
* @param cb the status callback
* @return a new CollectionUpdateOperation
*/
CollectionUpdateOperation collectionUpdate(String key, String subkey,
CollectionUpdateOperation collectionUpdate(String key, String elementKey,
CollectionUpdate<?> collectionUpdate, byte[] data,
OperationCallback cb);

Expand All @@ -447,12 +447,12 @@ CollectionPipedUpdateOperation collectionPipedUpdate(String key,
* Increment/Decrement operation for collection items (b+tree items).
*
* @param key b+tree item's key
* @param subkey element key
* @param elementKey element key (b+tree bkey)
* @param collectionMutate operation parameters (increment/decrement amount and so on)
* @param cb the callback that will contain the incremented/decremented result
* @return a new CollectionMutateOperation
*/
CollectionMutateOperation collectionMutate(String key, String subkey,
CollectionMutateOperation collectionMutate(String key, String elementKey,
CollectionMutate collectionMutate,
OperationCallback cb);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ public byte[] getAdditionalArgs() {
*/
@Override
public void decodeElemHeader(List<String> tokens) {
subkey = tokens.get(0);
if (subkey.startsWith("0x")) {
bkey = new BKeyObject(BTreeUtil.hexStringToByteArrays(subkey.substring(2)));
elementKey = tokens.get(0);
if (elementKey.startsWith("0x")) {
bkey = new BKeyObject(BTreeUtil.hexStringToByteArrays(elementKey.substring(2)));
} else {
bkey = new BKeyObject(Long.parseLong(subkey));
bkey = new BKeyObject(Long.parseLong(elementKey));
}
if (tokens.size() == 2) {
dataLength = Integer.parseInt(tokens.get(1));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/spy/memcached/collection/BTreeGet.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public byte[] getAdditionalArgs() {

@Override
public void decodeElemHeader(List<String> tokens) {
subkey = tokens.get(0);
elementKey = tokens.get(0);
if (tokens.size() == 2) {
dataLength = Integer.parseInt(tokens.get(1));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ public byte[] getAdditionalArgs() {
*/
@Override
public void decodeElemHeader(List<String> tokens) {
subkey = tokens.get(0);
if (subkey.startsWith("0x")) {
bkey = new BKeyObject(BTreeUtil.hexStringToByteArrays(subkey.substring(2)));
elementKey = tokens.get(0);
if (elementKey.startsWith("0x")) {
bkey = new BKeyObject(BTreeUtil.hexStringToByteArrays(elementKey.substring(2)));
} else {
bkey = new BKeyObject(Long.parseLong(subkey));
bkey = new BKeyObject(Long.parseLong(elementKey));
}
if (tokens.size() == 2) {
dataLength = Integer.parseInt(tokens.get(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ private BTreeInsertAndGet(BKeyObject bKey, byte[] eFlag, T value, boolean update

@Override
public void decodeElemHeader(List<String> tokens) {
subkey = tokens.get(0);
if (subkey.startsWith("0x")) {
bKey = new BKeyObject(BTreeUtil.hexStringToByteArrays(subkey.substring(2)));
elementKey = tokens.get(0);
if (elementKey.startsWith("0x")) {
bKey = new BKeyObject(BTreeUtil.hexStringToByteArrays(elementKey.substring(2)));
} else {
bKey = new BKeyObject(Long.parseLong(subkey));
bKey = new BKeyObject(Long.parseLong(elementKey));
}
if (tokens.size() == 2) {
dataLength = Integer.parseInt(tokens.get(1));
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/net/spy/memcached/collection/CollectionGet.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public abstract class CollectionGet {

protected String range;
protected String str;
protected String subkey;
protected String elementKey;
protected int dataLength;

protected byte[] elementFlag;
Expand All @@ -40,8 +40,8 @@ public boolean isDropIfEmpty() {
return dropIfEmpty;
}

public String getSubkey() {
return subkey;
public String getElementKey() {
return elementKey;
}

public int getDataLength() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/spy/memcached/collection/MapGet.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public String getCommand() {

@Override
public void decodeElemHeader(List<String> tokens) {
this.subkey = tokens.get(0);
this.elementKey = tokens.get(0);
this.dataLength = Integer.parseInt(tokens.get(1));
}
}
4 changes: 2 additions & 2 deletions src/main/java/net/spy/memcached/ops/BaseOperationFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public Collection<Operation> clone(KeyedOperation op) {
(GetAttrOperation.Callback) c.getCallback()));
} else if (op instanceof CollectionInsertOperation) {
CollectionInsertOperation c = (CollectionInsertOperation) op;
rv.add(collectionInsert(first(c.getKeys()), c.getSubKey(),
rv.add(collectionInsert(first(c.getKeys()), c.getElementKey(),
c.getInsert(), c.getData(), c.getCallback()));
} else if (op instanceof CollectionGetOperation) {
CollectionGetOperation c = (CollectionGetOperation) op;
Expand All @@ -105,7 +105,7 @@ public Collection<Operation> clone(KeyedOperation op) {
c.getCallback()));
} else if (op instanceof CollectionExistOperation) {
CollectionExistOperation c = (CollectionExistOperation) op;
rv.add(collectionExist(first(c.getKeys()), c.getSubKey(),
rv.add(collectionExist(first(c.getKeys()), c.getElementKey(),
c.getExist(), c.getCallback()));
} else {
assert false : "Unhandled operation type: " + op.getClass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
public interface CollectionExistOperation extends KeyedOperation {

String getSubKey();
String getElementKey();

CollectionExist getExist();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public interface CollectionGetOperation extends KeyedOperation {
CollectionGet getGet();

interface Callback extends OperationCallback {
void gotData(String subkey, int flags, byte[] data, byte[] eflag);
void gotData(String elementKey, int flags, byte[] data, byte[] eflag);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
public interface CollectionInsertOperation extends KeyedOperation {

String getSubKey();
String getElementKey();

CollectionInsert<?> getInsert();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
public interface CollectionUpdateOperation extends KeyedOperation {

String getSubKey();
String getElementKey();

CollectionUpdate<?> getUpdate();

Expand Down
Loading
Loading