| 55 | runtime_profile_(profile) { } |
| 56 | |
| 57 | Status HBaseTableWriter::Init(RuntimeState* state) { |
| 58 | RETURN_IF_ERROR(ExecEnv::GetInstance()->htable_factory()->GetTable( |
| 59 | table_desc_->table_name(), &table_)); |
| 60 | encoding_timer_ = ADD_TIMER(runtime_profile_, "EncodingTimer"); |
| 61 | htable_put_timer_ = ADD_TIMER(runtime_profile_, "HTablePutTimer"); |
| 62 | |
| 63 | int num_col = table_desc_->num_cols(); |
| 64 | if (num_col < 2) { |
| 65 | return Status("HBase tables must contain at least" |
| 66 | " one column in addition to the row key."); |
| 67 | } |
| 68 | |
| 69 | JNIEnv* env = JniUtil::GetJNIEnv(); |
| 70 | if (env == NULL) return Status("Error getting JNIEnv."); |
| 71 | output_exprs_byte_sizes_.resize(num_col); |
| 72 | cf_arrays_.reserve(num_col - 1); |
| 73 | qual_arrays_.reserve(num_col - 1); |
| 74 | for (int i = 0; i < num_col; ++i) { |
| 75 | output_exprs_byte_sizes_[i] = |
| 76 | output_expr_evals_[i]->root().type().GetByteSize(); |
| 77 | |
| 78 | if (i == 0) continue; |
| 79 | |
| 80 | // Setup column family and qualifier byte array for non-rowkey column |
| 81 | const HBaseTableDescriptor::HBaseColumnDescriptor& col = table_desc_->cols()[i]; |
| 82 | jbyteArray byte_array; |
| 83 | jbyteArray global_ref; |
| 84 | RETURN_IF_ERROR(CreateByteArray(env, col.family, &byte_array)); |
| 85 | RETURN_IF_ERROR(JniUtil::LocalToGlobalRef(env, byte_array, &global_ref)); |
| 86 | cf_arrays_.push_back(global_ref); |
| 87 | RETURN_IF_ERROR(CreateByteArray(env, col.qualifier, &byte_array)); |
| 88 | RETURN_IF_ERROR(JniUtil::LocalToGlobalRef(env, byte_array, &global_ref)); |
| 89 | qual_arrays_.push_back(global_ref); |
| 90 | } |
| 91 | |
| 92 | return Status::OK(); |
| 93 | } |
| 94 | |
| 95 | Status HBaseTableWriter::InitJNI() { |
| 96 | JNIEnv* env = JniUtil::GetJNIEnv(); |
no test coverage detected