REL
Entity Data Types
Entity
The data type Entity is a supertype of Hash.
Type Relation: Entity(x)
The Entity relation holds if a value has a 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]Next: Metadata Types
Was this doc helpful?