aerospike / aerospike-client-java

Aerospike Java Client Library
Other
236 stars 212 forks source link

Issue in Aerospike ListOperation Remove #96

Closed finch986 closed 6 years ago

finch986 commented 6 years ago

I am using aerospike listoperation in code, but I am getting Bin Type error , Error Code 12 while performing the removeByValue operation.

aerospike config details:

client version: 4.1.4 java-helper-version: 1.2 namespace config:

namespace test {

    replication-factor 2

    memory-size 2G

    default-ttl 5d # 5 days, use 0 to never expire/evict.

storage-engine memory

    # To use file storage backing, comment out the line above and use the

    # following lines instead.

    storage-engine device {

            file /opt/aerospike/data/test.dat

            filesize 5G

            data-in-memory true # Store data in memory in addition to file.

    }

}

code sample:

public void samplecode() throws Exception { Key key = new Key("test", "ccp", "oplkey11"); aerospikeClient.delete(null, key);

List<com.aerospike.client.Value> itemList = new ArrayList<com.aerospike.client.Value>();
itemList.add(com.aerospike.client.Value.get(1));
itemList.add(com.aerospike.client.Value.get(33));
itemList.add(com.aerospike.client.Value.get(-1));
itemList.add(com.aerospike.client.Value.get(33));
itemList.add(com.aerospike.client.Value.get(-2));
itemList.add(com.aerospike.client.Value.get(0));
itemList.add(com.aerospike.client.Value.get(22));
itemList.add(com.aerospike.client.Value.get(11));
itemList.add(com.aerospike.client.Value.get(14));
itemList.add(com.aerospike.client.Value.get(6));

List<com.aerospike.client.Value> valueList = new ArrayList<com.aerospike.client.Value>();
valueList.add(com.aerospike.client.Value.get(-45));
valueList.add(com.aerospike.client.Value.get(14));
String binName = "categories";
try {
    Record record = aerospikeClient.operate(null, key,
            ListOperation.appendItems(binName, itemList),
            ListOperation.removeByValue(binName, com.aerospike.client.Value.get(0), ListReturnType.INDEX));
    logger.info("record {}", record);
} catch (Exception  e) {
    logger.info("fdfd {}", e);
}

}

BrianNichols commented 6 years ago

After the record delete(), the record key does not exist. When the record key doesn't exist on operate(), the following is returned:

For server versions < 3.16.0.1. "Bin type error" is returned. For server version >= 3.16.0.1, "Key not found" is returned.

finch986 commented 6 years ago

but we are appending items as well . Also this is sample Code we have copied from Aerospike Examples

BrianNichols commented 6 years ago

I tried your example with java client 4.1.4 and the latest server version with file storage engine. It worked fine.

record (gen:1),(exp:261344151),(bins:(categories:[10, [5]]))

Which server version are you using?

finch986 commented 6 years ago

Server 3.15 . Client latest Java .

On Thu 15 Mar, 2018, 01:07 Brian Nichols, notifications@github.com wrote:

I tried your example with java client 4.1.4 and the latest server version with file storage engine. It worked fine.

record (gen:1),(exp:261344151),(bins:(categories:[10, [5]]))

Which server version are you using?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aerospike/aerospike-client-java/issues/96#issuecomment-373148761, or mute the thread https://github.com/notifications/unsubscribe-auth/ADiPSLvQZYe50LnIcTo1_pWuCOIVz0OAks5teXFrgaJpZM4SoZeb .

BrianNichols commented 6 years ago

Support for ListOperation.removeByValue() was first added in server version 3.16.0.1. I recommend upgrading to server version 3.16.0.6.