orcalib.orca_types#
This module defines the types of columns that can be used to declare tables in the Orca database.
Examples:
DocumentT
module-attribute
#
Represents a document column type
A document is a long text that needs to be broken up for indexing
EnumT
module-attribute
#
Represents an Enum column type.
This must be used with the []
operator to specify the enum values.
Examples:
VectorT
module-attribute
#
ImageT
module-attribute
#
OrcaTypeHandle
#
Bases: ABC
Base class for all Orca types. Derived classes represent the types of columns in a table.
Parameters:
-
t_name
(str
) –The name of the type, e.g., “vector” or “image”
-
notnull
(bool
, default:False
) –Whether the column must have a value
-
unique
(bool
, default:False
) –Whether the column must have a unique value
vector_shape
property
#
parameters
property
#
The type parameters as a tuple.
Note
These should be in the same order as the parameters in the constructor
full_name
property
#
from_string
classmethod
#
Parses a type string into an OrcaTypeHandle.
Essentially, you can reconstruct a type after using str(), repr(), or the type’s full_name
property.
Parameters:
-
type_str
(str
) –The type string to parse
Returns:
-
OrcaTypeHandle
–An OrcaTypeHandle instance
Examples:
__eq__
#
NumericTypeHandle
#
Bases: OrcaTypeHandle
Represents a numeric column type, such as integer
or float
that has
a specific data type, e.g., float16
or int32
.
Parameters:
-
dtype
(NumericType | NumericTypeAlternative
) –The numeric type, e.g.,
int32
orfloat64
-
length
(int | None
, default:None
) –The length of the vector, or None if this is not a vector type
-
notnull
(bool
, default:False
) –Whether the column must have a value
-
unique
(bool
, default:False
) –Whether the column must have a unique value
full_name
property
#
from_string
classmethod
#
Parses a type string into an OrcaTypeHandle.
Essentially, you can reconstruct a type after using str(), repr(), or the type’s full_name
property.
Parameters:
-
type_str
(str
) –The type string to parse
Returns:
-
OrcaTypeHandle
–An OrcaTypeHandle instance
Examples:
__eq__
#
__hash__
#
Generate a hash that is unique to the type, including type parameters and constraints.
Returns:
-
int
–Value of the hash
CustomSerializable
#
Bases: Protocol[T]
Protocol for column types that should be transferred as a file instead of a value.
TextTypeHandle
#
Bases: OrcaTypeHandle
Represents a text column type, such as text
or text NOT NULL UNIQUE
.
Parameters:
-
notnull
(bool
, default:False
) –Whether the column must have a value
-
unique
(bool
, default:False
) –Whether the column must have a unique value
vector_shape
property
#
parameters
property
#
The type parameters as a tuple.
Note
These should be in the same order as the parameters in the constructor
full_name
property
#
from_string
classmethod
#
Parses a type string into an OrcaTypeHandle.
Essentially, you can reconstruct a type after using str(), repr(), or the type’s full_name
property.
Parameters:
-
type_str
(str
) –The type string to parse
Returns:
-
OrcaTypeHandle
–An OrcaTypeHandle instance
Examples:
__eq__
#
EnumTypeHandle
#
Bases: OrcaTypeHandle
Represents an enum column type, such as enum
or enum NOT NULL UNIQUE
.
Parameters:
-
store_as_string
(bool
, default:False
) –Whether the enum values are stored as strings (for modeling purposes you will usually want to store them as integers)
-
notnull
(bool
, default:False
) –Whether the column must have a value
-
unique
(bool
, default:False
) –Whether the column must have a unique value
-
name_to_value
(dict[str, int] | None
, default:None
) –A dictionary of name-value pairs for the enum. You can also use the
__getitem__
method to specify the values. This is primarily used when cloning the type.
vector_shape
property
#
full_name
property
#
numpy_dtype
property
#
from_string
classmethod
#
Parses a type string into an OrcaTypeHandle.
Essentially, you can reconstruct a type after using str(), repr(), or the type’s full_name
property.
Parameters:
-
type_str
(str
) –The type string to parse
Returns:
-
OrcaTypeHandle
–An OrcaTypeHandle instance
Examples:
__eq__
#
__hash__
#
Generate a hash that is unique to the type, including type parameters and constraints.
Returns:
-
int
–Value of the hash
__str__
#
Get the type name, including type parameters and constraints.
Returns:
-
str
–The string representation of the type
Examples:
DocumentTypeHandle
#
Bases: OrcaTypeHandle
Represents a document column type.
Parameters:
-
notnull
(bool
, default:False
) –Whether the column must have a value
-
unique
(bool
, default:False
) –Whether the column must have a unique value
vector_shape
property
#
parameters
property
#
The type parameters as a tuple.
Note
These should be in the same order as the parameters in the constructor
full_name
property
#
from_string
classmethod
#
Parses a type string into an OrcaTypeHandle.
Essentially, you can reconstruct a type after using str(), repr(), or the type’s full_name
property.
Parameters:
-
type_str
(str
) –The type string to parse
Returns:
-
OrcaTypeHandle
–An OrcaTypeHandle instance
Examples:
__eq__
#
ImageTypeHandle
#
Bases: OrcaTypeHandle
, CustomSerializable[Image]
Represents an image column type
Parameters:
-
format
(ImageFormat | str | None
) –The image format, for example “PNG” or ImageFormat.PNG
-
notnull
(bool
, default:False
) –Whether the column must have a value
-
unique
(bool
, default:False
) –Whether the column must have a unique value
vector_shape
property
#
full_name
property
#
from_string
classmethod
#
Parses a type string into an OrcaTypeHandle.
Essentially, you can reconstruct a type after using str(), repr(), or the type’s full_name
property.
Parameters:
-
type_str
(str
) –The type string to parse
Returns:
-
OrcaTypeHandle
–An OrcaTypeHandle instance
Examples:
__eq__
#
__hash__
#
Generate a hash that is unique to the type, including type parameters and constraints.
Returns:
-
int
–Value of the hash
__str__
#
Get the type name, including type parameters and constraints.
Returns:
-
str
–The string representation of the type
Examples: