Lmap.exists throws error for non-existing key


#1

lmap.exists returns 1 as expected for a key which does exist, but throws an error rather than returning 0 for a non-existing key. aql example:

aql> insert into test.demo (PK, bin) values ('key', 'value')
OK, 1 record affected.

aql> execute lmap.put('mymap', 'id123', 'value') on test.content where pk='key'
+-----+
| put |
+-----+
| 0   |
+-----+
1 row in set (0.000 secs)

aql> execute lmap.get('mymap', 'id123') on test.content where pk='key'
+-------------------+
| get               |
+-------------------+
| {"id123":"value"} |
+-------------------+
1 row in set (0.000 secs)

aql> execute lmap.exists('mymap', 'id123') on test.content where pk='key'
+--------+
| exists |
+--------+
| 1      |
+--------+
1 row in set (0.000 secs)

aql> execute lmap.exists('mymap', 'id124') on test.content where pk='key'
Error: (125) AEROSPIKE_ERR_LARGE_ITEM_NOT_FOUND

I am developing on OS X with your vagrant Aerospike Community Edition build 3.4.1 image.


#2

Yes, the correct contract is to return an error, when the item is not found.


#3

Hi,

The reason I (and other developers) need an ‘exists’ function is so we can test if an item exists WITHOUT throwing an error, as to fail that test is not semantically an error.

This is common practice on other systems, and I would expect the same from Aerospike.

e.g. Redis: http://redis.io/commands/exists http://redis.io/commands/hexists


#4

Thanks will take feedback and consider.


#5

@memunix,

Thank you for posting about LDTs in our forum. Please see the LDT Feature Guide for current LDT recommendations and best practices.


#6

@memunix,

Effective immediately, we will no longer actively support the LDT feature and will eventually remove the API. The exact deprecation and removal timeline will depend on customer and community requirements. Instead of LDTs, we advise that you use our newer List and SortedMap APIs, which are now available in all Aerospike-supported clients at the General Availability level. Read our blog post for details.