Class Entities
Environment, Usage and their parts (sdk/spec/entities.md,
decision 10): no schema in the data, a version byte before every entity (0 — none), its fields in the order
of its version. The fields of every version live in entities.tsv, the same for the SDKs of all languages:
the reader decodes an old version by its line of the table and fills the current record by the names of the
fields (a field the old version lacks gets its default); the writer writes the latest version, and refuses to start
if the class no longer matches it — a changed record needs a new version in the table.
Kinds of fields: boolean (u8), int, long (zigzag), double, float
(IEEE 754), string and zone (u8 0 — null, 1 — a string follows), enum:T (as a
string: the name of the constant), list:K (varint count + 1, 0 — null, then the elements),
record:T (an entity, with its own version byte; a component Option<T> of an entity is the same
record:T, none — version 0, and one newer than the reader is none, where a required part newer than the
reader passes its owner over). Types are named from io.kubfly.sdk.api:
Environment, environment.Machine, usage.host.Cpu.
A union is a sealed interface of records (usage.platform.Platform): an entity whose fields are
kind (the enum its method kind() returns), then one record per permitted record, in
the order of permits, named by the record with a small first letter (jvm, go); only the part
of the value is written, the others are version 0. The reader gives that part, the record of the interface.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA field of a version of an entity.static interfaceAn entity read: its value, none (version 0), or newer than this reader — passed over by its length and told to the report. -
Method Summary
Modifier and TypeMethodDescriptionThe lines of the current classes, as the table must hold them for their latest versions.static Option<List<Entities.Field>> The fields of a version of a type.static intThe latest version of a type.static StringThe name of a type in the table.read(BufferReader reader, Class<T> type) Reads an entity of any version known toentities.tsvinto the current record.static <T extends Record>
Entities.Read<T> read(BufferReader reader, Class<T> type, Newer newer) Reads an entity of any version known toentities.tsvinto the current record; one newer than this reader is passed over by its length and told to the report (decision 89), and so is one whose required part is newer.types()The types of the table, for diagnostics.static intWrites an entity of its latest version, or 0 fornull.
-
Method Details
-
write
Writes an entity of its latest version, or 0 fornull.- Parameters:
buffer- the buffer ornullto count onlyoffset- wherevalue- the entity ornull- Returns:
- the offset after it
- Throws:
IllegalStateException- if the class does not match its latest version inentities.tsv
-
read
public static <T extends Record> Option<T> read(BufferReader reader, Class<T> type) throws IOException Reads an entity of any version known toentities.tsvinto the current record.- Type Parameters:
T- the type- Parameters:
reader- the readertype- the current class- Returns:
- the entity;
Nonefor version 0 — no entity - Throws:
IOException- if the data is damaged or the version is unknown
-
read
public static <T extends Record> Entities.Read<T> read(BufferReader reader, Class<T> type, Newer newer) throws IOException Reads an entity of any version known toentities.tsvinto the current record; one newer than this reader is passed over by its length and told to the report (decision 89), and so is one whose required part is newer. A part newer than the reader in a list is left out of the list.- Type Parameters:
T- the type- Parameters:
reader- the readertype- the current classnewer- the report of what was passed over- Returns:
- the entity, none (version 0), or newer than this reader
- Throws:
IOException- if the data is damaged
-
name
-
current
-
fields
The fields of a version of a type.- Parameters:
name- the typeversion- the version- Returns:
- the fields;
Noneif the type or the version is unknown
-
latest
The latest version of a type.- Parameters:
name- the type- Returns:
- the version, or 0 if unknown
-
types
-