Package com.gpudb
Class RecordRetriever<T>
- java.lang.Object
-
- com.gpudb.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.RecordRetrieverinstances are thread safe and may be used from any number of threads simultaneously.
-
-
Constructor Summary
Constructors Constructor Description RecordRetriever(GPUdb gpudb, String tableName, Type type)Creates aRecordRetrieverwith the specified parameters.RecordRetriever(GPUdb gpudb, String tableName, TypeObjectMap<T> typeObjectMap)Creates aRecordRetrieverwith the specified parameters.RecordRetriever(GPUdb gpudb, String tableName, TypeObjectMap<T> typeObjectMap, WorkerList workers)Creates aRecordRetrieverwith the specified parameters.RecordRetriever(GPUdb gpudb, String tableName, TypeObjectMap<T> typeObjectMap, WorkerList workers, Map<String,String> options)Creates aRecordRetrieverwith the specified parameters.RecordRetriever(GPUdb gpudb, String tableName, TypeObjectMap<T> typeObjectMap, Map<String,String> options)Creates aRecordRetrieverwith the specified parameters.RecordRetriever(GPUdb gpudb, String tableName, Type type, WorkerList workers)Creates aRecordRetrieverwith the specified parameters.RecordRetriever(GPUdb gpudb, String tableName, Type type, WorkerList workers, Map<String,String> options)Creates aRecordRetrieverwith the specified parameters.RecordRetriever(GPUdb gpudb, String tableName, Type type, Map<String,String> options)Creates aRecordRetrieverwith the specified parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GetRecordsResponse<T>getByKey(List<Object> keyValues, String expression)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.GetRecordsResponse<T>getByKey(List<Object> keyValues, String expression, long offset)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.GetRecordsByColumnResponsegetColumnsByKey(List<String> columns, List<Object> keyValues, String expression)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.GetRecordsByColumnResponsegetColumnsByKey(List<String> columns, List<Object> keyValues, String expression, long offset)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.GPUdbgetGPUdb()Gets the GPUdb instance from which records will be retrieved.Map<String,String>getOptions()Gets the options currently used for the retriever methods.StringgetTableName()Gets the name of the table from which records will be retrieved.booleanisDoingWorkerLookup()booleanisUsingHeadRank()RecordRetriever<T>setOptions(Map<String,String> options)Sets the options to be used for the retriever methods.
-
-
-
Constructor Detail
-
RecordRetriever
public RecordRetriever(GPUdb gpudb, String tableName, Type type) throws GPUdbException
Creates aRecordRetrieverwith the specified parameters.
It will use default settings for theGPUdb.getRecords(String, long, long, Map)call supportinggetByKey(List, String)and theGPUdb.getRecordsByColumn(String, List, long, long, Map)call supportinggetColumnsByKey(List, List, String).
Details can be found atGetRecordsRequest.OptionsandGetRecordsByColumnRequest.Options, respectively.- Parameters:
gpudb- theGPUdbinstance to retrieve records fromtableName- the table to retrieve records fromtype- theTypeof records being retrieved- Throws:
GPUdbException- if a configuration error occursIllegalArgumentException- if an invalid parameter is specified
-
RecordRetriever
public RecordRetriever(GPUdb gpudb, String tableName, Type type, Map<String,String> options) throws GPUdbException
Creates aRecordRetrieverwith the specified parameters.- Parameters:
gpudb- theGPUdbinstance to retrieve records fromtableName- the table to retrieve records fromtype- theTypeof records being retrievedoptions- optional parameters to pass to GPUdb while retrieving (nullfor no parameters)
This is the same set of options as accepted by theGPUdb.getRecords(String, long, long, Map)andGPUdb.getRecordsByColumn(String, List, long, long, Map)calls.
The details can be found atGetRecordsRequest.OptionsandGetRecordsByColumnRequest.Options.- Throws:
GPUdbException- if a configuration error occursIllegalArgumentException- if an invalid parameter is specified
-
RecordRetriever
public RecordRetriever(GPUdb gpudb, String tableName, Type type, WorkerList workers) throws GPUdbException
Creates aRecordRetrieverwith the specified parameters.- Parameters:
gpudb- theGPUdbinstance to retrieve records fromtableName- the table to retrieve records fromtype- theTypeof records being retrievedworkers- worker list for multi-head retrieval (nullto disable multi-head retrieval)- Throws:
GPUdbException- if a configuration error occursIllegalArgumentException- if an invalid parameter is specified
-
RecordRetriever
public RecordRetriever(GPUdb gpudb, String tableName, Type type, WorkerList workers, Map<String,String> options) throws GPUdbException
Creates aRecordRetrieverwith the specified parameters.- Parameters:
gpudb- theGPUdbinstance to retrieve records fromtableName- the table to retrieve records fromtype- theTypeof records being retrievedworkers- worker list for multi-head retrieval (nullto disable multi-head retrieval)options- optional parameters to pass to GPUdb while retrieving (nullfor no parameters)
This is the same set of options as accepted by theGPUdb.getRecords(String, long, long, Map)andGPUdb.getRecordsByColumn(String, List, long, long, Map)calls.
The details can be found atGetRecordsRequest.OptionsandGetRecordsByColumnRequest.Options.- Throws:
GPUdbException- if a configuration error occursIllegalArgumentException- if an invalid parameter is specified
-
RecordRetriever
public RecordRetriever(GPUdb gpudb, String tableName, TypeObjectMap<T> typeObjectMap) throws GPUdbException
Creates aRecordRetrieverwith the specified parameters.- Parameters:
gpudb- theGPUdbinstance to retrieve records fromtableName- the table to retrieve records fromtypeObjectMap- theTypeObjectMapfor the type of records being retrieved- Throws:
GPUdbException- if a configuration error occursIllegalArgumentException- if an invalid parameter is specified
-
RecordRetriever
public RecordRetriever(GPUdb gpudb, String tableName, TypeObjectMap<T> typeObjectMap, Map<String,String> options) throws GPUdbException
Creates aRecordRetrieverwith the specified parameters.- Parameters:
gpudb- theGPUdbinstance to retrieve records fromtableName- the table to retrieve records fromtypeObjectMap- theTypeObjectMapfor the type of records being retrievedoptions- optional parameters to pass to GPUdb while retrieving (nullfor no parameters)
This is the same set of options as accepted by theGPUdb.getRecords(String, long, long, Map)andGPUdb.getRecordsByColumn(String, List, long, long, Map)calls.
The details can be found atGetRecordsRequest.OptionsandGetRecordsByColumnRequest.Options.- Throws:
GPUdbException- if a configuration error occursIllegalArgumentException- if an invalid parameter is specified
-
RecordRetriever
public RecordRetriever(GPUdb gpudb, String tableName, TypeObjectMap<T> typeObjectMap, WorkerList workers) throws GPUdbException
Creates aRecordRetrieverwith the specified parameters.- Parameters:
gpudb- theGPUdbinstance to retrieve records fromtableName- the table to retrieve records fromtypeObjectMap- theTypeObjectMapfor the type of records being retrievedworkers- worker list for multi-head retrieval (nullto disable multi-head retrieval)- Throws:
GPUdbException- if a configuration error occursIllegalArgumentException- if an invalid parameter is specified
-
RecordRetriever
public RecordRetriever(GPUdb gpudb, String tableName, TypeObjectMap<T> typeObjectMap, WorkerList workers, Map<String,String> options) throws GPUdbException
Creates aRecordRetrieverwith the specified parameters.- Parameters:
gpudb- theGPUdbinstance to retrieve records fromtableName- the table to retrieve records fromtypeObjectMap- theTypeObjectMapfor the type of records being retrievedworkers- worker list for multi-head retrieval (nullto disable multi-head retrieval)options- optional parameters to pass to GPUdb while retrieving (nullfor no parameters)
This is the same set of options as accepted by theGPUdb.getRecords(String, long, long, Map)andGPUdb.getRecordsByColumn(String, List, long, long, Map)calls.
The details can be found atGetRecordsRequest.OptionsandGetRecordsByColumnRequest.Options.- Throws:
GPUdbException- if a configuration error occursIllegalArgumentException- if an invalid parameter is specified
-
-
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
RecordRetrieverobject 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
RecordRetrieverobject 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.
-
getOptions
public Map<String,String> getOptions()
Gets the options currently used for the retriever methods. Note that anyGetRecordsRequest.Options.EXPRESSIONoptions will get overridden at the nextgetByKey(java.util.List<java.lang.Object>, java.lang.String)call with the appropriate expression.- Returns:
- the options used during record retrieval
- See Also:
setOptions(java.util.Map<java.lang.String, java.lang.String>)
-
setOptions
public RecordRetriever<T> setOptions(Map<String,String> options)
Sets the options to be used for the retriever methods.- Parameters:
options- the options to be used during record retrieval- Returns:
- the current
RecordRetrieverinstance - See Also:
GetRecordsRequest.Options.EXPRESSION
-
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 tablesexpression- 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
GetRecordsResponsewith 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 givenoffset.
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 tablesexpression- 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 tableoffset- offset of the record(s) within the result set to return- Returns:
- a
GetRecordsResponsewith 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 tablesexpression- 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
GetRecordsResponsewith 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 givenoffset.
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 tablesexpression- 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 tableoffset- offset of the record(s) within the result set to return- Returns:
- a
GetRecordsResponsewith the requested records - Throws:
GPUdbException
-
-