Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hbase-table-writer.h
Go to the documentation of this file.
1 // Copyright 2012 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef IMPALA_EXEC_HBASE_TABLE_WRITER_H
16 #define IMPALA_EXEC_HBASE_TABLE_WRITER_H
17 
18 #include <jni.h>
19 #include <boost/thread.hpp>
20 #include <boost/scoped_ptr.hpp>
21 #include <vector>
22 #include <string>
23 #include <utility>
24 
25 #include "common/status.h"
26 #include "runtime/runtime-state.h"
27 #include "runtime/descriptors.h"
28 #include "runtime/row-batch.h"
29 #include "runtime/hbase-table.h"
30 
31 namespace impala {
32 
42  public:
44  const std::vector<ExprContext*>& output_expr_ctxs,
45  RuntimeProfile* profile);
47 
49  void Close(RuntimeState* state);
50 
53  Status Init(RuntimeState* state);
54 
56  static Status InitJNI();
57 
58  private:
61  Status CreatePut(JNIEnv* env, const void* rk, int rk_len, jobject* put);
62 
64  Status CreateByteArray(JNIEnv* env, const std::string& s,
65  jbyteArray* j_array);
66 
68  Status CreateByteArray(JNIEnv* env, const void* data, int data_len,
69  jbyteArray* j_array);
70 
74  Status CreatePutList(JNIEnv* env, int num_puts);
75 
79 
82 
86  boost::scoped_ptr<HBaseTable> table_;
87 
89  const std::vector<ExprContext*> output_expr_ctxs_;
90 
92  std::vector<int> output_exprs_byte_sizes_;
93 
95  jobject put_list_;
96 
98  static jclass put_cl_;
99 
101  static jmethodID put_ctor_;
102 
104  static jmethodID put_add_id_;
105 
107  static jclass list_cl_;
108 
110  static jmethodID list_ctor_;
111 
113  static jmethodID list_add_id_;
114 
116  std::vector<jbyteArray> cf_arrays_;
117 
119  std::vector<jbyteArray> qual_arrays_;
120 
125 };
126 
127 } // namespace impala
128 #endif
static jmethodID put_add_id_
Put::add(byte[], byte[], byte[])
jobject put_list_
jni ArrayList<Put>
Status CreatePutList(JNIEnv *env, int num_puts)
std::vector< int > output_exprs_byte_sizes_
output_exprs_byte_sizes_[i] is the byte size of output_expr_ctxs_[i]->root()'s type.
std::vector< jbyteArray > qual_arrays_
qual_arrays_[i-1] is the column family qualifier jbyteArray for column i.
static jmethodID put_ctor_
new Put(byte[])
Status CreatePut(JNIEnv *env, const void *rk, int rk_len, jobject *put)
static jmethodID list_add_id_
ArrayList::add(V);.
std::vector< jbyteArray > cf_arrays_
cf_arrays_[i-1] is the column family jbyteArray for column i.
const std::vector< ExprContext * > output_expr_ctxs_
The expressions that are run to create tuples to be written to hbase.
RuntimeProfile * runtime_profile_
Parent table sink's profile.
static jclass put_cl_
org.apache.hadoop.hbase.client.Put
static Status InitJNI()
Grab all of the Java classes needed to get data into and out of HBase.
HBaseTableWriter(HBaseTableDescriptor *table_desc, const std::vector< ExprContext * > &output_expr_ctxs, RuntimeProfile *profile)
RuntimeProfile::Counter * htable_put_timer_
Status Init(RuntimeState *state)
Status CreateByteArray(JNIEnv *env, const std::string &s, jbyteArray *j_array)
Create a byte array containing the string's chars.
Status AppendRowBatch(RowBatch *batch)
RuntimeProfile::Counter * encoding_timer_
static jclass list_cl_
java.util.ArrayList
void Close(RuntimeState *state)
Calls to Close release the HBaseTable.
HBaseTableDescriptor * table_desc_
Owned by RuntimeState not by this object.
static jmethodID list_ctor_
new ArrayList<V>(starting_capacity)
boost::scoped_ptr< HBaseTable > table_