Skip to content

Fix: Null value settings not applying correctly in tablet. - #15228

Merged
jt2594838 merged 1 commit into
apache:masterfrom
hongzhi-gao:fix/cpp_client_tablet_bitmap
Mar 31, 2025
Merged

Fix: Null value settings not applying correctly in tablet.#15228
jt2594838 merged 1 commit into
apache:masterfrom
hongzhi-gao:fix/cpp_client_tablet_bitmap

Conversation

@hongzhi-gao

@hongzhi-gaohongzhi-gao commented Mar 29, 2025

Copy link
Copy Markdown
Contributor

Description

Fixed an issue where tablet bitmap processing failed to handle null values correctly.

Implementation Details

  • The tablet's bitmap is serialized according to tablet.rowSize, not the full byte length.

Testing

  • Verified fix in test environment

This PR has:
• [x] been self-reviewed.

  • table model
 #include"TableSession.h"
#include"TableSessionBuilder.h"
#include<iostream>
#include<ostream>usingnamespacestd;
TableSession *session;
intmain() {
try {
session = (newTableSessionBuilder())->build();
try {
session->executeNonQueryStatement("CREATE DATABASE test_insert_db1");
session->executeNonQueryStatement("use test_insert_db1");
session->executeNonQueryStatement("CREATE TABLE t1 (tag1 STRING TAG,attr1 STRING ATTRIBUTE,s1 BOOLEAN FIELD,s2 INT32 FIELD,s3 INT64 FIELD,s4 FLOAT FIELD,s5 DOUBLE FIELD,s6 TEXT FIELD)");
// 构建Tablet
vector<pair<string, TSDataType::TSDataType>> schemaList {
make_pair("tag1", TSDataType::TEXT),
make_pair("attr1", TSDataType::TEXT),
make_pair("s1", TSDataType::BOOLEAN),
make_pair("s2", TSDataType::INT32),
make_pair("s3", TSDataType::INT64),
make_pair("s4", TSDataType::FLOAT),
make_pair("s5", TSDataType::DOUBLE),
make_pair("s6", TSDataType::TEXT)
};
vector<ColumnCategory> columnTypes = {
ColumnCategory::TAG,
ColumnCategory::ATTRIBUTE,
ColumnCategory::FIELD,
ColumnCategory::FIELD,
ColumnCategory::FIELD,
ColumnCategory::FIELD,
ColumnCategory::FIELD,
ColumnCategory::FIELD
};
Tablet tablet("t1", schemaList, columnTypes, 100);
// 写入包含时间戳的空值int64_t time = 0;
for (int row = 0; row < 10; row++) {
int rowIndex = tablet.rowSize++;
tablet.timestamps[rowIndex] = time++;
tablet.addValue("tag1", rowIndex, "tag1");
tablet.addValue("attr1", rowIndex, "attr1");
tablet.addValue("s1", rowIndex, true);
tablet.addValue("s2", rowIndex, row);
tablet.addValue("s3", rowIndex, int64_t(row));
tablet.addValue("s4", rowIndex, 111.1F);
tablet.addValue("s5", rowIndex, 111.1);
tablet.addValue("s6", rowIndex, "test");
if (row % 2 == 0) {
tablet.bitMaps[0].mark(row);
tablet.bitMaps[1].mark(row);
tablet.bitMaps[2].mark(row);
tablet.bitMaps[3].mark(row);
tablet.bitMaps[4].mark(row);
tablet.bitMaps[5].mark(row);
tablet.bitMaps[6].mark(row);
tablet.bitMaps[7].mark(row);
}
}
session->insert(tablet);
} catch (IoTDBException &e) {
cout << e.what() << endl;
}
session->close();
} catch (IoTDBConnectionException &e) {
cout << e.what() << endl;
}
return0;
}

image

  • tree model
 #include"Session.h"
#include<cstdint>usingnamespacestd;
Session *session;
intmain() {
session = newSession("127.0.0.1", 6667, "root", "root");
session->open(false);
session->createDatabase("root.test_db1");
// 创建对齐时间序列
vector<std::string> measurements;
measurements.push_back("s1");
measurements.push_back("s2");
measurements.push_back("s3");
measurements.push_back("s4");
measurements.push_back("s5");
measurements.push_back("s6");
vector<TSDataType::TSDataType> dataTypes;
dataTypes.push_back(TSDataType::BOOLEAN);
dataTypes.push_back(TSDataType::INT32);
dataTypes.push_back(TSDataType::INT64);
dataTypes.push_back(TSDataType::FLOAT);
dataTypes.push_back(TSDataType::DOUBLE);
dataTypes.push_back(TSDataType::TEXT);
vector<TSEncoding::TSEncoding> encodings;
encodings.push_back(TSEncoding::PLAIN);
encodings.push_back(TSEncoding::PLAIN);
encodings.push_back(TSEncoding::PLAIN);
encodings.push_back(TSEncoding::PLAIN);
encodings.push_back(TSEncoding::PLAIN);
encodings.push_back(TSEncoding::PLAIN);
vector<CompressionType::CompressionType> compressors;
compressors.push_back(CompressionType::LZ4);
compressors.push_back(CompressionType::LZ4);
compressors.push_back(CompressionType::LZ4);
compressors.push_back(CompressionType::LZ4);
compressors.push_back(CompressionType::LZ4);
compressors.push_back(CompressionType::LZ4);
// session->createAlignedTimeseries("root.test_db1.d1", measurements, dataTypes, encodings, compressors);// 创建非对齐时间序列
vector<string> paths;
paths.emplace_back("root.test_db1.d1.s1");
paths.emplace_back("root.test_db1.d1.s2");
paths.emplace_back("root.test_db1.d1.s3");
paths.emplace_back("root.test_db1.d1.s4");
paths.emplace_back("root.test_db1.d1.s5");
paths.emplace_back("root.test_db1.d1.s6");
vector<TSDataType::TSDataType> tsDataTypes;
tsDataTypes.push_back(TSDataType::BOOLEAN);
tsDataTypes.push_back(TSDataType::INT32);
tsDataTypes.push_back(TSDataType::INT64);
tsDataTypes.push_back(TSDataType::FLOAT);
tsDataTypes.push_back(TSDataType::DOUBLE);
tsDataTypes.push_back(TSDataType::TEXT);
vector<TSEncoding::TSEncoding> tsEncodings;
tsEncodings.push_back(TSEncoding::PLAIN);
tsEncodings.push_back(TSEncoding::PLAIN);
tsEncodings.push_back(TSEncoding::PLAIN);
tsEncodings.push_back(TSEncoding::PLAIN);
tsEncodings.push_back(TSEncoding::PLAIN);
tsEncodings.push_back(TSEncoding::PLAIN);
vector<CompressionType::CompressionType> compressionTypes;
compressionTypes.push_back(CompressionType::LZ4);
compressionTypes.push_back(CompressionType::LZ4);
compressionTypes.push_back(CompressionType::LZ4);
compressionTypes.push_back(CompressionType::LZ4);
compressionTypes.push_back(CompressionType::LZ4);
compressionTypes.push_back(CompressionType::LZ4);
session->createMultiTimeseries(paths, dataTypes, encodings, compressors, nullptr, nullptr, nullptr, nullptr);
// 构建tablet
pair<string, TSDataType::TSDataType> pairA("s1", TSDataType::BOOLEAN);
pair<string, TSDataType::TSDataType> pairB("s2", TSDataType::INT32);
pair<string, TSDataType::TSDataType> pairC("s3", TSDataType::INT64);
pair<string, TSDataType::TSDataType> pairD("s4", TSDataType::FLOAT);
pair<string, TSDataType::TSDataType> pairE("s5", TSDataType::DOUBLE);
pair<string, TSDataType::TSDataType> pairF("s6", TSDataType::TEXT);
vector<pair<string, TSDataType::TSDataType>> schemas;
schemas.push_back(pairA);
schemas.push_back(pairB);
schemas.push_back(pairC);
schemas.push_back(pairD);
schemas.push_back(pairE);
schemas.push_back(pairF);
Tablet tablet("root.test_db1.d1", schemas, 30);
// 写入数据int64_t time = 0;
for (int row = 0; row < 10; row++) {
int rowIndex = tablet.rowSize++;
tablet.timestamps[rowIndex] = time++;
tablet.addValue("s1", rowIndex, true);
tablet.addValue("s2", rowIndex, row);
tablet.addValue("s3", rowIndex, int64_t(row));
tablet.addValue("s4", rowIndex, 111.1F);
tablet.addValue("s5", rowIndex, 111.1);
tablet.addValue("s6", rowIndex, "text");
// 标记空值if (row % 2 == 0) {
tablet.bitMaps[0].mark(row);
tablet.bitMaps[1].mark(row);
tablet.bitMaps[2].mark(row);
tablet.bitMaps[3].mark(row);
tablet.bitMaps[4].mark(row);
tablet.bitMaps[5].mark(row);
}
}
// session->insertAlignedTablet(tablet, true);
session->insertTablet(tablet, true);
session->close();
}

image


Key changed/added classes
  • Tablet
  • Tablet Serialize

@github-actionsgithub-actionsBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, this is your first pull request in IoTDB project. Thanks for your contribution! IoTDB will be better because of you.

@jt2594838
jt2594838 merged commit bf2eee9 into apache:masterMar 31, 2025
JackieTien97 pushed a commit that referenced this pull request Apr 14, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@hongzhi-gao@jt2594838