Java API LargeSet is failing when loading a list of values


#1

I am working on getting the Java API LargeSet working but when i try to add a list of objects i get the following exception

com.aerospike.client.AerospikeException: Error Code 100: /opt/aerospike/sys/udf/lua/aerospike.lua:45: bad argument #4 to 'format' (no value)
	com.aerospike.client.command.ReadCommand.handleUdfError(ReadCommand.java:141)
	com.aerospike.client.command.ReadCommand.parseResult(ReadCommand.java:105)
	com.aerospike.client.command.SyncCommand.execute(SyncCommand.java:56)
	com.aerospike.client.AerospikeClient.execute(AerospikeClient.java:1033)
	com.ngleav.aerospike.client.large.LargeSet.add(LargeSet.java:81)
	com.ngleav.CountService.initLDTSet(CountService.java:253)
	com.test.getAerospike(test.java:37)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	java.lang.reflect.Method.invoke(Method.java:606)
	org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
	org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
	org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
	org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
	org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
	org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
	org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
	org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
	org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
	org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

relavent code:

    for (Map.Entry<String, Set<String>> entry : publisherCounts.entrySet()) {
        key = new Key(namespace, "INDEX", entry.getKey());
        client.delete(policy, key);
        System.out.println(entry.getValue().size());
        LargeSet set = client.getLargeSet(policy, key, "counts", null);
        int count = 1;
        List<String> strings = Lists.newArrayList(entry.getValue());
        Value value = Value.getAsList(strings);
        set.add(strings);
}

I have enabled Large datatypes in the namespace config. I dont know what else to do. It seems to work if i call largeSet.add() for every value but using the addd all functionality throws this exception.

Thanks for your time.


#2

We have consolidated our LDT and now is only actively supporting LLIST data type.

Recommendation is to switch over to using LLIST


#3

The Java API actually uses LLIST under the covers but i went ahead and changed the code snippet to use LargeList instead of LargeSet. I still have the same issue.


#4

I believe what you are trying to do is add multiple strings to the list at the same time. This is done via multiple Values on the “add()” call. Please see example:

The effect of the call in the example is that a “list” data type is attempted. LLIST cannot take “list” as a data type. The types accepted are integer/string/map.

Hope this helps.


#5

In the Java API, the LargeList class has methods for:

.add(Value), .add(Value …), .add(List<>)

This should indicate that I should be able to send in a list of Strings and have it add all of those Strings to the data set. What i have done is convert the list into a ValueList using Value.getAsList

        Value value = Value.getAsList(new ArrayList<>(entry.getValue()));

This returns an object of type ValueList which inherits from Value and should work being passed to LargeList.add(Value). Doing this, I do get a different exception but this exception doesn’t make sense to me.

com.aerospike.client.AerospikeException: Error Code 1433: /opt/aerospike/sys/udf/lua/ldt/lib_llist.lua:1380 LDT-Key (Unique) Function Not Found
com.aerospike.client.command.ReadCommand.handleUdfError(ReadCommand.java:144)
com.aerospike.client.command.ReadCommand.parseResult(ReadCommand.java:105)
com.aerospike.client.command.SyncCommand.execute(SyncCommand.java:56)
com.aerospike.client.AerospikeClient.execute(AerospikeClient.java:1033)
com.aerospike.client.large.LargeList.add(LargeList.java:65)

This is at least progress though I don’t understand why sending a List<> into LargeList.add() doesn’t work.

One thing I have not tried is constructing an array of Value objects by calling Value.get(String) on every element of the set I am trying to put into LargeList. I can do this but… i am not happy with that solution at all. Is there some reason why I can only send in a List of objects? why Not Collection? The limitation causes the application layer to make that conversion which is just more unnecessary overhead.

Again, Thanks for your time.


#6

@ngleav,

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


#7

@ngleav,

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.