The Take Operation Consuming or Removing Data from a Space

You can remove tuples from a space by using the space’s take method and passing a tuple containing the appropriate key fields for that space.

The take method behaves exactly like an atomic get-and-remove: If a tuple with matching values for its key fields is currently stored in the space, you can infer the following:

  • The status value of the result passed to the take operation is be equal to OK.
  • The complete tuple is contained in the result, and at the same time removed from the space.

Otherwise (if there is no tuple with matching values for its key fields currently stored in the space), there is nothing retrieved by the Take operation, and the result's status is equal to NULL. Since ActiveSpaces provides immediate consistency, you have a guarantee that if two separate applications issue a take for the same entry at the same time, only one of them will see its take operation succeed; the other one will see its result's status be equal to NULL.

Unlike a simple delete operation that succeeds even if there is nothing to delete, you can use the take operation to effectively “consume” data from a space (for example, using a space browser), and your application can easily distribute workload using ActiveSpaces.

You can also perform a take operation on all or a filtered subset of the tuples contained in a space by using a space browser. For more information on space browsers, see Browsers.

Related reference