This is for storing the type information and representing the data in binary rather than string format as discussed in: Adding value type to posting list - #6 by mrjn
It would be better to use the same type system for schema and storage, otherwise converting between the two types will be cumbersome and confusing. So I plan on reusing what @akhiltak has started with scalar types for storage as well.
The reason I need to extend what he has is as follows:
- Initial Conversion:
RDF → Posting List
The RDF data is in string, posting list is a byte array. The type can be specified either in RDF or in the schema. The conversion will be:
string -> FromString -> native type -> ToByteArray -> byte array
2 . The second conversion is at query time when reading the posting list data and converting to JSON. There are 2 situations here:
a. The storage type matches the schema type. In this case the conversion only involves converting from the byte array to the native type. i.e.
byte array -> FromByteArray -> native type
b. The second case is when the storage type does not match the schema type. In this case we have to do a cast from one type to the other. This process will be:
byte array -> FromByteArray(storage) -> native type -> ToString(storage) -> string -> FromString(schema) -> native type (schema)
Hope this clears it up.