3 using System.Collections.Generic;
22 private Utils.RecordKeyBuilder<T> shard_key_builder;
23 private IList<int> routing_table;
24 private IList<Utils.WorkerQueue<T>> worker_queues;
25 private Random random;
37 Utils.WorkerList workers = null)
45 this.shard_key_builder =
new Utils.RecordKeyBuilder<T>(
false, this.ktype);
47 if (!this.shard_key_builder.hasKey())
48 this.shard_key_builder = null;
53 this.worker_queues =
new List<Utils.WorkerQueue<T>>();
57 if ((workers == null) || (workers.Count == 0))
59 workers =
new Utils.WorkerList(kdb);
64 if ((workers != null) && (workers.Count > 0))
67 foreach (
System.Uri worker_url in workers)
69 string get_records_worker_url_str = (worker_url.ToString() +
"get/records");
70 System.Uri url =
new System.Uri( get_records_worker_url_str );
71 Utils.WorkerQueue<T> worker_queue =
new Utils.WorkerQueue<T>( url );
72 this.worker_queues.Add( worker_queue );
78 for (
int i = 0; i < routing_table.Count; ++i)
80 if (this.routing_table[i] > this.worker_queues.Count)
86 string get_records_url_str = ( kdb.
URL.ToString() +
"get/records" );
88 Utils.WorkerQueue<T> worker_queue =
new Utils.WorkerQueue<T>( url );
89 this.worker_queues.Add(worker_queue);
90 this.routing_table = null;
99 this.random =
new Random((
int)DateTime.Now.Ticks);
125 string expression = null )
127 if ( this.shard_key_builder == null)
133 string full_expression = this.shard_key_builder.buildExpression( record );
134 if ( full_expression == null )
136 if ( expression != null )
137 full_expression = (full_expression +
" and (" + expression +
")");
140 IDictionary<string, string> options =
new Dictionary<string, string>();
150 if ( this.routing_table == null )
161 Utils.RecordKey shard_key = this.shard_key_builder.build( record );
162 System.Uri url = this.worker_queues[ shard_key.route( this.routing_table ) ].url;
174 kineticaDB.DecodeRawBinaryDataUsingRecordType( ktype,
176 decoded_response.
data );
177 return decoded_response;
182 }
catch ( Exception ex )
RecordRetriever(Kinetica kdb, string table_name, KineticaType ktype, Utils.WorkerList workers=null)
Create a RecordRetriever object with the given parameters.
IList< byte[]> records_binary
If the was 'binary', then this list contains the binary encoded records retrieved from the table...
const int END_OF_SET
No Limit
AdminShowShardsResponse adminShowShards(AdminShowShardsRequest request_)
Show the mapping of shards to the corresponding rank and tom.
const string FAST_INDEX_LOOKUP
Indicates if indexes should be used to perform the lookup for a given expression if possible...
A set of results returned by Kinetica.getRecords<T>(string,long,long,IDictionary<string, string>).
bool has_more_records
Too many records. Returned a partial set.
Uri URL
URL for Kinetica Server (including "http:" and port)
string table_name
Value of .
const string EXPRESSION
Optional filter expression to apply to the table.
long total_number_of_records
Total/Filtered number of records.
IList< T > data
If the was 'binary', then this list contains the binary encoded records retrieved from the table...
A set of parameters for Kinetica.getRecords<T>(string,long,long,IDictionary<string, string>).
string type_schema
Avro schema of <member name="records_binary"> or <member name="records_json">
GetRecordsResponse< T > getRecordsByKey(T record, string expression=null)
Retrieves records for a given shard key, optionally further limited by an additional expression...
string type_schema
Avro schema of <member name="records_binary"> or <member name="records_json">
Manages the insertion into GPUdb of large numbers of records in bulk, with automatic batch management...
EXPRESSION: Optional filter expression to apply to the table.
bool has_more_records
Too many records. Returned a partial set.
string table_name
Value of .
long total_number_of_records
Total/Filtered number of records.
IList< int > rank
Array of ranks indexed by the shard number.
A set of results returned by Kinetica.getRecords<T>(string,long,long,IDictionary<string, string>).
API to talk to Kinetica Database