Skip to content
Open
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
4 changes: 4 additions & 0 deletions compat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ cartesian product of every data type and encoding the local writer supports and
fails when the spec does not cover it. That is what keeps the matrix complete
as new encodings are added.

ALP is currently readable by Java for FLOAT and DOUBLE files written by C++.
Java does not encode ALP, so its matrix rows declare `javaWrite=no` while
retaining `javaRead=yes`.

## Data scale and page-size tiers

Every (type, encoding, compression) combination is generated at four data
Expand Down
17 changes: 13 additions & 4 deletions compat/compatibility-matrix.csv
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@
# when one block spans INT_MIN and INT_MAX, so SPRINTZ rows use the
# 'sprintz' profile (values within +/-1e9). Streaming numeric extremes are
# covered under PLAIN, RLE, TS_2DIFF, GORILLA, CHIMP and RLBE.
# - ALP (encoding id 15): C++/Python-only for now. The Java implementation
# has no ALP decoder, so this matrix declares no ALP rows and the C++
# completeness sweep stops at CAMEL. Add ALP rows and extend that bound
# only together with the Java decoder.
# - ALP (encoding id 15): Java can decode C++-written ALP files for FLOAT
# and DOUBLE, but Java does not provide an ALP encoder. ALP rows therefore
# declare javaWrite=no while keeping Java reads enabled.

id,model,dataType,encoding,compressions,rowCount,pageRows,chunks,devices,valueProfile,nullPatterns,javaWrite,cppWrite,javaRead,cppRead,gapReason,timestampProfile
table_int32_plain_r10,table,INT32,PLAIN,ALL,10,4,1,1,default,NONE,yes,yes,yes,yes,
Expand Down Expand Up @@ -210,6 +209,10 @@ table_float_rlbe_r10,table,FLOAT,RLBE,ALL,10,4,1,1,default,NONE,yes,yes,yes,yes,
table_float_rlbe_r1000,table,FLOAT,RLBE,ALL,1000,100,1,1,default,NONE,yes,yes,yes,yes,
table_float_rlbe_r100000,table,FLOAT,RLBE,ALL,100000,10000,1,1,default,NONE,yes,yes,yes,yes,
table_float_rlbe_r1000000,table,FLOAT,RLBE,SNAPPY+GZIP+LZ4+ZSTD+LZMA2,1000000,10000,1,1,default,NONE,yes,yes,yes,yes,
table_float_alp_r10,table,FLOAT,ALP,ALL,10,4,1,1,default,NONE,no,yes,yes,yes,Java supports ALP decoding only; it has no ALP encoder.
table_float_alp_r1000,table,FLOAT,ALP,ALL,1000,100,1,1,default,NONE,no,yes,yes,yes,Java supports ALP decoding only; it has no ALP encoder.
table_float_alp_r100000,table,FLOAT,ALP,ALL,100000,10000,1,1,default,NONE,no,yes,yes,yes,Java supports ALP decoding only; it has no ALP encoder.
table_float_alp_r1000000,table,FLOAT,ALP,SNAPPY+GZIP+LZ4+ZSTD+LZMA2,1000000,10000,1,1,default,NONE,no,yes,yes,yes,Java supports ALP decoding only; it has no ALP encoder.
table_float_rle_r10,table,FLOAT,RLE,ALL,10,4,1,1,runs,NONE,yes,yes,yes,yes,
table_float_rle_r1000,table,FLOAT,RLE,ALL,1000,100,1,1,runs,NONE,yes,yes,yes,yes,
table_float_rle_r100000,table,FLOAT,RLE,ALL,100000,10000,1,1,runs,NONE,yes,yes,yes,yes,
Expand Down Expand Up @@ -251,6 +254,10 @@ table_double_camel_r10,table,DOUBLE,CAMEL,ALL,10,4,1,1,default,NONE,yes,yes,yes,
table_double_camel_r1000,table,DOUBLE,CAMEL,ALL,1000,100,1,1,default,NONE,yes,yes,yes,yes,
table_double_camel_r100000,table,DOUBLE,CAMEL,ALL,100000,10000,1,1,default,NONE,yes,yes,yes,yes,
table_double_camel_r1000000,table,DOUBLE,CAMEL,SNAPPY+GZIP+LZ4+ZSTD+LZMA2,1000000,10000,1,1,default,NONE,yes,yes,yes,yes,
table_double_alp_r10,table,DOUBLE,ALP,ALL,10,4,1,1,default,NONE,no,yes,yes,yes,Java supports ALP decoding only; it has no ALP encoder.
table_double_alp_r1000,table,DOUBLE,ALP,ALL,1000,100,1,1,default,NONE,no,yes,yes,yes,Java supports ALP decoding only; it has no ALP encoder.
table_double_alp_r100000,table,DOUBLE,ALP,ALL,100000,10000,1,1,default,NONE,no,yes,yes,yes,Java supports ALP decoding only; it has no ALP encoder.
table_double_alp_r1000000,table,DOUBLE,ALP,SNAPPY+GZIP+LZ4+ZSTD+LZMA2,1000000,10000,1,1,default,NONE,no,yes,yes,yes,Java supports ALP decoding only; it has no ALP encoder.
table_double_rle_r10,table,DOUBLE,RLE,ALL,10,4,1,1,runs,NONE,yes,yes,yes,yes,
table_double_rle_r1000,table,DOUBLE,RLE,ALL,1000,100,1,1,runs,NONE,yes,yes,yes,yes,
table_double_rle_r100000,table,DOUBLE,RLE,ALL,100000,10000,1,1,runs,NONE,yes,yes,yes,yes,
Expand Down Expand Up @@ -348,3 +355,5 @@ table_multi_chunk_group,table,INT32,RLE,ALL,50,0,1,3,runs,NONE,yes,yes,yes,yes,
table_long_runs,table,INT64,RLE,ALL,1024,0,1,1,runs,NONE,yes,yes,yes,yes,
table_int32_plain_dups,table,INT32,PLAIN,UNCOMPRESSED,10,4,1,1,default,NONE,yes,yes,yes,yes,,duplicates
tree_int32_plain_dups,tree,INT32,PLAIN,UNCOMPRESSED,10,4,1,1,default,NONE,yes,yes,yes,yes,,duplicates
tree_float_alp_dups,tree,FLOAT,ALP,UNCOMPRESSED,10,4,1,1,default,NONE,no,yes,yes,yes,Java supports ALP decoding only; it has no ALP encoder.,duplicates
tree_double_alp_dups,tree,DOUBLE,ALP,UNCOMPRESSED,10,4,1,1,default,NONE,no,yes,yes,yes,Java supports ALP decoding only; it has no ALP encoder.,duplicates
15 changes: 5 additions & 10 deletions cpp/docs/alp-codec-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,11 @@ Status: draft for the C++-first implementation on `colin/alp-codec`.
- The existing Gorilla default is preserved. A column selects ALP by asking
for `TSEncoding::ALP`; there is no build flag. Readers that predate the
encoding reject the chunk instead of misreading it.
- **Java compatibility warning.** ALP is C++/Python-only for now. The Java
implementation has no `ALP` enum value, so a Java reader opens a file that
contains an ALP chunk but fails when it parses that chunk header (an
`IllegalArgumentException` naming the unknown encoding byte). Do not enable
ALP for files that are read by Java, and do not mix ALP and non-ALP writers
in a deployment that requires cross-language reads. The compatibility matrix
(`compat/compatibility-matrix.csv`) intentionally has no ALP rows until a
Java decoder exists.
- The format is language-neutral so a Java decoder can be added later without
changing encoded bytes.
- Java readers support ALP v1 decoding for FLOAT and DOUBLE; Java writers do
not encode ALP. The compatibility matrix (`compat/compatibility-matrix.csv`)
declares C++-written ALP cases and validates them with Java.
- The format is language-neutral, so the read-only Java decoder consumes the
same encoded bytes produced by C++ and Python.
- Python reuses the C++ implementation through the C wrapper.

## Relationship to TS_2DIFF
Expand Down
5 changes: 2 additions & 3 deletions cpp/src/common/db_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ enum TSEncoding : uint8_t {
SPRINTZ = 12,
RLBE = 13,
CAMEL = 14,
// C++/Python-only for now: the Java implementation has no ALP decoder.
// Java can open a file containing an ALP chunk, but any query that reads
// that series fails. Do not enable ALP for files shared with Java.
// C++/Python writers and C++/Java readers support ALP. Java currently
// provides decoding only; Java writers do not encode ALP.
ALP = 15,
INVALID_ENCODING = 255
};
Expand Down
8 changes: 3 additions & 5 deletions cpp/src/cwrapper/tsfile_cwrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ typedef enum {
TS_ENCODING_SPRINTZ = 12,
TS_ENCODING_RLBE = 13,
TS_ENCODING_CAMEL = 14,
/* C++/Python-only for now: the Java implementation has no ALP decoder.
* A file containing an ALP chunk opens in Java, but reading that series
* fails. Do not write ALP into files consumed by Java. */
/* Java supports read-only ALP decoding for FLOAT and DOUBLE. */
TS_ENCODING_ALP = 15,
TS_ENCODING_INVALID = 255
} TSEncoding;
Expand Down Expand Up @@ -473,8 +471,8 @@ int set_global_time_compression(uint8_t compression);
* - FLOAT: PLAIN, TS_2DIFF, GORILLA, SPRINTZ, CHIMP, RLBE, ALP
* - DOUBLE: PLAIN, TS_2DIFF, GORILLA, SPRINTZ, CHIMP, RLBE, CAMEL, ALP
* - STRING: PLAIN, DICTIONARY
* @warning ALP is C++/Python-only for now. A file written with ALP cannot be
* read by the Java implementation.
* @note Java can read ALP-encoded FLOAT and DOUBLE data but does not encode
* ALP.
*/
int set_datatype_encoding(uint8_t data_type, uint8_t encoding);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ std::vector<std::string> Split(const std::string& line, char delimiter) {
}

bool ParseEncodingName(const std::string& value, TSEncoding& out) {
for (int encoding = PLAIN; encoding <= CAMEL; ++encoding) {
for (int encoding = PLAIN; encoding <= ALP; ++encoding) {
TSEncoding candidate = static_cast<TSEncoding>(encoding);
if (value == get_encoding_name(candidate)) {
out = candidate;
Expand Down Expand Up @@ -1926,14 +1926,12 @@ TEST_F(EncodingCompressionCompatibilityTest, SpecMatchesCppCapabilities) {
ASSERT_FALSE(available_compressions.empty());

int missing = 0;
// Only the table model is exercised by the cross-language matrix.
// Only the table model has a complete capability matrix.
for (Model model : {Model::TABLE}) {
for (TSDataType data_type : kMatrixDataTypes) {
// The upper bound stops at CAMEL on purpose: ALP (15) is
// C++/Python-only and has no matrix rows until the Java
// implementation gains an ALP decoder. Extend this bound together
// with the Java decoder and the corresponding matrix rows.
for (int e = PLAIN; e <= CAMEL; e++) {
// Keep this sweep in sync with the Java-readable and C++-writable
// encodings declared in compatibility-matrix.csv.
for (int e = PLAIN; e <= ALP; e++) {
TSEncoding encoding = static_cast<TSEncoding>(e);
const bool can_write = EncoderSupported(encoding, data_type);
const bool can_read = DecoderSupported(encoding, data_type);
Expand Down
7 changes: 4 additions & 3 deletions cpp/tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ including ALP and GORILLA_V1 for FLOAT/DOUBLE, and RLE for BOOLEAN/FLOAT/DOUBLE.
GORILLA_V1 reserves NaN as its end marker: CSV NaN values are rejected with the
column and line number, without committing output; NULL and infinities remain valid.
FLOAT/DOUBLE RLE follows the SDK's two-decimal scaling and may be lossy.
`schema` and verbose write summaries report ALP by name. ALP is C++/Python-only;
Java cannot query ALP series. Native build options control compression
availability; LZMA2 is opt-in.
`schema` and verbose write summaries report ALP by name. Java can query
ALP-encoded FLOAT and DOUBLE series written by C++, but Java writers do not
encode ALP. Native build options control compression availability; LZMA2 is
opt-in.

| Option | Meaning |
|---|---|
Expand Down
2 changes: 1 addition & 1 deletion cpp/tools/skills/tsfile-cli/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ COMP ∈ UNCOMPRESSED, SNAPPY, GZIP, LZO, LZ4, ZSTD, LZMA2
and GORILLA_V1 for FLOAT/DOUBLE, and RLE for BOOLEAN/FLOAT/DOUBLE.
GORILLA_V1 rejects NaN (reserved end marker), but accepts NULL and infinities.
FLOAT/DOUBLE RLE uses the SDK's two-decimal scaling and may be lossy.
ALP is C++/Python-only, not Java-compatible. LZMA2 requires an enabled build.
Java builds with ALP v1 decoding can read these files. LZMA2 requires an enabled build.
- CSV null and backslash rules: see `references/commands.md` before preparing input.
- `DATE` cells are `YYYY-MM-DD`; `TIMESTAMP` and row `time` use strict decimal int64.
- **timestamps must be strictly increasing per device** (device = tag-column values);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,11 @@ error.encoding.float_decoder_method_not_supported = Method %1$s is not supported
# PlainDecoder — BigDecimal not supported
error.encoding.plain_decoder_bigdecimal_unsupported = Method readBigDecimal is not supported by PlainDecoder

# ALP decoder
error.encoding.alp_malformed = Malformed ALP v1 page
error.encoding.alp_no_more_values = No more ALP values in this page
error.encoding.alp_type_not_supported = ALP decoder does not support %1$s

# Decoder — method not supported (8 sites, 1 key)
error.encoding.decoder_method_not_supported = Method %1$s is not supported by Decoder

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,11 @@ error.encoding.float_decoder_method_not_supported = FloatDecoder 不支持方法
# PlainDecoder — BigDecimal not supported
error.encoding.plain_decoder_bigdecimal_unsupported = PlainDecoder 不支持 readBigDecimal 方法

# ALP decoder
error.encoding.alp_malformed = ALP v1 Page 格式无效
error.encoding.alp_no_more_values = 当前 Page 中没有更多 ALP 值
error.encoding.alp_type_not_supported = ALP Decoder 不支持 %1$s

# Decoder — method not supported (8 sites, 1 key)
error.encoding.decoder_method_not_supported = Decoder 不支持方法 %1$s

Expand Down
Loading
Loading