Skip to content
Closed
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
8 changes: 4 additions & 4 deletions src/paimon/common/data/binary_row_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ TEST_F(BinaryRowTest, TestBinary) {
auto pool = GetDefaultPool();
BinaryRow row(2);
BinaryRowWriter writer(&row, 0, pool.get());
char chars1[3] = {1, -1, 5};
char chars2[8] = {1, -1, 5, 5, 1, 5, 1, 5};
std::string str1(chars1, 3);
std::string str2(chars2, 8);
std::uint8_t chars1[3] = {1, 0xff, 5};
std::uint8_t chars2[8] = {1, 0xff, 5, 5, 1, 5, 1, 5};
std::string str1(reinterpret_cast<const char*>(chars1), 3);
std::string str2(reinterpret_cast<const char*>(chars2), 8);
Bytes bytes1(str1, pool.get());
Bytes bytes2(str2, pool.get());

Expand Down
9 changes: 5 additions & 4 deletions src/paimon/common/data/binary_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,17 @@ std::string BinaryString::ToString() const {
}

int32_t BinaryString::NumBytesForFirstByte(char b) {
if (b >= 0) {
const auto byte = static_cast<std::uint8_t>(b);
if ((byte & 0x80) == 0) {
// 1 byte, 7 bits: 0xxxxxxx
return 1;
} else if ((b >> 5) == -2 && (b & 0x1e) != 0) {
} else if ((byte & 0xe0) == 0xc0 && (byte & 0x1e) != 0) {
// 2 bytes, 11 bits: 110xxxxx 10xxxxxx
return 2;
} else if ((b >> 4) == -2) {
} else if ((byte & 0xf0) == 0xe0) {
// 3 bytes, 16 bits: 1110xxxx 10xxxxxx 10xxxxxx
return 3;
} else if ((b >> 3) == -2) {
} else if ((byte & 0xf8) == 0xf0) {
// 4 bytes, 21 bits: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
return 4;
} else {
Expand Down
53 changes: 28 additions & 25 deletions src/paimon/common/file_index/bitmap/bitmap_file_index_meta_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "paimon/common/file_index/bitmap/bitmap_file_index_meta.h"

#include <cstdint>
#include <map>
#include <memory>
#include <string>
Expand Down Expand Up @@ -67,13 +68,14 @@ TEST(BitmapFileIndexMetaTest, TestStringType) {
};
{
// test v1 version
std::vector<char> index_bytes = {
1, 0, 0, 0, 5, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 97, 0, 0, 0, 20, 0,
0, 0, 1, 98, -1, -1, -1, -3, 58, 48, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 16, 0, 0, 0,
1, 0, 3, 0, 58, 48, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 16, 0, 0, 0, 0, 0, 4, 0};

auto input_stream =
std::make_shared<ByteArrayInputStream>(index_bytes.data(), index_bytes.size());
std::vector<std::uint8_t> index_bytes = {
1, 0, 0, 0, 5, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1,
97, 0, 0, 0, 20, 0, 0, 0, 1, 98, 0xff, 0xff, 0xff, 0xfd, 58, 48, 0, 0,
1, 0, 0, 0, 0, 0, 1, 0, 16, 0, 0, 0, 1, 0, 3, 0, 58, 48,
0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 16, 0, 0, 0, 0, 0, 4, 0};

auto input_stream = std::make_shared<ByteArrayInputStream>(
reinterpret_cast<const char*>(index_bytes.data()), index_bytes.size());
// skip version
ASSERT_OK(input_stream->Seek(1, SeekOrigin::FS_SEEK_SET));
BitmapFileIndexMetaV1 index_meta(FieldType::STRING, 0, index_bytes.size(),
Expand All @@ -83,15 +85,16 @@ TEST(BitmapFileIndexMetaTest, TestStringType) {
}
{
// test v2 version
std::vector<char> index_bytes = {
2, 0, 0, 0, 5, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0,
1, 0, 0, 0, 1, 97, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 2, 0, 0, 0,
1, 97, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 1, 98, -1, -1, -1, -3, -1, -1,
-1, -1, 58, 48, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 16, 0, 0, 0, 1, 0, 3,
0, 58, 48, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 16, 0, 0, 0, 0, 0, 4, 0};

auto input_stream =
std::make_shared<ByteArrayInputStream>(index_bytes.data(), index_bytes.size());
std::vector<std::uint8_t> index_bytes = {
2, 0, 0, 0, 5, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 20,
0, 0, 0, 1, 0, 0, 0, 1, 97, 0, 0, 0, 0, 0, 0, 0, 30, 0,
0, 0, 2, 0, 0, 0, 1, 97, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0,
0, 1, 98, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff, 0xff, 0xff, 58, 48, 0, 0, 1, 0, 0,
0, 0, 0, 1, 0, 16, 0, 0, 0, 1, 0, 3, 0, 58, 48, 0, 0, 1,
0, 0, 0, 0, 0, 1, 0, 16, 0, 0, 0, 0, 0, 4, 0};

auto input_stream = std::make_shared<ByteArrayInputStream>(
reinterpret_cast<const char*>(index_bytes.data()), index_bytes.size());
// skip version
ASSERT_OK(input_stream->Seek(1, SeekOrigin::FS_SEEK_SET));
BitmapFileIndexMetaV2 index_meta(FieldType::STRING, index_bytes.size(), GetDefaultPool());
Expand All @@ -101,15 +104,15 @@ TEST(BitmapFileIndexMetaTest, TestStringType) {
}

TEST(BitmapFileIndexMetaTest, TestInvalidType) {
std::vector<char> index_bytes = {
2, 0, 0, 0, 5, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0,
1, 0, 0, 0, 1, 97, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 2, 0, 0, 0,
1, 97, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 1, 98, -1, -1, -1, -3, -1, -1,
-1, -1, 58, 48, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 16, 0, 0, 0, 1, 0, 3,
0, 58, 48, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 16, 0, 0, 0, 0, 0, 4, 0};

auto input_stream =
std::make_shared<ByteArrayInputStream>(index_bytes.data(), index_bytes.size());
std::vector<std::uint8_t> index_bytes = {
2, 0, 0, 0, 5, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0,
1, 0, 0, 0, 1, 97, 0, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 2, 0, 0, 0,
1, 97, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 1, 98, 0xff, 0xff, 0xff, 0xfd, 0xff, 0xff,
0xff, 0xff, 58, 48, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 16, 0, 0, 0, 1, 0, 3,
0, 58, 48, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 16, 0, 0, 0, 0, 0, 4, 0};

auto input_stream = std::make_shared<ByteArrayInputStream>(
reinterpret_cast<const char*>(index_bytes.data()), index_bytes.size());
// skip version
ASSERT_OK(input_stream->Seek(1, SeekOrigin::FS_SEEK_SET));
BitmapFileIndexMetaV2 index_meta(FieldType::DECIMAL, index_bytes.size(), GetDefaultPool());
Expand Down
Loading