Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpp/examples/cpp_examples/demo_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ int demo_read() {
while ((code = ret->next(has_next)) == common::E_OK && has_next) {
// Timestamp at column 1 and column index begin from 1.
Timestamp timestamp = ret->get_value<Timestamp>(1);
std::cout << timestamp << std::endl;
for (int i = 1; i <= column_num; i++) {
if (ret->is_null(i)) {
std::cout << "null" << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/cwrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ under the License.
]]
message("Running in cwrapper directory")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
aux_source_directory(. CWRAPPER_SRC_LIST)
set(CWRAPPER_SRC_LIST tsfile_cwrapper.cc)
add_library(cwrapper_obj OBJECT ${CWRAPPER_SRC_LIST})

# install header files
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/cwrapper/tsfile_cwrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -431,15 +431,15 @@ ResultSetMetaData tsfile_result_set_get_metadata(ResultSet result_set) {

char *tsfile_result_set_metadata_get_column_name(ResultSetMetaData result_set,
uint32_t column_index) {
if (column_index > result_set.column_num) {
if (column_index > (uint32_t)result_set.column_num) {
return nullptr;
}
return result_set.column_names[column_index - 1];
}

TSDataType tsfile_result_set_metadata_get_data_type(
ResultSetMetaData result_set, uint32_t column_index) {
if (column_index > result_set.column_num) {
if (column_index > (uint32_t)result_set.column_num) {
return TS_DATATYPE_INVALID;
}
return result_set.data_types[column_index - 1];
Expand Down
1 change: 0 additions & 1 deletion cpp/src/encoding/dictionary_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class DictionaryDecoder : public Decoder {
}
int read_String(common::String &ret_value, common::PageArena &pa,
common::ByteStream &in) {
int ret = common::E_OK;
auto std_str = read_string(in);
return ret_value.dup_from(std_str, pa);
}
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/encoding/double_sprintz_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class DoubleSprintzDecoder : public SprintzDecoder {
}
}
ret_value = current_buffer_[current_count_++];
if (current_count_ == decode_size_) {
if (current_count_ == (size_t)decode_size_) {
is_block_read_ = false;
current_count_ = 0;
}
Expand All @@ -100,7 +100,7 @@ class DoubleSprintzDecoder : public SprintzDecoder {
}

bool has_remaining(const common::ByteStream& input) override {
int min_length = sizeof(uint32_t) + 1;
uint32_t min_length = sizeof(uint32_t) + 1;
return (is_block_read_ && current_count_ < decode_size_) ||
input.remaining_size() >= min_length;
}
Expand All @@ -121,7 +121,7 @@ class DoubleSprintzDecoder : public SprintzDecoder {
if ((bit_width_ & (1 << 7)) != 0) {
decode_size_ = bit_width_ & ~(1 << 7);
DoubleGorillaDecoder decoder;
for (int i = 0; i < decode_size_; ++i) {
for (size_t i = 0; i < decode_size_; ++i) {
if (RET_FAIL(decoder.read_double(current_buffer_[i], input))) {
return ret;
}
Expand Down Expand Up @@ -208,7 +208,7 @@ class DoubleSprintzDecoder : public SprintzDecoder {
double pre_value_;
double current_value_;
size_t current_count_;
int decode_size_;
size_t decode_size_;
bool is_block_read_ = false;

std::vector<double> current_buffer_;
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/encoding/double_sprintz_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class DoubleSprintzEncoder : public SprintzEncoder {
}
values_.push_back(value);

if (values_.size() == block_size_ + 1) {
if (values_.size() == (size_t)block_size_ + 1) {
fire_pred_.reset();
for (int i = 1; i <= block_size_; ++i) {
convert_buffer_[i - 1] = predict(values_[i], values_[i - 1]);
Expand Down Expand Up @@ -149,7 +149,7 @@ class DoubleSprintzEncoder : public SprintzEncoder {
int64_t predict(double value, double prev) {
int64_t curr_bits = common::double_to_long(value);
int64_t prev_bits = common::double_to_long(prev);
int64_t raw_pred;
int64_t raw_pred = 0;
if (predict_method_ == "delta") {
raw_pred = curr_bits - prev_bits;
} else if (predict_method_ == "fire") {
Expand Down
6 changes: 3 additions & 3 deletions cpp/src/encoding/float_sprintz_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class FloatSprintzDecoder : public SprintzDecoder {
}

bool has_remaining(const common::ByteStream &input) override {
int min_length = sizeof(uint32_t) + 1;
size_t min_length = sizeof(uint32_t) + 1;
return (is_block_read_ && current_count_ < decode_size_) ||
input.remaining_size() >= min_length;
}
Expand Down Expand Up @@ -122,7 +122,7 @@ class FloatSprintzDecoder : public SprintzDecoder {
if ((bit_width_ & (1 << 7)) != 0) {
decode_size_ = bit_width_ & ~(1 << 7);
FloatGorillaDecoder decoder;
for (int i = 0; i < decode_size_; ++i) {
for (size_t i = 0; i < decode_size_; ++i) {
if (RET_FAIL(decoder.read_float(current_buffer_[i], input))) {
return ret;
}
Expand Down Expand Up @@ -221,7 +221,7 @@ class FloatSprintzDecoder : public SprintzDecoder {
float pre_value_;
float current_value_;
size_t current_count_;
int decode_size_;
size_t decode_size_;
bool is_block_read_ = false;

std::vector<float> current_buffer_;
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/encoding/float_sprintz_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class FloatSprintzEncoder : public SprintzEncoder {
}
values_.push_back(value);

if (values_.size() == block_size_ + 1) {
if (values_.size() == (size_t)block_size_ + 1) {
fire_pred_.reset();
for (int i = 1; i <= block_size_; ++i) {
convert_buffer_[i - 1] = predict(values_[i], values_[i - 1]);
Expand Down Expand Up @@ -147,7 +147,7 @@ class FloatSprintzEncoder : public SprintzEncoder {
int32_t predict(float value, float prev_value) {
int32_t curr_bits = common::float_to_int(value);
int32_t prev_bits = common::float_to_int(prev_value);
int32_t raw_pred;
int32_t raw_pred = 0;
if (predict_method_ == "delta") {
raw_pred = curr_bits - prev_bits;
} else if (predict_method_ == "fire") {
Expand Down
10 changes: 5 additions & 5 deletions cpp/src/encoding/int32_sprintz_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ namespace storage {
class Int32SprintzDecoder : public SprintzDecoder {
public:
Int32SprintzDecoder()
: current_value_(0),
: fire_pred_(2),
pre_value_(0),
current_value_(0),
current_buffer_(block_size_ + 1),
fire_pred_(2),
predict_scheme_("fire") {
SprintzDecoder::reset();
current_value_ = 0;
Expand All @@ -56,7 +56,7 @@ class Int32SprintzDecoder : public SprintzDecoder {
}

bool has_remaining(const common::ByteStream &in) {
int min_len = sizeof(int32_t) + 1;
uint32_t min_len = sizeof(int32_t) + 1;
return (is_block_read_ && current_count_ < block_size_) ||
in.remaining_size() >= min_len;
}
Expand Down Expand Up @@ -103,9 +103,9 @@ class Int32SprintzDecoder : public SprintzDecoder {
}

bool has_next(common::ByteStream &input) {
int min_lenth = sizeof(int32_t) + 1;
uint32_t min_length = sizeof(int32_t) + 1;
return (is_block_read_ && current_count_ < block_size_) ||
input.remaining_size() >= min_lenth;
input.remaining_size() >= min_length;
}

protected:
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/encoding/int32_sprintz_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class Int32SprintzEncoder : public SprintzEncoder {

values_.push_back(value);

if (values_.size() == block_size_ + 1) {
if (values_.size() == (size_t)block_size_ + 1) {
int32_t prev = values_[0];
fire_pred_.reset();
for (int i = 1; i <= block_size_; ++i) {
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/encoding/int64_sprintz_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ namespace storage {
class Int64SprintzDecoder : public SprintzDecoder {
public:
Int64SprintzDecoder()
: current_value_(0),
: fire_pred_(3),
pre_value_(0),
current_value_(0),
current_buffer_(block_size_ + 1),
fire_pred_(3),
predict_scheme_("fire") {
SprintzDecoder::reset();
current_count_ = 0;
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/encoding/int64_sprintz_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class Int64SprintzEncoder : public SprintzEncoder {

values_.push_back(value);

if (values_.size() == block_size_ + 1) {
if (values_.size() == (size_t)block_size_ + 1) {
int64_t prev = values_[0];
fire_pred_.reset();
for (int i = 1; i <= block_size_; ++i) {
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/encoding/sprintz_encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class SprintzEncoder : public Encoder {
group_num_(0),
bit_width_(0),
byte_cache_(1024, common::MOD_ENCODER_OBJ),
is_first_cached_(false),
predict_method_("fire") {}
predict_method_("fire"),
is_first_cached_(false) {}

protected:
int block_size_; // Size of each compressed block, default 8
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/writer/tsfile_table_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int storage::TsFileTableWriter::write_table(storage::Tablet& tablet) const {
return common::E_TABLE_NOT_EXIST;
}
tablet.set_table_name(to_lower(tablet.get_table_name()));
for (int i = 0; i < tablet.get_column_count(); i++) {
for (size_t i = 0; i < tablet.get_column_count(); i++) {
tablet.set_column_name(i, to_lower(tablet.get_column_name(i)));
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/test/common/datatype/date_converter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ TEST_F(DateConverterTest, IntToDateValidDate) {
// Test round-trip conversion consistency
TEST_F(DateConverterTest, RoundTripConversion) {
std::tm tm_result = {0};
int32_t int_result;
int32_t int_result = 0;

// Forward conversion then backward conversion
ASSERT_EQ(DateConverter::date_to_int(valid_tm_, int_result), common::E_OK);
Expand Down
2 changes: 1 addition & 1 deletion cpp/test/reader/table_view/tsfile_reader_table_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ TEST_F(TsFileTableReaderTest, TableModelQueryWithMultiTabletsMultiFlush) {
while (IS_SUCC(table_result_set->next(has_next)) && has_next) {
for (int i = 0; i < 1; i++) {
auto column_schemas = tmp_table_schema->get_measurement_schemas();
for (int j = 0; j < column_schemas.size(); j++) {
for (size_t j = 0; j < column_schemas.size(); j++) {
switch (column_schemas[j]->data_type_) {
case TSDataType::INT64:
ASSERT_EQ(table_result_set->get_value<int64_t>(j + 2),
Expand Down
18 changes: 6 additions & 12 deletions cpp/test/writer/table_view/tsfile_writer_table_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ TEST_F(TsFileWriterTableTest, WritehDataTypeMisMatch) {
int row_index = i * num_timestamp_per_device + l;
tablet.add_timestamp(row_index, offset + l);
auto column_schemas = table_schema->get_measurement_schemas();
for (int idx = 0; idx < column_schemas.size(); idx++) {
for (size_t idx = 0; idx < column_schemas.size(); idx++) {
switch (datatypes[idx]) {
case TSDataType::INT64:
tablet.add_value(row_index,
Expand Down Expand Up @@ -779,7 +779,7 @@ TEST_F(TsFileWriterTableTest, MultiDatatypes) {
std::vector<common::TSDataType> data_types = {
FLOAT, INT64, BOOLEAN, DOUBLE, STRING, TIMESTAMP, TEXT, BLOB, DATE};

for (int i = 0; i < measurement_names.size(); i++) {
for (size_t i = 0; i < measurement_names.size(); i++) {
measurement_schemas.emplace_back(
new MeasurementSchema(measurement_names[i], data_types[i]));
column_categories.emplace_back(ColumnCategory::FIELD);
Expand All @@ -803,7 +803,7 @@ TEST_F(TsFileWriterTableTest, MultiDatatypes) {
today.tm_mday = local_time->tm_mday;
for (int i = 0; i < 100; i++) {
tablet.add_timestamp(i, static_cast<int64_t>(time++));
for (int j = 0; j < measurement_schemas.size(); j++) {
for (size_t j = 0; j < measurement_schemas.size(); j++) {
switch (data_types[j]) {
case BOOLEAN:
ASSERT_EQ(tablet.add_value(i, j, true), E_OK);
Expand Down Expand Up @@ -850,10 +850,8 @@ TEST_F(TsFileWriterTableTest, MultiDatatypes) {

auto table_result_set = (TableResultSet*)ret;
bool has_next = false;
int cur_line = 0;
auto schema = table_result_set->get_metadata();
while (IS_SUCC(table_result_set->next(has_next)) && has_next) {
int64_t timestamp = table_result_set->get_value<int64_t>(1);
ASSERT_EQ(table_result_set->get_value<float>(2), (float)1.0);
ASSERT_EQ(table_result_set->get_value<int64_t>(3), (int64_t)415412);
ASSERT_EQ(table_result_set->get_value<bool>(4), true);
Expand All @@ -880,8 +878,6 @@ TEST_F(TsFileWriterTableTest, DiffCodecTypes) {
std::vector<MeasurementSchema*> measurement_schemas;
std::vector<ColumnCategory> column_categories;

common::CompressionType compression_type =
common::CompressionType::UNCOMPRESSED;
std::vector<std::string> measurement_names = {
"int32_zigzag", "int64_zigzag", "string_dic", "text_dic",
"float_gorilla", "double_gorilla", "int32_ts2diff", "int64_ts2diff",
Expand All @@ -895,7 +891,7 @@ TEST_F(TsFileWriterTableTest, DiffCodecTypes) {
ZIGZAG, ZIGZAG, DICTIONARY, DICTIONARY, GORILLA, GORILLA, TS_2DIFF,
TS_2DIFF, RLE, RLE, SPRINTZ, SPRINTZ, SPRINTZ, SPRINTZ};

for (int i = 0; i < measurement_names.size(); i++) {
for (size_t i = 0; i < measurement_names.size(); i++) {
measurement_schemas.emplace_back(new MeasurementSchema(
measurement_names[i], data_types[i], encodings[i], UNCOMPRESSED));
column_categories.emplace_back(ColumnCategory::FIELD);
Expand All @@ -913,7 +909,7 @@ TEST_F(TsFileWriterTableTest, DiffCodecTypes) {
String literal_str(literal, std::strlen("device_id"));
for (int i = 0; i < 100; i++) {
tablet.add_timestamp(i, static_cast<int64_t>(time++));
for (int j = 0; j < measurement_schemas.size(); j++) {
for (size_t j = 0; j < measurement_schemas.size(); j++) {
std::string measurement_name = measurement_names[j];
switch (data_types[j]) {
case BOOLEAN:
Expand Down Expand Up @@ -955,10 +951,8 @@ TEST_F(TsFileWriterTableTest, DiffCodecTypes) {

auto table_result_set = (TableResultSet*)ret;
bool has_next = false;
int cur_line = 0;
auto schema = table_result_set->get_metadata();
while (IS_SUCC(table_result_set->next(has_next)) && has_next) {
int64_t timestamp = table_result_set->get_value<int64_t>(1);
ASSERT_EQ(table_result_set->get_value<int32_t>(2), 32);
ASSERT_EQ(table_result_set->get_value<int64_t>(3), 64);

Expand Down Expand Up @@ -1017,7 +1011,7 @@ TEST_F(TsFileWriterTableTest, EncodingConfigIntegration) {
SPRINTZ, TS_2DIFF, GORILLA, GORILLA, DICTIONARY, PLAIN, DICTIONARY};

// Create measurement schemas with configured encodings and compression
for (int i = 0; i < measurement_names.size(); i++) {
for (size_t i = 0; i < measurement_names.size(); i++) {
measurement_schemas.emplace_back(new MeasurementSchema(
measurement_names[i], data_types[i], encodings[i], SNAPPY));
column_categories.emplace_back(ColumnCategory::FIELD);
Expand Down
2 changes: 1 addition & 1 deletion cpp/test/writer/tsfile_writer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ TEST_F(TsFileWriterTest, WriteDiffrentTypeCombination) {
std::strcpy(literal, "literal");
String literal_str(literal, std::strlen("literal"));

for (int i = 0; i < schema_vecs.size(); ++i) {
for (size_t i = 0; i < schema_vecs.size(); ++i) {
TsRecord record(1622505600000 + i * 1000, device_path);
if (schema_vecs[i].data_type_ == TSDataType::INT32) {
record.add_point(schema_vecs[i].measurement_name_, (int32_t)i);
Expand Down
Loading