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
10 changes: 8 additions & 2 deletions core/src/main/java/io/github/dfa1/vortex/proto/ALPMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public static ALPMetadata decode(MemorySegment __seg, long __off, long __len) th
/// @return encoded bytes
public byte[] encode() {
ProtoWriter w = new ProtoWriter();
encodeTo(w);
return w.toByteArray();
}

void encodeTo(ProtoWriter w) {
if (exp_e != 0) {
w.writeTag(1, 0);
w.writeVarint32(exp_e);
Expand All @@ -60,8 +65,9 @@ public byte[] encode() {
}
if (patches != null) {
w.writeTag(3, 2);
w.writeEmbedded(patches.encode());
int __mark = w.beginLenDelim();
patches.encodeTo(w);
w.endLenDelim(__mark);
}
return w.toByteArray();
}
}
19 changes: 12 additions & 7 deletions core/src/main/java/io/github/dfa1/vortex/proto/ALPRDMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public static ALPRDMetadata decode(MemorySegment __seg, long __off, long __len)
/// @return encoded bytes
public byte[] encode() {
ProtoWriter w = new ProtoWriter();
encodeTo(w);
return w.toByteArray();
}

void encodeTo(ProtoWriter w) {
if (right_bit_width != 0) {
w.writeTag(1, 0);
w.writeVarint32(right_bit_width);
Expand All @@ -83,22 +88,22 @@ public byte[] encode() {
w.writeVarint32(dict_len);
}
if (!dict.isEmpty()) {
ProtoWriter packed = new ProtoWriter();
w.writeTag(3, 2);
int __mark = w.beginLenDelim();
for (Integer __v : dict) {
packed.writeVarint32(__v);
w.writeVarint32(__v);
}
byte[] __bytes = packed.toByteArray();
w.writeTag(3, 2);
w.writeEmbedded(__bytes);
w.endLenDelim(__mark);
}
if (left_parts_ptype.value() != 0) {
w.writeTag(4, 0);
w.writeVarint32(left_parts_ptype.value());
}
if (patches != null) {
w.writeTag(5, 2);
w.writeEmbedded(patches.encode());
int __mark = w.beginLenDelim();
patches.encodeTo(w);
w.endLenDelim(__mark);
}
return w.toByteArray();
}
}
6 changes: 5 additions & 1 deletion core/src/main/java/io/github/dfa1/vortex/proto/Binary.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ public static Binary decode(MemorySegment __seg, long __off, long __len) throws
/// @return encoded bytes
public byte[] encode() {
ProtoWriter w = new ProtoWriter();
encodeTo(w);
return w.toByteArray();
}

void encodeTo(ProtoWriter w) {
if (nullable) {
w.writeTag(1, 0);
w.writeBool(nullable);
}
return w.toByteArray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public static BitPackedMetadata decode(MemorySegment __seg, long __off, long __l
/// @return encoded bytes
public byte[] encode() {
ProtoWriter w = new ProtoWriter();
encodeTo(w);
return w.toByteArray();
}

void encodeTo(ProtoWriter w) {
if (bit_width != 0) {
w.writeTag(1, 0);
w.writeVarint32(bit_width);
Expand All @@ -60,8 +65,9 @@ public byte[] encode() {
}
if (patches != null) {
w.writeTag(3, 2);
w.writeEmbedded(patches.encode());
int __mark = w.beginLenDelim();
patches.encodeTo(w);
w.endLenDelim(__mark);
}
return w.toByteArray();
}
}
6 changes: 5 additions & 1 deletion core/src/main/java/io/github/dfa1/vortex/proto/Bool.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ public static Bool decode(MemorySegment __seg, long __off, long __len) throws IO
/// @return encoded bytes
public byte[] encode() {
ProtoWriter w = new ProtoWriter();
encodeTo(w);
return w.toByteArray();
}

void encodeTo(ProtoWriter w) {
if (nullable) {
w.writeTag(1, 0);
w.writeBool(nullable);
}
return w.toByteArray();
}
}
54 changes: 41 additions & 13 deletions core/src/main/java/io/github/dfa1/vortex/proto/DType.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,55 +115,83 @@ public static DType decode(MemorySegment __seg, long __off, long __len) throws I
/// @return encoded bytes
public byte[] encode() {
ProtoWriter w = new ProtoWriter();
encodeTo(w);
return w.toByteArray();
}

void encodeTo(ProtoWriter w) {
if (null_ != null) {
w.writeTag(1, 2);
w.writeEmbedded(null_.encode());
int __mark = w.beginLenDelim();
null_.encodeTo(w);
w.endLenDelim(__mark);
}
if (bool != null) {
w.writeTag(2, 2);
w.writeEmbedded(bool.encode());
int __mark = w.beginLenDelim();
bool.encodeTo(w);
w.endLenDelim(__mark);
}
if (primitive != null) {
w.writeTag(3, 2);
w.writeEmbedded(primitive.encode());
int __mark = w.beginLenDelim();
primitive.encodeTo(w);
w.endLenDelim(__mark);
}
if (decimal != null) {
w.writeTag(4, 2);
w.writeEmbedded(decimal.encode());
int __mark = w.beginLenDelim();
decimal.encodeTo(w);
w.endLenDelim(__mark);
}
if (utf8 != null) {
w.writeTag(5, 2);
w.writeEmbedded(utf8.encode());
int __mark = w.beginLenDelim();
utf8.encodeTo(w);
w.endLenDelim(__mark);
}
if (binary != null) {
w.writeTag(6, 2);
w.writeEmbedded(binary.encode());
int __mark = w.beginLenDelim();
binary.encodeTo(w);
w.endLenDelim(__mark);
}
if (struct != null) {
w.writeTag(7, 2);
w.writeEmbedded(struct.encode());
int __mark = w.beginLenDelim();
struct.encodeTo(w);
w.endLenDelim(__mark);
}
if (list != null) {
w.writeTag(8, 2);
w.writeEmbedded(list.encode());
int __mark = w.beginLenDelim();
list.encodeTo(w);
w.endLenDelim(__mark);
}
if (extension != null) {
w.writeTag(9, 2);
w.writeEmbedded(extension.encode());
int __mark = w.beginLenDelim();
extension.encodeTo(w);
w.endLenDelim(__mark);
}
if (fixed_size_list != null) {
w.writeTag(10, 2);
w.writeEmbedded(fixed_size_list.encode());
int __mark = w.beginLenDelim();
fixed_size_list.encodeTo(w);
w.endLenDelim(__mark);
}
if (variant != null) {
w.writeTag(11, 2);
w.writeEmbedded(variant.encode());
int __mark = w.beginLenDelim();
variant.encodeTo(w);
w.endLenDelim(__mark);
}
if (union != null) {
w.writeTag(12, 2);
w.writeEmbedded(union.encode());
int __mark = w.beginLenDelim();
union.encodeTo(w);
w.endLenDelim(__mark);
}
return w.toByteArray();
}

/// Factory for oneof case {@code null} (field tag 1).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ public static DateTimePartsMetadata decode(MemorySegment __seg, long __off, long
/// @return encoded bytes
public byte[] encode() {
ProtoWriter w = new ProtoWriter();
encodeTo(w);
return w.toByteArray();
}

void encodeTo(ProtoWriter w) {
if (days_ptype.value() != 0) {
w.writeTag(1, 0);
w.writeVarint32(days_ptype.value());
Expand All @@ -76,6 +81,5 @@ public byte[] encode() {
w.writeTag(3, 0);
w.writeVarint32(subseconds_ptype.value());
}
return w.toByteArray();
}
}
6 changes: 5 additions & 1 deletion core/src/main/java/io/github/dfa1/vortex/proto/Decimal.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public static Decimal decode(MemorySegment __seg, long __off, long __len) throws
/// @return encoded bytes
public byte[] encode() {
ProtoWriter w = new ProtoWriter();
encodeTo(w);
return w.toByteArray();
}

void encodeTo(ProtoWriter w) {
if (precision != 0) {
w.writeTag(1, 0);
w.writeVarint32(precision);
Expand All @@ -61,6 +66,5 @@ public byte[] encode() {
w.writeTag(3, 0);
w.writeBool(nullable);
}
return w.toByteArray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public static DecimalBytePartsMetadata decode(MemorySegment __seg, long __off, l
/// @return encoded bytes
public byte[] encode() {
ProtoWriter w = new ProtoWriter();
encodeTo(w);
return w.toByteArray();
}

void encodeTo(ProtoWriter w) {
if (zeroth_child_ptype.value() != 0) {
w.writeTag(1, 0);
w.writeVarint32(zeroth_child_ptype.value());
Expand All @@ -56,6 +61,5 @@ public byte[] encode() {
w.writeTag(2, 0);
w.writeVarint32(lower_part_count);
}
return w.toByteArray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ public static DecimalMetadata decode(MemorySegment __seg, long __off, long __len
/// @return encoded bytes
public byte[] encode() {
ProtoWriter w = new ProtoWriter();
encodeTo(w);
return w.toByteArray();
}

void encodeTo(ProtoWriter w) {
if (values_type != 0) {
w.writeTag(1, 0);
w.writeVarint32(values_type);
}
return w.toByteArray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public static DeltaMetadata decode(MemorySegment __seg, long __off, long __len)
/// @return encoded bytes
public byte[] encode() {
ProtoWriter w = new ProtoWriter();
encodeTo(w);
return w.toByteArray();
}

void encodeTo(ProtoWriter w) {
if (deltas_len != 0L) {
w.writeTag(1, 0);
w.writeVarint64(deltas_len);
Expand All @@ -51,6 +56,5 @@ public byte[] encode() {
w.writeTag(2, 0);
w.writeVarint32(offset);
}
return w.toByteArray();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public static DictMetadata decode(MemorySegment __seg, long __off, long __len) t
/// @return encoded bytes
public byte[] encode() {
ProtoWriter w = new ProtoWriter();
encodeTo(w);
return w.toByteArray();
}

void encodeTo(ProtoWriter w) {
if (values_len != 0) {
w.writeTag(1, 0);
w.writeVarint32(values_len);
Expand All @@ -76,6 +81,5 @@ public byte[] encode() {
w.writeTag(4, 0);
w.writeBool(all_values_referenced);
}
return w.toByteArray();
}
}
10 changes: 8 additions & 2 deletions core/src/main/java/io/github/dfa1/vortex/proto/Extension.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,25 @@ public static Extension decode(MemorySegment __seg, long __off, long __len) thro
/// @return encoded bytes
public byte[] encode() {
ProtoWriter w = new ProtoWriter();
encodeTo(w);
return w.toByteArray();
}

void encodeTo(ProtoWriter w) {
if (id != null && !id.isEmpty()) {
w.writeTag(1, 2);
w.writeString(id);
}
if (storage_dtype != null) {
w.writeTag(2, 2);
w.writeEmbedded(storage_dtype.encode());
int __mark = w.beginLenDelim();
storage_dtype.encodeTo(w);
w.endLenDelim(__mark);
}
if (metadata != null) {
w.writeTag(3, 2);
w.writeBytes(metadata);
}
return w.toByteArray();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public static FSSTMetadata decode(MemorySegment __seg, long __off, long __len) t
/// @return encoded bytes
public byte[] encode() {
ProtoWriter w = new ProtoWriter();
encodeTo(w);
return w.toByteArray();
}

void encodeTo(ProtoWriter w) {
if (uncompressed_lengths_ptype.value() != 0) {
w.writeTag(1, 0);
w.writeVarint32(uncompressed_lengths_ptype.value());
Expand All @@ -61,6 +66,5 @@ public byte[] encode() {
w.writeTag(2, 0);
w.writeVarint32(codes_offsets_ptype.value());
}
return w.toByteArray();
}
}
6 changes: 5 additions & 1 deletion core/src/main/java/io/github/dfa1/vortex/proto/Field.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ public static Field decode(MemorySegment __seg, long __off, long __len) throws I
/// @return encoded bytes
public byte[] encode() {
ProtoWriter w = new ProtoWriter();
encodeTo(w);
return w.toByteArray();
}

void encodeTo(ProtoWriter w) {
if (name != null) {
w.writeTag(1, 2);
w.writeString(name);
}
return w.toByteArray();
}

/// Factory for oneof case {@code name} (field tag 1).
Expand Down
Loading
Loading