1 #ifndef __GPUDB_MULTIHEAD_IO_UTILS_H__
2 #define __GPUDB_MULTIHEAD_IO_UTILS_H__
26 typedef std::vector<gpudb::HttpUrl> worker_list;
71 size_t size()
const {
return m_worker_urls.size(); }
79 bool empty()
const {
return m_worker_urls.empty(); }
87 worker_list m_worker_urls;
89 static void split_string(
const std::string &in_string,
91 std::vector<std::string> &elements );
117 void reset(
size_t buffer_size );
121 void add_char1(
const std::string& value,
bool is_null );
124 void add_char2(
const std::string& value,
bool is_null );
127 void add_char4(
const std::string& value,
bool is_null );
130 void add_char8(
const std::string& value,
bool is_null );
133 void add_char16(
const std::string& value,
bool is_null );
136 void add_char32(
const std::string& value,
bool is_null );
139 void add_char64(
const std::string& value,
bool is_null );
142 void add_char128(
const std::string& value,
bool is_null );
145 void add_char256(
const std::string& value,
bool is_null );
148 void add_date(
const std::string& value,
bool is_null );
151 void add_datetime(
const std::string& value,
bool is_null );
154 void add_decimal(
const std::string& value,
bool is_null );
157 void add_double(
double value,
bool is_null );
160 void add_float(
float value,
bool is_null );
163 void add_int8( int8_t value,
bool is_null );
166 void add_int16( int16_t value,
bool is_null );
169 void add_int( int32_t value,
bool is_null );
172 void add_ipv4(
const std::string& value,
bool is_null );
175 void add_long( int64_t value,
bool is_null );
178 void add_time(
const std::string& value,
bool is_null );
184 void add_string(
const std::string& value,
bool is_null );
187 void add_ulong(
const std::string& value,
bool is_null );
195 size_t route(
const std::vector<int32_t>& routing_table )
const;
211 && !(*
this == rhs) ); }
213 std::string
toString(
const std::string& separator =
" " )
const;
220 bool is_buffer_full(
bool throw_if_full =
true )
const;
223 bool will_buffer_overflow(
int n,
bool throw_if_overflow =
true )
const;
226 void add( uint8_t b );
228 std::vector<unsigned char> m_buffer;
229 size_t m_buffer_size;
230 size_t m_current_size;
232 int64_t m_routing_hash;
234 bool m_key_is_complete;
272 typedef boost::optional<int32_t> nullableInt;
275 std::vector<int32_t> m_pk_shard_key_indices;
276 std::vector<ColumnType_T> m_column_types;
277 size_t m_key_buffer_size;
295 std::string& result )
const;
299 bool has_key()
const {
return !m_pk_shard_key_indices.empty(); }
325 bool m_has_primary_key;
326 bool m_update_on_existing_pk;
331 typedef std::map<RecordKey, size_t> primary_key_map_t;
332 primary_key_map_t m_primary_key_map;
344 WorkerQueue(
const std::string& url,
size_t capacity,
bool has_primary_key,
345 bool update_on_existing_pk );
370 #endif // __GPUDB_MULTIHEAD_IO_UTILS_H__
bool operator!=(const RecordKeyBuilder &rhs) const
void add_date(const std::string &value, bool is_null)
bool build(const gpudb::GenericRecord &record, RecordKey &record_key) const
void reset(size_t buffer_size)
WorkerList(const GPUdb &gpudb)
void add_string(const std::string &value, bool is_null)
void add_char2(const std::string &value, bool is_null)
bool operator<(const RecordKey &rhs) const
Returns true if this RecordKey is less than the other key.
void add_char32(const std::string &value, bool is_null)
void add_char8(const std::string &value, bool is_null)
void add_ipv4(const std::string &value, bool is_null)
RecordKey & operator=(const RecordKey &other)
The assignment operator.
bool buildExpression(const gpudb::GenericRecord &record, std::string &result) const
void add_int8(int8_t value, bool is_null)
void add_time(const std::string &value, bool is_null)
static bool verify_ulong_value(const std::string &value)
A static utility function for verifying if a given string is a valid.
void add_char128(const std::string &value, bool is_null)
std::vector< gpudb::GenericRecord > recordVector_T
void add_timestamp(int64_t value, bool is_null)
size_t route(const std::vector< int32_t > &routing_table) const
Given a routing table consisting of worker rank indices, choose a worker rank based on the hash of th...
const_iterator begin() const
bool insert(const gpudb::GenericRecord &record, const RecordKey &key, recordVector_T &flushed_records)
Inserts a record into the queue.
void add_ulong(const std::string &value, bool is_null)
int32_t get_hash_code() const
const_iterator end() const
bool operator!=(const RecordKey &rhs) const
std::string toString(const std::string &separator=" ") const
bool operator==(const RecordKey &rhs) const
Returns true if the other RecordKey is equivalent to this key.
void add_char64(const std::string &value, bool is_null)
void add_double(double value, bool is_null)
void add_char1(const std::string &value, bool is_null)
bool operator==(const RecordKeyBuilder &rhs) const
void add_long(int64_t value, bool is_null)
void add_int(int32_t value, bool is_null)
bool operator>(const RecordKey &rhs) const
void add_decimal(const std::string &value, bool is_null)
void add_datetime(const std::string &value, bool is_null)
void add_char16(const std::string &value, bool is_null)
void compute_hash()
Compute the hash of the key in the buffer.
void add_char4(const std::string &value, bool is_null)
std::string toString() const
void add_char256(const std::string &value, bool is_null)
worker_list::const_iterator const_iterator
void add_int16(int16_t value, bool is_null)
void add_float(float value, bool is_null)
void flush(recordVector_T &flushed_records)
Returns the current queue and creates a new internal queue.
const gpudb::HttpUrl & get_url() const
Returns the URL in string format for this worker.