Popping from LSTACK


#1

Hi, Is is possible to pop an element from a LSTACK? I can only peek elements, but I want to remove them from the stack like a normal stack doing a pop operation.

Example:

Push A Push B List contains [A, B] Pop List contains [A]

Thanks


#2

Yes

aql> execute lstack.push('stackbin', 1) on test.demo where PK=1
+------+
| push |
+------+
| 0    |
+------+
1 row in set (0.001 secs)

aql> execute lstack.push('stackbin', 1) on test.demo where PK=1
+------+
| push |
+------+
| 0    |
+------+
1 row in set (0.000 secs)

aql> execute lstack.push('stackbin', 1) on test.demo where PK=1
+------+
| push |
+------+
| 0    |
+------+
1 row in set (0.000 secs)

aql> execute lstack.scan('stackbin') on test.demo where PK=1
+-----------+
| scan      | 
+-----------+
| [1, 1, 1] |
 +-----------+
 1 row in set (0.000 secs)

aql> execute lstack.pop('stackbin', 2) on test.demo where PK=1
+--------+
|  pop    |
+--------+
| [1, 1] |
+--------+
1 row in set (0.000 secs)

aql> execute lstack.scan('stackbin') on test.demo where PK=1
+------+
| scan | 
+------+
| [1]  |
+------+
1 row in set (0.000 secs)

But please do remember that lstack will be deprecated soon.

Instead try using LLIST. Refer to https://github.com/helipilot50/aerospike-LDT-techniques

– R


#3

There is no such operation in C API: http://www.aerospike.com/apidocs/c/df/d4e/group__ldt__operations.html


#4

Using the C API, you can only push, peek and destroy, but there is no capability for removing or popping from the stack.


#5

But…AQL has this functionality if I remember correctly, how is that implemented?


#6

aql is doing this via a udf execution call, which is what all LDT calls are. You would be able to do the same with C as well. The LDT calls on C are simply wrapper calls to UDF execute calls.


#7

@mickkelodeon,

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


#8

@mickkelodeon,

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.