1 #ifndef __GPUDB_MULTIHEAD_IO_UTILS_H__
2 #define __GPUDB_MULTIHEAD_IO_UTILS_H__
26 typedef std::vector<gpudb::HttpUrl> worker_list;
76 size_t size()
const {
return m_worker_urls.size(); }
84 bool empty()
const {
return m_worker_urls.empty(); }
92 worker_list m_worker_urls;
94 static void split_string(
const std::string &in_string,
96 std::vector<std::string> &elements );
125 void reset(
size_t buffer_size );
132 void add_char1(
const std::string& value,
bool is_null );
135 void add_char2(
const std::string& value,
bool is_null );
138 void add_char4(
const std::string& value,
bool is_null );
141 void add_char8(
const std::string& value,
bool is_null );
144 void add_char16(
const std::string& value,
bool is_null );
147 void add_char32(
const std::string& value,
bool is_null );
150 void add_char64(
const std::string& value,
bool is_null );
153 void add_char128(
const std::string& value,
bool is_null );
156 void add_char256(
const std::string& value,
bool is_null );
159 void add_date(
const std::string& value,
bool is_null );
162 void add_datetime(
const std::string& value,
bool is_null );
165 void add_decimal(
const std::string& value,
bool is_null );
168 void add_double(
double value,
bool is_null );
171 void add_float(
float value,
bool is_null );
174 void add_int8( int8_t value,
bool is_null );
177 void add_int16( int16_t value,
bool is_null );
180 void add_int( int32_t value,
bool is_null );
183 void add_ipv4(
const std::string& value,
bool is_null );
186 void add_long( int64_t value,
bool is_null );
189 void add_time(
const std::string& value,
bool is_null );
195 void add_string(
const std::string& value,
bool is_null );
198 void add_ulong(
const std::string& value,
bool is_null );
201 void add_uuid(
const std::string& value,
bool is_null );
209 size_t route(
const std::vector<int32_t>& routing_table )
const;
225 && !(*
this == rhs) ); }
227 std::string
toString(
const std::string& separator =
" " )
const;
234 bool is_buffer_full(
bool throw_if_full =
true )
const;
237 bool will_buffer_overflow(
int n,
bool throw_if_overflow =
true )
const;
240 void add( uint8_t b );
242 std::vector<unsigned char> m_buffer;
243 size_t m_buffer_size;
244 size_t m_current_size;
246 int64_t m_routing_hash;
248 bool m_key_is_complete;
288 typedef boost::optional<int32_t> nullableInt;
291 std::vector<int32_t> m_pk_shard_key_indices;
292 std::vector<ColumnType_T> m_column_types;
293 size_t m_key_buffer_size;
311 std::string& result )
const;
315 bool has_key()
const {
return !m_pk_shard_key_indices.empty(); }
353 WorkerQueue(
const std::string& url,
size_t capacity );
381 #endif // __GPUDB_MULTIHEAD_IO_UTILS_H__
bool operator!=(const RecordKeyBuilder &rhs) const
void clear()
Clear queue without sending.
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)
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_boolean(bool 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_uuid(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.
int64_t get_routing_hash() const