|  | 
|  | 1 | +syntax = "proto3"; | 
|  | 2 | + | 
|  | 3 | +package io.lionweb.protobuf; | 
|  | 4 | + | 
|  | 5 | +option java_multiple_files = true; | 
|  | 6 | +option java_package = "io.lionweb.protobuf"; | 
|  | 7 | +option java_outer_classname = "ChunkProtos"; | 
|  | 8 | + | 
|  | 9 | +// We make use of interned strings, languages, and meta-pointers because this is leading to significant performance | 
|  | 10 | +// benefits. | 
|  | 11 | +// So many integer values are indexes into tables of interned values. | 
|  | 12 | +// Values prefixed with "si_" are string indexes | 
|  | 13 | +// Values prefixed with "li_" are language indexes | 
|  | 14 | +// Values prefixed with "mpi_" are meta-pointer indexes | 
|  | 15 | +// | 
|  | 16 | +// Null values for strings and languages are encoded as 0, so indexes into these tables | 
|  | 17 | +// are shifted by one. Specifically: | 
|  | 18 | +// - During serialization: null → 0; value i → index (i + 1), where i is the position in the interned table. | 
|  | 19 | +// - During deserialization: 0 → null; index i → element (i - 1) of the interned table. | 
|  | 20 | + | 
|  | 21 | +message PBChunk { | 
|  | 22 | +  string serialization_format_version = 1; | 
|  | 23 | + | 
|  | 24 | +  // Interned strings | 
|  | 25 | +  repeated string interned_strings = 2; | 
|  | 26 | +  repeated PBMetaPointer interned_meta_pointers= 3; | 
|  | 27 | + | 
|  | 28 | +  // Interned languages | 
|  | 29 | +  repeated PBLanguage interned_languages = 4; | 
|  | 30 | +  repeated PBNode nodes = 5; | 
|  | 31 | +} | 
|  | 32 | + | 
|  | 33 | +message PBLanguage { | 
|  | 34 | +  optional uint32 si_key = 1; | 
|  | 35 | +  optional uint32 si_version = 2; | 
|  | 36 | +} | 
|  | 37 | + | 
|  | 38 | +message PBNode { | 
|  | 39 | +  // Yes, we should _not_ have null IDs, but if necessary we can represent them | 
|  | 40 | +  optional uint32 si_id = 1; | 
|  | 41 | +  uint32 mpi_classifier = 2; | 
|  | 42 | +  repeated PBProperty properties = 3; | 
|  | 43 | +  repeated PBContainment containments = 4; | 
|  | 44 | +  repeated PBReference references = 5; | 
|  | 45 | +  /* This is a list of indexes representing the string values corresponding to the IDs of the annotations */ | 
|  | 46 | +  repeated uint32 si_annotations = 6 [packed = true]; | 
|  | 47 | +  optional uint32 si_parent = 7; | 
|  | 48 | +} | 
|  | 49 | + | 
|  | 50 | +message PBMetaPointer { | 
|  | 51 | +  // Instead of duplicating language+version as raw numbers everywhere, | 
|  | 52 | +  // point to the languages table. | 
|  | 53 | +  uint32 li_language = 1; // index into PBChunk.languages | 
|  | 54 | +  optional uint32 si_key = 2; // concept/key within that language | 
|  | 55 | +} | 
|  | 56 | + | 
|  | 57 | +message PBProperty { | 
|  | 58 | +  uint32 mpi_meta_pointer = 1; | 
|  | 59 | +  optional uint32 si_value = 2; | 
|  | 60 | +} | 
|  | 61 | + | 
|  | 62 | +message PBContainment { | 
|  | 63 | +  uint32 mpi_meta_pointer = 1; | 
|  | 64 | +  repeated uint32 si_children = 2 [packed = true]; | 
|  | 65 | +} | 
|  | 66 | + | 
|  | 67 | +message PBReference { | 
|  | 68 | +  uint32 mpi_meta_pointer = 1; | 
|  | 69 | +  repeated PBReferenceValue values = 2; | 
|  | 70 | +} | 
|  | 71 | + | 
|  | 72 | +message PBReferenceValue { | 
|  | 73 | +  optional uint32 si_resolveInfo = 1; | 
|  | 74 | +  optional uint32 si_referred = 2; | 
|  | 75 | +} | 
0 commit comments