Skip to content
REL
REFERENCE
Data Types
Entity

Data Types: 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, which are the types created by the entity declaration:

// query
 
entity Planet planet_constructor = {"Earth"; "Venus"; "Mars"}
 
ic entity_ic {
   subset(planet_constructor, {(String, Entity)})
}
ic constructor_ic {Entity(planet_constructor["Earth"])}
 
def output = Planet

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:

// query
 
def output = hash128[{("a", 1); ("b", 2); ("c", 3)}]
// query
 
entity E e = 1; 2; 3
 

Type Relation: Hash(x)

Hash(x) tests whether x is a Hash.

// query
 
def output = hash128[{("a", 1); ("b", 2); ("c", 3)}]
 
ic hash_ic { subset(output:values, (String, Int, Hash)) }
// 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:

// 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:

// 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:

// query
 
def output = auto_number[{"a"; "b"; "c"}]
// query
 
@auto_number entity E e = 1;2;3
 

Type Relation: AutoNumber(x)

AutoNumber(x) tests whether x is an AutoNumber.

// query
 
def output = auto_number[{"a"; "b"; "c"}]
 
ic auto_number_ic { subset(output, (String, AutoNumber)) }
// query
 
@auto_number entity E e = 1;2;3
 
ic { AutoNumber(E) }

Next: Metadata Types

Was this doc helpful?