This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory.git
The following commit(s) were added to refs/heads/main by this push:
new 9614e2331 feat(xlang): reserve 4 bits for type meta (#3204)
9614e2331 is described below
commit 9614e23310d7fdee06f797fc2afacaec3c16dae0
Author: Shawn Yang <[email protected]>
AuthorDate: Tue Jan 27 11:48:02 2026 +0800
feat(xlang): reserve 4 bits for type meta (#3204)
## Why?
- Reserve 4 bits in the TypeDef/class meta header for future extensions
while keeping cross-language compatibility.
## What does this PR do?
- Update the global header layout to use 8-bit meta size and move flags
to bits 8/9 across Java/Go/C++/Rust/Python implementations.
- Align xlang and Java serialization specs with the new header layout
and reserved bits.
- Fix encoder paths to emit extra meta size only when size reaches the
8-bit mask.
- Improve Python nullable basic-type codegen/serialization with
dedicated int/float helpers and correct buffer slicing.
## Related issues
Closes #3203
## Does this PR introduce any user-facing change?
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
---
cpp/fory/serialization/type_resolver.cc | 6 +--
docs/specification/java_serialization_spec.md | 5 ++-
docs/specification/xlang_serialization_spec.md | 11 ++---
go/fory/type_def.go | 16 +++----
.../main/java/org/apache/fory/meta/ClassDef.java | 8 ++--
.../java/org/apache/fory/meta/ClassDefEncoder.java | 2 +-
.../java/org/apache/fory/meta/TypeDefDecoder.java | 3 +-
.../java/org/apache/fory/meta/TypeDefEncoder.java | 3 +-
python/pyfory/codegen.py | 28 +++++++++++-
python/pyfory/meta/typedef.py | 6 +--
python/pyfory/meta/typedef_encoder.py | 4 +-
python/pyfory/serialization.pyx | 52 ++++++++++++++++++++++
python/pyfory/struct.py | 32 +++++++++----
rust/fory-core/src/meta/type_meta.rs | 8 ++--
14 files changed, 140 insertions(+), 44 deletions(-)
diff --git a/cpp/fory/serialization/type_resolver.cc
b/cpp/fory/serialization/type_resolver.cc
index 606f170a8..2f240feb2 100644
--- a/cpp/fory/serialization/type_resolver.cc
+++ b/cpp/fory/serialization/type_resolver.cc
@@ -37,9 +37,9 @@ constexpr size_t SMALL_NUM_FIELDS_THRESHOLD = 0b11111;
constexpr uint8_t REGISTER_BY_NAME_FLAG = 0b100000;
constexpr size_t FIELD_NAME_SIZE_THRESHOLD = 0b1111;
constexpr size_t BIG_NAME_THRESHOLD = 0b111111;
-constexpr int64_t META_SIZE_MASK = 0xfff;
-// constexpr int64_t COMPRESS_META_FLAG = 0b1 << 13;
-constexpr int64_t HAS_FIELDS_META_FLAG = 0b1 << 12;
+constexpr int64_t META_SIZE_MASK = 0xff;
+// constexpr int64_t COMPRESS_META_FLAG = 0b1 << 9;
+constexpr int64_t HAS_FIELDS_META_FLAG = 0b1 << 8;
constexpr int8_t NUM_HASH_BITS = 50;
// ============================================================================
diff --git a/docs/specification/java_serialization_spec.md
b/docs/specification/java_serialization_spec.md
index f7f2a1386..e3093f2b9 100644
--- a/docs/specification/java_serialization_spec.md
+++ b/docs/specification/java_serialization_spec.md
@@ -232,12 +232,13 @@ when shared meta is enabled, or referenced by index when
already seen.
Header layout (lower bits on the right):
```
-| 50-bit hash | 1 bit compress | 1 bit has_fields_meta | 12-bit size |
+| 50-bit hash | 4 bits reserved | 1 bit compress | 1 bit has_fields_meta |
8-bit size |
```
-- size: lower 12 bits. If size equals the mask (0xFFF), write extra size as
varuint32 and add it.
+- size: lower 8 bits. If size equals the mask (0xFF), write extra size as
varuint32 and add it.
- compress: set when payload is compressed.
- has_fields_meta: set when field metadata is present.
+- reserved: bits 10-13 are reserved for future use and must be zero.
- hash: 50-bit hash of the payload and flags.
### Class meta bytes
diff --git a/docs/specification/xlang_serialization_spec.md
b/docs/specification/xlang_serialization_spec.md
index 362d2784c..1256ccb08 100644
--- a/docs/specification/xlang_serialization_spec.md
+++ b/docs/specification/xlang_serialization_spec.md
@@ -489,11 +489,12 @@ resolution. It is encoded as:
The 8-byte header is a little-endian uint64:
-- Low 12 bits: meta size (number of bytes in the TypeDef body).
- - If meta size >= 0xFFF, the low 12 bits are set to 0xFFF and an extra
- `varuint32(meta_size - 0xFFF)` follows immediately after the header.
-- Bit 12: `HAS_FIELDS_META` (1 = fields metadata present).
-- Bit 13: `COMPRESS_META` (1 = body is compressed; decompress before parsing).
+- Low 8 bits: meta size (number of bytes in the TypeDef body).
+ - If meta size >= 0xFF, the low 8 bits are set to 0xFF and an extra
+ `varuint32(meta_size - 0xFF)` follows immediately after the header.
+- Bit 8: `HAS_FIELDS_META` (1 = fields metadata present).
+- Bit 9: `COMPRESS_META` (1 = body is compressed; decompress before parsing).
+- Bits 10-13: reserved for future extension (must be zero).
- High 50 bits: hash of the TypeDef body.
#### TypeDef body
diff --git a/go/fory/type_def.go b/go/fory/type_def.go
index 363f46091..99a33431f 100644
--- a/go/fory/type_def.go
+++ b/go/fory/type_def.go
@@ -28,16 +28,16 @@ import (
)
const (
- META_SIZE_MASK = 0xFFF
- COMPRESS_META_FLAG = 0b1 << 13
- HAS_FIELDS_META_FLAG = 0b1 << 12
+ META_SIZE_MASK = 0xFF
+ COMPRESS_META_FLAG = 0b1 << 9
+ HAS_FIELDS_META_FLAG = 0b1 << 8
NUM_HASH_BITS = 50
)
/*
TypeDef represents a transportable value object containing type information
and field definitions.
typeDef are layout as following:
- - first 8 bytes: global header (50 bits hash + 1 bit compress flag + write
fields meta + 12 bits meta size)
+ - first 8 bytes: global header (50 bits hash + 1 bit compress flag + write
fields meta + 8 bits meta size)
- next 1 byte: meta header (2 bits reserved + 1 bit register by name flag +
5 bits num fields)
- next variable bytes: type id (varint) or ns name + type name
- next variable bytes: field definitions (see below)
@@ -1101,7 +1101,7 @@ func getFieldNameEncodingIndex(encoding meta.Encoding)
int {
/*
encodingTypeDef encodes a TypeDef into binary format according to the
specification
typeDef are layout as following:
-- first 8 bytes: global header (50 bits hash + 1 bit compress flag + write
fields meta + 12 bits meta size)
+- first 8 bytes: global header (50 bits hash + 1 bit compress flag + write
fields meta + 8 bits meta size)
- next 1 byte: meta header (2 bits reserved + 1 bit register by name flag + 5
bits num fields)
- next variable bytes: type id (varint) or ns name + type name
- next variable bytes: field defs (see below)
@@ -1245,9 +1245,9 @@ func prependGlobalHeader(buffer *ByteBuffer, isCompressed
bool, hasFieldsMeta bo
}
if metaSize < META_SIZE_MASK {
- header |= uint64(metaSize) & 0xFFF
+ header |= uint64(metaSize) & META_SIZE_MASK
} else {
- header |= 0xFFF // Set to max value, actual size will follow
+ header |= META_SIZE_MASK // Set to max value, actual size will
follow
}
result := NewByteBuffer(make([]byte, metaSize+8))
@@ -1362,7 +1362,7 @@ func writeFieldDef(typeResolver *TypeResolver, buffer
*ByteBuffer, field FieldDe
/*
decodeTypeDef decodes a TypeDef from the buffer
typeDef are layout as following:
- - first 8 bytes: global header (50 bits hash + 1 bit compress flag + write
fields meta + 12 bits meta size)
+ - first 8 bytes: global header (50 bits hash + 1 bit compress flag + write
fields meta + 8 bits meta size)
- next 1 byte: meta header (2 bits reserved + 1 bit register by name flag +
5 bits num fields)
- next variable bytes: type id (varint) or ns name + type name
- next variable bytes: field definitions (see below)
diff --git a/java/fory-core/src/main/java/org/apache/fory/meta/ClassDef.java
b/java/fory-core/src/main/java/org/apache/fory/meta/ClassDef.java
index 1587c1684..75e901e28 100644
--- a/java/fory-core/src/main/java/org/apache/fory/meta/ClassDef.java
+++ b/java/fory-core/src/main/java/org/apache/fory/meta/ClassDef.java
@@ -69,10 +69,10 @@ import org.apache.fory.util.StringUtils;
public class ClassDef implements Serializable {
private static final Logger LOG = LoggerFactory.getLogger(ClassDef.class);
- static final int COMPRESS_META_FLAG = 0b1 << 13;
- static final int HAS_FIELDS_META_FLAG = 0b1 << 12;
- // low 12 bits
- static final int META_SIZE_MASKS = 0xfff;
+ static final int COMPRESS_META_FLAG = 0b1 << 9;
+ static final int HAS_FIELDS_META_FLAG = 0b1 << 8;
+ // low 8 bits
+ static final int META_SIZE_MASKS = 0xff;
static final int NUM_HASH_BITS = 50;
// TODO use field offset to sort field, which will hit l1-cache more. Since
diff --git
a/java/fory-core/src/main/java/org/apache/fory/meta/ClassDefEncoder.java
b/java/fory-core/src/main/java/org/apache/fory/meta/ClassDefEncoder.java
index f28e1f978..49cab8c4f 100644
--- a/java/fory-core/src/main/java/org/apache/fory/meta/ClassDefEncoder.java
+++ b/java/fory-core/src/main/java/org/apache/fory/meta/ClassDefEncoder.java
@@ -227,7 +227,7 @@ public class ClassDefEncoder {
header |= Math.min(metaSize, META_SIZE_MASKS);
MemoryBuffer result = MemoryUtils.buffer(metaSize + 8);
result.writeInt64(header);
- if (metaSize > META_SIZE_MASKS) {
+ if (metaSize >= META_SIZE_MASKS) {
result.writeVarUint32(metaSize - META_SIZE_MASKS);
}
result.writeBytes(buffer.getHeapMemory(), 0, metaSize);
diff --git
a/java/fory-core/src/main/java/org/apache/fory/meta/TypeDefDecoder.java
b/java/fory-core/src/main/java/org/apache/fory/meta/TypeDefDecoder.java
index 9b6e851ac..12a5a40b8 100644
--- a/java/fory-core/src/main/java/org/apache/fory/meta/TypeDefDecoder.java
+++ b/java/fory-core/src/main/java/org/apache/fory/meta/TypeDefDecoder.java
@@ -43,7 +43,8 @@ import org.apache.fory.util.StringUtils;
import org.apache.fory.util.Utils;
/**
- * A decoder which decode binary into {@link ClassDef}. See spec documentation:
+ * A decoder which decode binary into {@link ClassDef}. Global header layout
follows the xlang spec
+ * with an 8-bit meta size and flags at bits 8/9. See spec documentation:
* docs/specification/fory_xlang_serialization_spec.md <a
*
href="https://fory.apache.org/docs/specification/fory_xlang_serialization_spec">...</a>
*/
diff --git
a/java/fory-core/src/main/java/org/apache/fory/meta/TypeDefEncoder.java
b/java/fory-core/src/main/java/org/apache/fory/meta/TypeDefEncoder.java
index 420f75b51..6886c2ef2 100644
--- a/java/fory-core/src/main/java/org/apache/fory/meta/TypeDefEncoder.java
+++ b/java/fory-core/src/main/java/org/apache/fory/meta/TypeDefEncoder.java
@@ -51,7 +51,8 @@ import org.apache.fory.util.StringUtils;
import org.apache.fory.util.Utils;
/**
- * An encoder which encode {@link ClassDef} into binary. See spec
documentation:
+ * An encoder which encode {@link ClassDef} into binary. Global header layout
follows the xlang spec
+ * with an 8-bit meta size and flags at bits 8/9. See spec documentation:
* docs/specification/fory_xlang_serialization_spec.md <a
*
href="https://fory.apache.org/docs/specification/fory_xlang_serialization_spec">...</a>
*/
diff --git a/python/pyfory/codegen.py b/python/pyfory/codegen.py
index f587464db..820484de7 100644
--- a/python/pyfory/codegen.py
+++ b/python/pyfory/codegen.py
@@ -42,13 +42,29 @@ _type_mapping = {
"read_nullable_pyfloat64",
),
str: ("write_string", "read_string", "write_nullable_pystr",
"read_nullable_pystr"),
+ "int8": ("write_int8", "read_int8", "write_nullable_int8",
"read_nullable_int8"),
+ "int16": ("write_int16", "read_int16", "write_nullable_int16",
"read_nullable_int16"),
+ "int32": ("write_varint32", "read_varint32", "write_nullable_int32",
"read_nullable_int32"),
+ "int64": (
+ "write_varint64",
+ "read_varint64",
+ "write_nullable_pyint64",
+ "read_nullable_pyint64",
+ ),
+ "float32": ("write_float32", "read_float32", "write_nullable_float32",
"read_nullable_float32"),
+ "float64": (
+ "write_double",
+ "read_double",
+ "write_nullable_pyfloat64",
+ "read_nullable_pyfloat64",
+ ),
}
def gen_write_nullable_basic_stmts(
buffer: str,
value: str,
- type_: type,
+ type_: Union[type, str],
) -> List[str]:
methods = _type_mapping[type_]
from pyfory import ENABLE_FORY_CYTHON_SERIALIZATION
@@ -66,7 +82,7 @@ def gen_write_nullable_basic_stmts(
def gen_read_nullable_basic_stmts(
buffer: str,
- type_: type,
+ type_: Union[type, str],
set_action: Callable[[str], str],
) -> List[str]:
methods = _type_mapping[type_]
@@ -114,8 +130,16 @@ def compile_function(
context["write_nullable_pybool"] = serialization.write_nullable_pybool
context["read_nullable_pybool"] = serialization.read_nullable_pybool
+ context["write_nullable_int8"] = serialization.write_nullable_int8
+ context["read_nullable_int8"] = serialization.read_nullable_int8
+ context["write_nullable_int16"] = serialization.write_nullable_int16
+ context["read_nullable_int16"] = serialization.read_nullable_int16
+ context["write_nullable_int32"] = serialization.write_nullable_int32
+ context["read_nullable_int32"] = serialization.read_nullable_int32
context["write_nullable_pyint64"] =
serialization.write_nullable_pyint64
context["read_nullable_pyint64"] = serialization.read_nullable_pyint64
+ context["write_nullable_float32"] =
serialization.write_nullable_float32
+ context["read_nullable_float32"] = serialization.read_nullable_float32
context["write_nullable_pyfloat64"] =
serialization.write_nullable_pyfloat64
context["read_nullable_pyfloat64"] =
serialization.read_nullable_pyfloat64
context["write_nullable_pystr"] = serialization.write_nullable_pystr
diff --git a/python/pyfory/meta/typedef.py b/python/pyfory/meta/typedef.py
index 1218a039d..41da800c3 100644
--- a/python/pyfory/meta/typedef.py
+++ b/python/pyfory/meta/typedef.py
@@ -30,9 +30,9 @@ SMALL_NUM_FIELDS_THRESHOLD = 0b11111
REGISTER_BY_NAME_FLAG = 0b100000
FIELD_NAME_SIZE_THRESHOLD = 0b1111 # 4-bit threshold for field names
BIG_NAME_THRESHOLD = 0b111111 # 6-bit threshold for namespace/typename
-COMPRESS_META_FLAG = 0b1 << 13
-HAS_FIELDS_META_FLAG = 0b1 << 12
-META_SIZE_MASKS = 0xFFF
+COMPRESS_META_FLAG = 0b1 << 9
+HAS_FIELDS_META_FLAG = 0b1 << 8
+META_SIZE_MASKS = 0xFF
NUM_HASH_BITS = 50
NAMESPACE_ENCODINGS = [Encoding.UTF_8, Encoding.ALL_TO_LOWER_SPECIAL,
Encoding.LOWER_UPPER_DIGIT_SPECIAL]
diff --git a/python/pyfory/meta/typedef_encoder.py
b/python/pyfory/meta/typedef_encoder.py
index 7d0975622..aeb28070b 100644
--- a/python/pyfory/meta/typedef_encoder.py
+++ b/python/pyfory/meta/typedef_encoder.py
@@ -135,11 +135,11 @@ def prepend_header(buffer: bytes, is_compressed: bool,
has_fields_meta: bool):
header |= min(meta_size, META_SIZE_MASKS)
result = Buffer.allocate(meta_size + 8)
result.write_int64(header)
- if meta_size > META_SIZE_MASKS:
+ if meta_size >= META_SIZE_MASKS:
result.write_varuint32(meta_size - META_SIZE_MASKS)
result.write_bytes(buffer)
- return result.to_bytes()
+ return result.to_bytes(0, result.writer_index)
def write_namespace(buffer: Buffer, namespace: str):
diff --git a/python/pyfory/serialization.pyx b/python/pyfory/serialization.pyx
index 49aa54e59..9fa7420e3 100644
--- a/python/pyfory/serialization.pyx
+++ b/python/pyfory/serialization.pyx
@@ -1615,6 +1615,27 @@ cpdef inline write_nullable_pybool(Buffer buffer, value):
buffer.write_int8(NOT_NULL_VALUE_FLAG)
buffer.write_bool(value)
+cpdef inline write_nullable_int8(Buffer buffer, value):
+ if value is None:
+ buffer.write_int8(NULL_FLAG)
+ else:
+ buffer.write_int8(NOT_NULL_VALUE_FLAG)
+ buffer.write_int8(value)
+
+cpdef inline write_nullable_int16(Buffer buffer, value):
+ if value is None:
+ buffer.write_int8(NULL_FLAG)
+ else:
+ buffer.write_int8(NOT_NULL_VALUE_FLAG)
+ buffer.write_int16(value)
+
+cpdef inline write_nullable_int32(Buffer buffer, value):
+ if value is None:
+ buffer.write_int8(NULL_FLAG)
+ else:
+ buffer.write_int8(NOT_NULL_VALUE_FLAG)
+ buffer.write_varint32(value)
+
cpdef inline write_nullable_pyint64(Buffer buffer, value):
if value is None:
buffer.write_int8(NULL_FLAG)
@@ -1622,6 +1643,13 @@ cpdef inline write_nullable_pyint64(Buffer buffer,
value):
buffer.write_int8(NOT_NULL_VALUE_FLAG)
buffer.write_varint64(value)
+cpdef inline write_nullable_float32(Buffer buffer, value):
+ if value is None:
+ buffer.write_int8(NULL_FLAG)
+ else:
+ buffer.write_int8(NOT_NULL_VALUE_FLAG)
+ buffer.write_float32(value)
+
cpdef inline write_nullable_pyfloat64(Buffer buffer, value):
if value is None:
buffer.write_int8(NULL_FLAG)
@@ -1642,12 +1670,36 @@ cpdef inline read_nullable_pybool(Buffer buffer):
else:
return None
+cpdef inline read_nullable_int8(Buffer buffer):
+ if buffer.read_int8() == NOT_NULL_VALUE_FLAG:
+ return buffer.read_int8()
+ else:
+ return None
+
+cpdef inline read_nullable_int16(Buffer buffer):
+ if buffer.read_int8() == NOT_NULL_VALUE_FLAG:
+ return buffer.read_int16()
+ else:
+ return None
+
+cpdef inline read_nullable_int32(Buffer buffer):
+ if buffer.read_int8() == NOT_NULL_VALUE_FLAG:
+ return buffer.read_varint32()
+ else:
+ return None
+
cpdef inline read_nullable_pyint64(Buffer buffer):
if buffer.read_int8() == NOT_NULL_VALUE_FLAG:
return buffer.read_varint64()
else:
return None
+cpdef inline read_nullable_float32(Buffer buffer):
+ if buffer.read_int8() == NOT_NULL_VALUE_FLAG:
+ return buffer.read_float32()
+ else:
+ return None
+
cpdef inline read_nullable_pyfloat64(Buffer buffer):
if buffer.read_int8() == NOT_NULL_VALUE_FLAG:
return buffer.read_double()
diff --git a/python/pyfory/struct.py b/python/pyfory/struct.py
index 0dfcb6177..9ad711259 100644
--- a/python/pyfory/struct.py
+++ b/python/pyfory/struct.py
@@ -608,10 +608,18 @@ class DataClassSerializer(Serializer):
# Use gen_write_nullable_basic_stmts for nullable basic types
if isinstance(serializer, BooleanSerializer):
stmts.extend(gen_write_nullable_basic_stmts(buffer,
field_value, bool))
- elif isinstance(serializer, (ByteSerializer, Int16Serializer,
Int32Serializer, Int64Serializer)):
- stmts.extend(gen_write_nullable_basic_stmts(buffer,
field_value, int))
- elif isinstance(serializer, (Float32Serializer,
Float64Serializer)):
- stmts.extend(gen_write_nullable_basic_stmts(buffer,
field_value, float))
+ elif isinstance(serializer, ByteSerializer):
+ stmts.extend(gen_write_nullable_basic_stmts(buffer,
field_value, "int8"))
+ elif isinstance(serializer, Int16Serializer):
+ stmts.extend(gen_write_nullable_basic_stmts(buffer,
field_value, "int16"))
+ elif isinstance(serializer, Int32Serializer):
+ stmts.extend(gen_write_nullable_basic_stmts(buffer,
field_value, "int32"))
+ elif isinstance(serializer, Int64Serializer):
+ stmts.extend(gen_write_nullable_basic_stmts(buffer,
field_value, "int64"))
+ elif isinstance(serializer, Float32Serializer):
+ stmts.extend(gen_write_nullable_basic_stmts(buffer,
field_value, "float32"))
+ elif isinstance(serializer, Float64Serializer):
+ stmts.extend(gen_write_nullable_basic_stmts(buffer,
field_value, "float64"))
elif isinstance(serializer, StringSerializer):
stmts.extend(gen_write_nullable_basic_stmts(buffer,
field_value, str))
else:
@@ -698,10 +706,18 @@ class DataClassSerializer(Serializer):
# Use gen_read_nullable_basic_stmts for nullable basic types
if isinstance(serializer, BooleanSerializer):
field_stmts.extend(gen_read_nullable_basic_stmts(buffer,
bool, lambda v: f"{field_value} = {v}"))
- elif isinstance(serializer, (ByteSerializer, Int16Serializer,
Int32Serializer, Int64Serializer)):
- field_stmts.extend(gen_read_nullable_basic_stmts(buffer,
int, lambda v: f"{field_value} = {v}"))
- elif isinstance(serializer, (Float32Serializer,
Float64Serializer)):
- field_stmts.extend(gen_read_nullable_basic_stmts(buffer,
float, lambda v: f"{field_value} = {v}"))
+ elif isinstance(serializer, ByteSerializer):
+ field_stmts.extend(gen_read_nullable_basic_stmts(buffer,
"int8", lambda v: f"{field_value} = {v}"))
+ elif isinstance(serializer, Int16Serializer):
+ field_stmts.extend(gen_read_nullable_basic_stmts(buffer,
"int16", lambda v: f"{field_value} = {v}"))
+ elif isinstance(serializer, Int32Serializer):
+ field_stmts.extend(gen_read_nullable_basic_stmts(buffer,
"int32", lambda v: f"{field_value} = {v}"))
+ elif isinstance(serializer, Int64Serializer):
+ field_stmts.extend(gen_read_nullable_basic_stmts(buffer,
"int64", lambda v: f"{field_value} = {v}"))
+ elif isinstance(serializer, Float32Serializer):
+ field_stmts.extend(gen_read_nullable_basic_stmts(buffer,
"float32", lambda v: f"{field_value} = {v}"))
+ elif isinstance(serializer, Float64Serializer):
+ field_stmts.extend(gen_read_nullable_basic_stmts(buffer,
"float64", lambda v: f"{field_value} = {v}"))
elif isinstance(serializer, StringSerializer):
field_stmts.extend(gen_read_nullable_basic_stmts(buffer,
str, lambda v: f"{field_value} = {v}"))
else:
diff --git a/rust/fory-core/src/meta/type_meta.rs
b/rust/fory-core/src/meta/type_meta.rs
index 4ead56cbb..81aa4b9d7 100644
--- a/rust/fory-core/src/meta/type_meta.rs
+++ b/rust/fory-core/src/meta/type_meta.rs
@@ -68,9 +68,9 @@ const SMALL_FIELD_ID_THRESHOLD: i16 = 0b1111;
const BIG_NAME_THRESHOLD: usize = 0b111111;
-const META_SIZE_MASK: i64 = 0xfff;
-const COMPRESS_META_FLAG: i64 = 0b1 << 13;
-const HAS_FIELDS_META_FLAG: i64 = 0b1 << 12;
+const META_SIZE_MASK: i64 = 0xff;
+const COMPRESS_META_FLAG: i64 = 0b1 << 9;
+const HAS_FIELDS_META_FLAG: i64 = 0b1 << 8;
const NUM_HASH_BITS: i8 = 50;
pub static NAMESPACE_ENCODINGS: &[Encoding] = &[
@@ -922,7 +922,7 @@ impl TypeMeta {
let mut meta_buffer = vec![];
let mut meta_writer = Writer::from_buffer(&mut meta_buffer);
meta_writer.write_bytes(self.to_meta_bytes()?.as_slice());
- // global_binary_header:| hash:50bits | is_compressed:1bit |
write_fields_meta:1bit | meta_size:12bits |
+ // global_binary_header:| hash:50bits | reserved:4bits |
is_compressed:1bit | write_fields_meta:1bit | meta_size:8bits |
let meta_size = meta_writer.len() as i64;
let mut header: i64 = min(META_SIZE_MASK, meta_size);
let write_meta_fields_flag = !self.get_field_infos().is_empty();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]