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
9 changes: 5 additions & 4 deletions cpp/examples/c_examples/demo_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ERRNO read_tsfile() {
// Timestamp at column 1 and column index begin from 1.
Timestamp timestamp =
tsfile_result_set_get_value_by_index_int64_t(ret, 1);
printf("%ld\n", timestamp);
printf("%lld\n", (long long)timestamp);
for (int i = 1; i <= column_num; i++) {
if (tsfile_result_set_is_null_by_index(ret, i)) {
printf(" null ");
Expand All @@ -72,9 +72,10 @@ ERRNO read_tsfile() {
i));
break;
case TS_DATATYPE_INT64:
printf("%ld\n",
tsfile_result_set_get_value_by_index_int64_t(ret,
i));
printf("%lld\n",
(long long)
tsfile_result_set_get_value_by_index_int64_t(
ret, i));
break;
case TS_DATATYPE_FLOAT:
printf(
Expand Down
10 changes: 5 additions & 5 deletions cpp/src/encoding/float_sprintz_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,20 @@ class FloatSprintzDecoder : public SprintzDecoder {
predict_scheme_ = method;
}

int read_boolean(bool& ret_value, common::ByteStream& in) {
int read_boolean(bool& ret_value, common::ByteStream& in) override {
return common::E_TYPE_NOT_MATCH;
}
int read_int32(int32_t& ret_value, common::ByteStream& in) {
int read_int32(int32_t& ret_value, common::ByteStream& in) override {
return common::E_TYPE_NOT_MATCH;
}
int read_int64(int64_t& ret_value, common::ByteStream& in) {
int read_int64(int64_t& ret_value, common::ByteStream& in) override {
return common::E_TYPE_NOT_MATCH;
}
int read_double(double& ret_value, common::ByteStream& in) {
int read_double(double& ret_value, common::ByteStream& in) override {
return common::E_TYPE_NOT_MATCH;
}
int read_String(common::String& ret_value, common::PageArena& pa,
common::ByteStream& in) {
common::ByteStream& in) override {
return common::E_TYPE_NOT_MATCH;
}

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/encoding/gorilla_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class GorillaDecoder : public Decoder {

~GorillaDecoder() override = default;

void reset() {
void reset() override {
type_ = common::GORILLA;
stored_value_ = 0;
stored_leading_zeros_ = INT32_MAX;
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/encoding/int32_sprintz_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Int32SprintzDecoder : public SprintzDecoder {
predict_scheme_ = method;
}

bool has_remaining(const common::ByteStream& in) {
bool has_remaining(const common::ByteStream& in) override {
uint32_t min_len = sizeof(int32_t) + 1;
return (is_block_read_ && current_count_ < block_size_) ||
in.remaining_size() >= min_len;
Expand All @@ -79,7 +79,7 @@ class Int32SprintzDecoder : public SprintzDecoder {
return common::E_TYPE_NOT_MATCH;
}

int read_int32(int32_t& ret_value, common::ByteStream& in) {
int read_int32(int32_t& ret_value, common::ByteStream& in) override {
int ret = common::E_OK;
if (!is_block_read_) {
if (RET_FAIL(decode_block(in))) {
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/encoding/int64_sprintz_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Int64SprintzDecoder : public SprintzDecoder {
std::fill(current_buffer_.begin(), current_buffer_.end(), 0);
}

bool has_remaining(const common::ByteStream& in) {
bool has_remaining(const common::ByteStream& in) override {
return (is_block_read_ && current_count_ < block_size_) ||
in.has_remaining();
}
Expand Down
16 changes: 8 additions & 8 deletions cpp/src/encoding/ts2diff_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TS2DIFFDecoder : public Decoder {
TS2DIFFDecoder() { reset(); }
~TS2DIFFDecoder() override {}

void reset() {
void reset() override {
write_index_ = -1;
bits_left_ = 0;
stored_value_ = 0;
Expand All @@ -48,7 +48,7 @@ class TS2DIFFDecoder : public Decoder {
current_index_ = 0;
}

FORCE_INLINE bool has_remaining(const common::ByteStream& buffer) {
FORCE_INLINE bool has_remaining(const common::ByteStream& buffer) override {
if (buffer.has_remaining()) return true;
return bits_left_ != 0 || (current_index_ <= write_index_ &&
write_index_ != -1 && current_index_ != 0);
Expand Down Expand Up @@ -98,13 +98,13 @@ class TS2DIFFDecoder : public Decoder {
}

T decode(common::ByteStream& in);
int read_boolean(bool& ret_value, common::ByteStream& in);
int read_int32(int32_t& ret_value, common::ByteStream& in);
int read_int64(int64_t& ret_value, common::ByteStream& in);
int read_float(float& ret_value, common::ByteStream& in);
int read_double(double& ret_value, common::ByteStream& in);
int read_boolean(bool& ret_value, common::ByteStream& in) override;
int read_int32(int32_t& ret_value, common::ByteStream& in) override;
int read_int64(int64_t& ret_value, common::ByteStream& in) override;
int read_float(float& ret_value, common::ByteStream& in) override;
int read_double(double& ret_value, common::ByteStream& in) override;
int read_String(common::String& ret_value, common::PageArena& pa,
common::ByteStream& in);
common::ByteStream& in) override;

public:
T first_value_;
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/file/read_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ int ReadFile::open(const std::string& file_path) {
return ret;
}

int ReadFile::get_file_size(int32_t& file_size) {
int ReadFile::get_file_size(int64_t& file_size) {
struct stat s;
if (fstat(fd_, &s) < 0) {
LOGE("fstat error, file_path=" << file_path_.c_str() << "fd=" << fd_
<< "errno" << errno);
return E_FILE_STAT_ERR;
}
file_size = s.st_size;
file_size = static_cast<int64_t>(s.st_size);
return E_OK;
}

Expand Down Expand Up @@ -109,13 +109,13 @@ int ReadFile::check_file_magic() {
return ret;
}

int ReadFile::read(int32_t offset, char* buf, int32_t buf_size,
int ReadFile::read(int64_t offset, char* buf, int32_t buf_size,
int32_t& read_len) {
int ret = E_OK;
read_len = 0;
while (read_len < buf_size) {
ssize_t pread_size = ::pread(fd_, buf + read_len, buf_size - read_len,
offset + read_len);
static_cast<off_t>(offset + read_len));
if (pread_size < 0) {
ret = E_FILE_READ_ERR;
////log_err("tsfile reader error, file_path=%s, errno=%d",
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/file/read_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ class ReadFile {

int open(const std::string& file_path);
FORCE_INLINE bool is_opened() const { return fd_ > 0; }
FORCE_INLINE int32_t file_size() const { return file_size_; }
FORCE_INLINE int64_t file_size() const { return file_size_; }
FORCE_INLINE const std::string& file_path() const { return file_path_; }

/*
* try to reader @buf_size bytes from @offset of this file
* into @buf. @read_len return the actual len reader.
*/
int read(int32_t offset, char* buf, int32_t buf_size,
int read(int64_t offset, char* buf, int32_t buf_size,
int32_t& ret_read_len);
void close();

private:
int get_file_size(int32_t& file_size);
int get_file_size(int64_t& file_size);
int check_file_magic();

private:
Expand All @@ -59,7 +59,7 @@ class ReadFile {
private:
std::string file_path_;
int fd_;
int32_t file_size_;
int64_t file_size_;
};

} // end namespace storage
Expand Down
24 changes: 13 additions & 11 deletions cpp/src/file/tsfile_io_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,20 @@ int TsFileIOReader::load_tsfile_meta() {

int ret = E_OK;
uint32_t tsfile_meta_size = 0;
int32_t read_offset = 0;
int64_t read_offset = 0;
int32_t ret_read_len = 0;

// Step 1: reader the tsfile_meta_size
// 1.1 prepare reader buffer
int32_t alloc_size = UTIL_MIN(TSFILE_READ_IO_SIZE, file_size());
const int64_t fsize = file_size();
const int32_t alloc_size = static_cast<int32_t>(
UTIL_MIN(static_cast<int64_t>(TSFILE_READ_IO_SIZE), fsize));
char* read_buf = (char*)mem_alloc(alloc_size, MOD_TSFILE_READER);
if (IS_NULL(read_buf)) {
return E_OOM;
}
// 1.2 reader data from file
read_offset = file_size() - alloc_size;
read_offset = fsize - alloc_size;
ret_read_len = 0;
if (RET_FAIL(read_file_->read(read_offset, read_buf, alloc_size,
ret_read_len))) {
Expand Down Expand Up @@ -177,7 +179,7 @@ int TsFileIOReader::load_tsfile_meta() {
read_buf = old_read_buf;
ret = E_OOM;
} else if (RET_FAIL(read_file_->read(
file_size() - tsfile_meta_size -
fsize - tsfile_meta_size -
TAIL_MAGIC_AND_META_SIZE_SIZE,
read_buf, tsfile_meta_size, ret_read_len))) {
} else if (tsfile_meta_size != (uint32_t)ret_read_len) {
Expand Down Expand Up @@ -226,8 +228,8 @@ int TsFileIOReader::load_timeseries_index_for_ssi(
}
auto& pa = ssi->timeseries_index_pa_;

int start_offset = device_index_entry->get_offset(),
end_offset = device_ie_end_offset;
int64_t start_offset = device_index_entry->get_offset(),
end_offset = device_ie_end_offset;
ASSERT(start_offset < end_offset);
const int32_t read_size = end_offset - start_offset;
int32_t ret_read_len = 0;
Expand Down Expand Up @@ -387,8 +389,8 @@ int TsFileIOReader::load_all_measurement_index_entry(
return ret;
}

int TsFileIOReader::read_device_meta_index(int32_t start_offset,
int32_t end_offset,
int TsFileIOReader::read_device_meta_index(int64_t start_offset,
int64_t end_offset,
common::PageArena& pa,
MetaIndexNode*& device_meta_index,
bool leaf) {
Expand Down Expand Up @@ -428,8 +430,8 @@ int TsFileIOReader::get_timeseries_indexes(
return ret;
}

int start_offset = device_index_entry->get_offset(),
end_offset = device_ie_end_offset;
int64_t start_offset = device_index_entry->get_offset(),
end_offset = device_ie_end_offset;
ASSERT(start_offset < end_offset);
const int32_t read_size = end_offset - start_offset;
int32_t ret_read_len = 0;
Expand Down Expand Up @@ -577,7 +579,7 @@ int TsFileIOReader::get_time_column_metadata(
return ret;
}
char* ti_buf = nullptr;
int start_idx = 0, end_idx = 0;
int64_t start_idx = 0, end_idx = 0;
int ret_read_len = 0;
if (measurement_node->node_type_ == LEAF_MEASUREMENT) {
ByteStream buffer;
Expand Down
4 changes: 2 additions & 2 deletions cpp/src/file/tsfile_io_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class TsFileIOReader {

int get_chunk_metadata_list(IDeviceID device_id, std::string measurement,
std::vector<ChunkMeta*>& chunk_meta_list);
int read_device_meta_index(int32_t start_offset, int32_t end_offset,
int read_device_meta_index(int64_t start_offset, int64_t end_offset,
common::PageArena& pa,
MetaIndexNode*& device_meta_index, bool leaf);
int get_timeseries_indexes(
Expand All @@ -85,7 +85,7 @@ class TsFileIOReader {
common::PageArena& pa);

private:
FORCE_INLINE int32_t file_size() const { return read_file_->file_size(); }
FORCE_INLINE int64_t file_size() const { return read_file_->file_size(); }

int load_tsfile_meta();

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/reader/chunk_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ int ChunkReader::read_from_file_and_rewrap(int want_size) {
int ret = E_OK;
const int DEFAULT_READ_SIZE = 4096; // may use page_size + page_header_size
char* file_data_buf = in_stream_.get_wrapped_buf();
int offset = chunk_meta_->offset_of_chunk_header_ + chunk_visit_offset_;
int64_t offset = chunk_meta_->offset_of_chunk_header_ + chunk_visit_offset_;
int read_size =
(want_size < DEFAULT_READ_SIZE ? DEFAULT_READ_SIZE : want_size);
if (file_data_buf_size_ < read_size ||
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/reader/device_meta_iterator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ int DeviceMetaIterator::load_leaf_device(MetaIndexNode* meta_index_node) {
continue;
}
}
int32_t start_offset = child->get_offset();
int32_t end_offset = i + 1 < leaf_children.size()
int64_t start_offset = child->get_offset();
int64_t end_offset = i + 1 < leaf_children.size()
? leaf_children[i + 1]->get_offset()
: meta_index_node->end_offset_;
MetaIndexNode* child_node = nullptr;
Expand All @@ -104,8 +104,8 @@ int DeviceMetaIterator::load_internal_node(MetaIndexNode* meta_index_node) {

for (size_t i = 0; i < internal_children.size(); i++) {
std::shared_ptr<IMetaIndexEntry> child = internal_children[i];
int32_t start_offset = child->get_offset();
int32_t end_offset = (i + 1 < internal_children.size())
int64_t start_offset = child->get_offset();
int64_t end_offset = (i + 1 < internal_children.size())
? internal_children[i + 1]->get_offset()
: meta_index_node->end_offset_;

Expand Down
2 changes: 1 addition & 1 deletion cpp/src/reader/filter/tag_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace storage {

// TagFilter base class implementation
TagFilter::TagFilter(int col_idx, std::string tag_value)
: col_idx_(col_idx), value_(std::move(tag_value)), value2_("") {}
: value_(std::move(tag_value)), value2_(""), col_idx_(col_idx) {}

TagFilter::~TagFilter() = default;

Expand Down
3 changes: 2 additions & 1 deletion cpp/src/reader/filter/tag_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class TagFilter : public Filter {
TagFilter(int col_idx, std::string tag_value);
~TagFilter() override;

virtual bool satisfyRow(int time, std::vector<std::string*> segments) const;
bool satisfyRow(int time,
std::vector<std::string*> segments) const override;
virtual bool satisfyRow(std::vector<std::string*> segments) const;

std::string value_;
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/writer/chunk_writer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int ChunkWriter::end_encode_chunk() {
chunk_header_.data_size_ = chunk_data_.total_size();
chunk_header_.num_of_pages_ = num_of_pages_;
}
} else if (first_page_statistic_ != nullptr) {
} else if (first_page_statistic_->count_ != 0) {
ret = write_first_page_data(chunk_data_, false);
if (E_OK == ret) {
free_first_writer_data();
Expand Down
5 changes: 1 addition & 4 deletions cpp/src/writer/chunk_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,7 @@ class ChunkWriter {
FORCE_INLINE void free_first_writer_data() {
// free memory
first_page_data_.destroy();
if (first_page_statistic_ != nullptr) {
StatisticFactory::free(first_page_statistic_);
first_page_statistic_ = nullptr;
}
first_page_statistic_->reset();
}
int seal_cur_page(bool end_chunk);
void save_first_page_data(PageWriter& first_page_writer);
Expand Down
Loading
Loading