Skip to content

Commit 9e1dce8

Browse files
committed
Fix compile
1 parent 70d2ef9 commit 9e1dce8

4 files changed

Lines changed: 25 additions & 12 deletions

File tree

cpp/src/encoding/dictionary_decoder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ class DictionaryDecoder : public Decoder {
7373
if (entry_index_.empty()) {
7474
init_map(buffer);
7575
}
76-
int code = value_decoder_.read_int(buffer);
76+
int32_t code = 0;
77+
value_decoder_.read_int(code, buffer);
7778
return entry_index_[code];
7879
}
7980

cpp/src/encoding/int32_sprintz_decoder.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ class Int32SprintzDecoder : public SprintzDecoder {
125125
decode_size_ = bit_width_ & ~(1 << 7);
126126
Int32RleDecoder decoder;
127127
for (int i = 0; i < decode_size_; ++i) {
128-
current_buffer_[i] = decoder.read_int(input);
128+
if (RET_FAIL(decoder.read_int(current_buffer_[i], input))) {
129+
return ret;
130+
}
129131
}
130132
} else {
131133
decode_size_ = block_size_ + 1;

cpp/src/encoding/int64_rle_decoder.h

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,38 +182,43 @@ class Int64RleDecoder : public Decoder {
182182
bitpacking_num_ = current_count_;
183183
is_rle_run_ = false;
184184
} else {
185-
printf(
186-
"tsfile-encoding IntRleDecoder: bit_packed_group_count %d, "
187-
"smaller "
188-
"than 1",
189-
bit_packed_group_count);
185+
return common::E_DECODE_ERR;
190186
}
191-
read_bit_packing_buffer(bit_packed_group_count, last_bit_packed_num);
187+
ret = read_bit_packing_buffer(bit_packed_group_count,
188+
last_bit_packed_num);
192189
return ret;
193190
}
194191

195-
void read_bit_packing_buffer(int bit_packed_group_count,
196-
int last_bit_packed_num) {
192+
int read_bit_packing_buffer(int bit_packed_group_count,
193+
int last_bit_packed_num) {
194+
int ret = common::E_OK;
197195
if (current_buffer_ != nullptr) {
198196
common::mem_free(current_buffer_);
199197
}
200198
current_buffer_ = static_cast<int64_t*>(
201199
common::mem_alloc(sizeof(int64_t) * bit_packed_group_count * 8,
202200
common::MOD_DECODER_OBJ));
201+
if (IS_NULL(current_buffer_)) {
202+
return common::E_OOM;
203+
}
203204
int bytes_to_read = bit_packed_group_count * bit_width_;
204205
if (bytes_to_read > (int)byte_cache_.remaining_size()) {
205206
bytes_to_read = byte_cache_.remaining_size();
206207
}
207208
std::vector<unsigned char> bytes(bytes_to_read);
208209

209210
for (int i = 0; i < bytes_to_read; i++) {
210-
common::SerializationUtil::read_ui8(bytes[i], byte_cache_);
211+
if (RET_FAIL(common::SerializationUtil::read_ui8(bytes[i],
212+
byte_cache_))) {
213+
return ret;
214+
}
211215
}
212216

213217
// save all int values in currentBuffer
214218
packer_->unpack_all_values(
215219
bytes.data(), bytes_to_read,
216220
current_buffer_); // decode from bytes, save in currentBuffer
221+
return ret;
217222
}
218223

219224
int read_length_and_bitwidth(common::ByteStream& buffer) {
@@ -222,6 +227,9 @@ class Int64RleDecoder : public Decoder {
222227
common::SerializationUtil::read_var_uint(length_, buffer))) {
223228
return common::E_PARTIAL_READ;
224229
} else {
230+
if (tmp_buf_) {
231+
common::mem_free(tmp_buf_);
232+
}
225233
tmp_buf_ =
226234
(uint8_t*)common::mem_alloc(length_, common::MOD_DECODER_OBJ);
227235
if (tmp_buf_ == nullptr) {

cpp/src/encoding/int64_sprintz_decoder.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ class Int64SprintzDecoder : public SprintzDecoder {
124124
decode_size_ = bit_width_ & ~(1 << 7);
125125
Int64RleDecoder decoder;
126126
for (int i = 0; i < decode_size_; ++i) {
127-
current_buffer_[i] = decoder.read_int(input);
127+
if (RET_FAIL(decoder.read_int(current_buffer_[i], input))) {
128+
return ret;
129+
}
128130
}
129131
} else {
130132
decode_size_ = block_size_ + 1;

0 commit comments

Comments
 (0)