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/src/encoding/decoder_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class DecoderFactory {

case RLE:
switch (data_type) {
case BOOLEAN:
case INT32:
case DATE:
ALLOC_AND_RETURN_DECODER(Int32RleDecoder);
Expand Down
8 changes: 8 additions & 0 deletions cpp/test/encoding/encoding_coverage_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <vector>

#include "common/allocator/byte_stream.h"
#include "encoding/decoder_factory.h"
#include "encoding/dictionary_decoder.h"
#include "encoding/dictionary_encoder.h"
#include "encoding/gorilla_decoder.h"
Expand All @@ -45,6 +46,13 @@

namespace storage {

TEST(EncodingCoverage, BooleanRleDecoderFactory) {
Decoder* decoder =
DecoderFactory::alloc_value_decoder(common::RLE, common::BOOLEAN);
ASSERT_NE(nullptr, decoder);
DecoderFactory::free(decoder);
}

// ── Type-mismatch returns ────────────────────────────────────────────────
//
// Every codec exposes read_boolean / read_int32 / read_int64 / read_float /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,10 @@ std::vector<FixtureCase> ReadManifest(const std::string& directory) {
void AssertValue(const FixtureCase& fixture_case, int row,
TableResultSet* result_set) {
switch (fixture_case.data_type) {
case BOOLEAN:
ASSERT_EQ(row % 192 < 64 ? row % 2 == 0 : row % 192 < 128,
result_set->get_value<bool>(3));
break;
case INT32:
ASSERT_EQ(IntValue(row), result_set->get_value<int32_t>(3));
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,30 @@ private static List<FixtureCase> buildMatrix() {
cases.add(new FixtureCase(dataType, compression, NULL_PAGE_ROWS, NullPattern.ALL));
}
}
// Java-only fixtures: exercise the default BOOLEAN encoding without requiring
// the C++ writer to support RLE booleans as well.
for (CompressionType compression :
Arrays.asList(
CompressionType.UNCOMPRESSED,
CompressionType.LZ4,
CompressionType.ZSTD,
CompressionType.LZMA2)) {
for (NullPattern pattern : NullPattern.values()) {
cases.add(
new FixtureCase(
FixtureCase.fileName(TSDataType.BOOLEAN, TSEncoding.RLE, compression)
+ ".default."
+ pattern.name().toLowerCase(Locale.ROOT),
TABLE_NAME,
TAG_COLUMN,
VALUE_COLUMN,
TSDataType.BOOLEAN,
TSEncoding.RLE,
compression,
NULL_PAGE_ROWS * 8,
pattern));
}
}
return cases;
}

Expand Down Expand Up @@ -423,19 +447,28 @@ private static TableSchema tableSchema(FixtureCase fixtureCase) {
if (isTs2DiffFloatCase(fixtureCase) && fixtureCase.fileName.endsWith(".mpn0")) {
props = Collections.singletonMap(Encoder.MAX_POINT_NUMBER, "0");
}
MeasurementSchema valueSchema;
if (fixtureCase.dataType == TSDataType.BOOLEAN) {
valueSchema = new MeasurementSchema(fixtureCase.valueColumn, TSDataType.BOOLEAN);
assertEquals("Java default BOOLEAN encoding", TSEncoding.RLE, valueSchema.getEncodingType());
valueSchema.setCompressionType(fixtureCase.compression);
} else {
valueSchema =
new MeasurementSchema(
fixtureCase.valueColumn,
fixtureCase.dataType,
fixtureCase.encoding,
fixtureCase.compression,
props);
}
List<IMeasurementSchema> schemas =
Arrays.asList(
new MeasurementSchema(
fixtureCase.tagColumn,
TSDataType.STRING,
TSEncoding.PLAIN,
CompressionType.UNCOMPRESSED),
new MeasurementSchema(
fixtureCase.valueColumn,
fixtureCase.dataType,
fixtureCase.encoding,
fixtureCase.compression,
props));
valueSchema);
List<ColumnCategory> categories =
new ArrayList<>(Arrays.asList(ColumnCategory.TAG, ColumnCategory.FIELD));
if (fixtureCase.nullPattern != NullPattern.NONE) {
Expand Down Expand Up @@ -474,6 +507,9 @@ private static Tablet tablet(TableSchema tableSchema, FixtureCase fixtureCase) {
private static void addValue(Tablet tablet, FixtureCase fixtureCase, int row) {
TSDataType dataType = fixtureCase.dataType;
switch (dataType) {
case BOOLEAN:
tablet.addValue(row, VALUE_COLUMN, booleanValue(row));
break;
case INT32:
tablet.addValue(row, VALUE_COLUMN, intValue(row));
break;
Expand All @@ -497,6 +533,9 @@ private static void addValue(Tablet tablet, FixtureCase fixtureCase, int row) {

private static void assertValue(FixtureCase fixtureCase, int row, ResultSet resultSet) {
switch (fixtureCase.dataType) {
case BOOLEAN:
assertEquals("BOOLEAN at row " + row, booleanValue(row), resultSet.getBoolean(3));
break;
case INT32:
assertEquals("INT32 at row " + row, intValue(row), resultSet.getInt(3));
break;
Expand Down Expand Up @@ -524,6 +563,11 @@ private static void assertValue(FixtureCase fixtureCase, int row, ResultSet resu
}
}

// Alternate bits and long true/false runs to cover both RLE packing modes.
private static boolean booleanValue(int row) {
return row % 192 < 64 ? row % 2 == 0 : row % 192 < 128;
}

private static int intValue(int row) {
return INT_VALUES[row % INT_VALUES.length];
}
Expand Down
Loading