MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / Init

Method Init

src/sdk/batch_request_result_set_sql.cc:46–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44SQLBatchRequestResultSet::~SQLBatchRequestResultSet() {}
45
46bool SQLBatchRequestResultSet::Init() {
47 if (!response_ || response_->code() != ::fedb::base::kOk) {
48 LOG(WARNING) << "bad response code " << response_->code();
49 return false;
50 }
51
52 // Get all buffer byte size
53 byte_size_ = 0;
54 for (auto row_size : response_->row_sizes()) {
55 if (row_size < 0) {
56 LOG(WARNING) << "illegal row size field";
57 return false;
58 }
59 byte_size_ += row_size;
60 }
61 DLOG(INFO) << "byte size " << byte_size_ << " count " << response_->count();
62
63 // Decode schema
64 ::hybridse::codec::Schema schema;
65 ::hybridse::codec::SchemaCodec::Decode(response_->schema(), &schema);
66 external_schema_.SetSchema(schema);
67
68 if (byte_size_ <= 0) return true;
69
70 for (int i = 0; i < response_->common_column_indices().size(); ++i) {
71 common_column_indices_.insert(
72 response_->common_column_indices().Get(i));
73 }
74 column_remap_.resize(schema.size());
75 for (int i = 0; i < schema.size(); ++i) {
76 auto iter = common_column_indices_.find(i);
77 if (iter != common_column_indices_.end()) {
78 column_remap_[i] = common_schema_.size();
79 *common_schema_.Add() = schema.Get(i);
80 } else {
81 column_remap_[i] = non_common_schema_.size();
82 *non_common_schema_.Add() = schema.Get(i);
83 }
84 }
85
86 common_row_view_ = std::unique_ptr<::hybridse::sdk::RowIOBufView>(
87 new ::hybridse::sdk::RowIOBufView(common_schema_));
88 non_common_row_view_ = std::unique_ptr<::hybridse::sdk::RowIOBufView>(
89 new ::hybridse::sdk::RowIOBufView(non_common_schema_));
90
91 if (!common_schema_.empty()) {
92 uint32_t row_size = 0;
93 cntl_->response_attachment().copy_to(&row_size, 4, 2);
94 common_buf_size_ = row_size;
95 position_ = row_size;
96 cntl_->response_attachment().append_to(&common_buf_, row_size, 0);
97 common_row_view_->Reset(common_buf_);
98 }
99 return true;
100}
101
102bool SQLBatchRequestResultSet::IsNULL(int index) {
103 if (!IsValidColumnIdx(index)) {

Callers

nothing calls this directly

Calls 8

DecodeFunction · 0.85
codeMethod · 0.80
SetSchemaMethod · 0.80
insertMethod · 0.80
sizeMethod · 0.45
GetMethod · 0.45
emptyMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected