0

Java client sources

Function select has index:

public java.util.List select(int space, int index, java.lang.Object key, int offset, int limit, int iterator)

But replace, update and delete given only space & key:

public java.util.List delete(int space, java.lang.Object key)
Ant20
  • 1,993
  • 2
  • 12
  • 16

1 Answers1

1

Delete is performed on a primary key, so it's an atomic operation because primary key enforces uniqueness. A secondary index might be unique, but it might be not as well, therefore you would need to start a transaction to ensure atomicity in a non-unique secondary index key. So that's a reason why there is no delete/update/insert on a secondary index for Java yet. It's a good question if tarantool allows transactions started remotely, but I doubt it'd be useful.

So you would need to do the following to get it working:

  1. write a stored procedure in Lua to iterate over your index/select the value you need
  2. put the procedure you wrote into your Tarantool instances
  3. call it from your Java code by name, by using a public List call(String var1, Object... var2);

E.g.

    -- Lua function
    function deleteFromSpaceByUniqueSecondaryIndex(secondaryId)
        box.space.YourSpace.index.yourSecondaryIdx:delete(secondaryId)
    end

.....

    //call it from Java like that
    tarantoolConn.call("deleteFromSpaceByUniqueSecondaryIndex", secondaryId);
bashnesnos
  • 816
  • 6
  • 16