Space Data Retrieval Methods

You can retrieve (or consume) data from a space in three ways: Get Method, Callback Query Method, and Space Browser Method. The method you use to retreive data from a space depends on the application logic of your code.

  • Get Method - A tuple space implements the associative memory paradigm and allows the application to get a complete copy of the tuple associated with specific values of it's key fields.

    This is done by using the spaces’s get method and passing a tuple containing appropriate key field values for that space. If a tuple with matching values for its key fields is currently stored in the space, the value of the status in the result object returned by the get method is equal to OK. If no tuple in the space has matching values for the key fields, the value of the status in the result object is NULL.

  • Callback Query Method - You can create listeners on a space that invoke a user query callback function as filtered initial data and new data are pushed from the space to the listeners. For more information on listeners, see Listeners.
  • Space Browser Query Method - You can also create space browsers on the space that let users retrieve filtered data initially stored in the space and retrieve new data tuple by tuple and on demand. For more information on space browsers, see Browsers.

The method used to retrieve data from a space depends on the application logic of your code.

  • To retrieve a single tuple using an exact key match, use the get function.
  • To retrieve and monitor either all or a filtered subset of the data contained in the space, both listeners and space browsers offer the same functionality. The choice of which method to use depends on whether your application needs a multi-threaded event-driven callback-oriented approach, or needs to iterate through the tuples at its own pace (i.e., on demand, using the space browser’s next method).
Related reference