Entity Data Types
Entity
The data type Entity
is a supertype that includes Hash
and AutoNumber
data types.
Type Relation: Entity(x)
The Entity
relation holds if a value has an AutoNumber
or Hash
type.
Everything created using an entity type
constructor is an Entity
:
// read query
entity type Person = String
def bob = ^Person["Bob"]
def output = Entity(bob)
See Entities for more details.
Hash
The Hash
type contains values generated by the hash128
utility, which includes entities
generated with the (default) @hash
annotation.
Construction
Hashes are constructed with hash128[R]
, which hashes each of the tuples in the relation and adds it as a new column in the result:
// read query
def output = hash128[{("a", 1); ("b", 2); ("c", 3)}]
// read query
entity E e = 1; 2; 3
Type Relation: Hash(x)
Hash(x)
tests whether x
is a Hash
.
// read query
def output = hash128[{("a", 1); ("b", 2); ("c", 3)}]
ic hash_ic { subset(output:values, (String, Int, Hash)) }
// read query
entity E e = 1;2;3
ic { Hash(E) }
Noteworthy Operations
The hash_value_uint128_convert
utility converts a Hash
type to a Uint128
:
// read query
def hashes = hash128[{"a" ; "b"}]
def output(x,y,z) = hashes(x,y) and z = hash_value_uint128_convert[y]
In the other direction,
Uint128
values are converted to Hash
with uint128_hash_value_convert
:
// read query
def output = uint128_hash_value_convert[0x00000123456789abcdef]
AutoNumber
Currently, this data type is deprecated and should be avoided. It will be removed soon.
The AutoNumber
type contains values generated by the auto_number
utility, which includes
entities generated with the @auto_number
annotation.
Construction
The auto_number[R]
utility and @auto_number
entities:
// read query
def output = auto_number[{"a"; "b"; "c"}]
// read query
@auto_number entity E e = 1;2;3
Type Relation: AutoNumber(x)
AutoNumber(x)
tests whether x
is an AutoNumber
.
// read query
def output = auto_number[{"a"; "b"; "c"}]
ic auto_number_ic { subset(output, (String, AutoNumber)) }
// read query
@auto_number entity E e = 1;2;3
ic { AutoNumber(E) }
Next: Metadata Types