Package com.gpudb

Class RecordRetriever<T>

  • Type Parameters:
    T - the type of object being retrieved

    public class RecordRetriever<T>
    extends Object
    Object that permits efficient retrieval of records from GPUdb, with support for multi-head access. RecordRetriever instances are thread safe and may be used from any number of threads simultaneously.
    • Method Detail

      • getGPUdb

        public GPUdb getGPUdb()
        Gets the GPUdb instance from which records will be retrieved.
        Returns:
        the GPUdb instance from which records will be retrieved
      • getTableName

        public String getTableName()
        Gets the name of the table from which records will be retrieved.
        Returns:
        the name of the table from which records will be retrieved
      • isUsingHeadRank

        public boolean isUsingHeadRank()
        Returns:
        whether this RecordRetriever object is using the head-rank to do a simple record fetching (not utilizing the server's key lookup feature) (true value), or using multi-head (the worker ranks) for key lookup (false value).
      • isDoingWorkerLookup

        public boolean isDoingWorkerLookup()
        Returns:
        whether this RecordRetriever object is using the worker ranks to do key lookups (true value), or doing simple record fetching (not the server's key lookup feature) (false value). Note that this will not reflect the non-worker lookup scenario where only an expression is supplied and the table is sharded.
      • getByKey

        public GetRecordsResponse<T> getByKey​(List<Object> keyValues,
                                              String expression)
                                       throws GPUdbException
        Retrieves records with the given key values and filter expression from the database using a direct-to-rank fast key lookup, if possible, and falling back to a standard lookup via the head node, if not.
        This method operates in four modes, depending on the parameters passed:
        • keyValues only - attempts a direct-to-rank lookup for records matching the given key values
        • keyValues and expression - attempts a direct-to-rank lookup for records matching the given key values, filtering them by the given expression
        • expression only - requests, via the head rank, all records in the table matching the given filter expression
        • neither - retrieves all records from the table via the head rank
        Parameters:
        keyValues - the key values to use for the lookup; these must correspond to either the explicit or implicit shard key for sharded tables or the primary key of replicated tables
        expression - a filter expression that will be applied to the data requested by the key values; if no key values are specified this filter will be applied to all of the data in the target table
        Returns:
        a GetRecordsResponse with the requested records
        Throws:
        GPUdbException
      • getByKey

        public GetRecordsResponse<T> getByKey​(List<Object> keyValues,
                                              String expression,
                                              long offset)
                                       throws GPUdbException
        Retrieves records with the given key values and filter expression from the database using a direct-to-rank fast key lookup, if possible, and falling back to a standard lookup via the head node, if not. Returns records in the overall result set starting from the given offset.
        This method operates in four modes, depending on the parameters passed:
        • keyValues only - attempts a direct-to-rank lookup for records matching the given key values
        • keyValues and expression - attempts a direct-to-rank lookup for records matching the given key values, filtering them by the given expression
        • expression only - requests, via the head rank, all records in the table matching the given filter expression
        • neither - retrieves all records from the table via the head rank
        Parameters:
        keyValues - the key values to use for the lookup; these must correspond to either the explicit or implicit shard key for sharded tables or the primary key of replicated tables
        expression - a filter expression that will be applied to the data requested by the key values; if no key values are specified this filter will be applied to all of the data in the target table
        offset - offset of the record(s) within the result set to return
        Returns:
        a GetRecordsResponse with the requested records
        Throws:
        GPUdbException
      • getColumnsByKey

        public GetRecordsByColumnResponse getColumnsByKey​(List<String> columns,
                                                          List<Object> keyValues,
                                                          String expression)
                                                   throws GPUdbException
        Retrieves records with the given key values and filter expression from the database using a direct-to-rank fast key lookup, if possible, and falling back to a standard lookup via the head node, if not.
        This method operates in four modes, depending on the parameters passed:
        • keyValues only - attempts a direct-to-rank lookup for records matching the given key values
        • keyValues and expression - attempts a direct-to-rank lookup for records matching the given key values, filtering them by the given expression
        • expression only - requests, via the head rank, all records in the table matching the given filter expression
        • neither - retrieves all records from the table via the head rank
        Parameters:
        columns - The requested columns (which can include expressions) being requested. May use "*" for all columns.
        keyValues - the key values to use for the lookup; these must correspond to either the explicit or implicit shard key for sharded tables or the primary key of replicated tables
        expression - a filter expression that will be applied to the data requested by the key values; if no key values are specified this filter will be applied to all of the data in the target table
        Returns:
        a GetRecordsResponse with the requested records
        Throws:
        GPUdbException
      • getColumnsByKey

        public GetRecordsByColumnResponse getColumnsByKey​(List<String> columns,
                                                          List<Object> keyValues,
                                                          String expression,
                                                          long offset)
                                                   throws GPUdbException
        Retrieves records with the given key values and filter expression from the database using a direct-to-rank fast key lookup, if possible, and falling back to a standard lookup via the head node, if not. Returns records in the overall result set starting from the given offset.
        This method operates in four modes, depending on the parameters passed:
        • keyValues only - attempts a direct-to-rank lookup for records matching the given key values
        • keyValues and expression - attempts a direct-to-rank lookup for records matching the given key values, filtering them by the given expression
        • expression only - requests, via the head rank, all records in the table matching the given filter expression
        • neither - retrieves all records from the table via the head rank
        Parameters:
        columns - The requested columns (which can include expressions) being requested. May use "*" for all columns.
        keyValues - the key values to use for the lookup; these must correspond to either the explicit or implicit shard key for sharded tables or the primary key of replicated tables
        expression - a filter expression that will be applied to the data requested by the key values; if no key values are specified this filter will be applied to all of the data in the target table
        offset - offset of the record(s) within the result set to return
        Returns:
        a GetRecordsResponse with the requested records
        Throws:
        GPUdbException