graviti.portex.builtin#

The Portex builtin types.

Module Contents#

Classes#

PortexBuiltinType

The base class of Portex builtin type.

string

Portex primitive type string.

binary

Portex primitive type binary.

boolean

Portex primitive type boolean.

int32

Portex primitive type int32.

int64

Portex primitive type int64.

float32

Portex primitive type float32.

float64

Portex primitive type float64.

record

Portex complex type record.

enum

Portex complex type enum.

array

Portex complex type array.

tensor

Portex complex type tensor.

Attributes#

graviti.portex.builtin.builtins[source]#
class graviti.portex.builtin.PortexBuiltinType(nullable=False)[source]#

Bases: graviti.portex.base.PortexType

The base class of Portex builtin type.

Parameters

nullable (bool) –

to_builtin(self)[source]#

Expand the top level type to Portex builtin type.

Returns

The expanded Portex builtin type.

Parameters

self (_T) –

Return type

_T

class graviti.portex.builtin.string(nullable=False)[source]#

Bases: PortexBuiltinType

Portex primitive type string.

Parameters

nullable (bool) – Whether it is a nullable type.

Examples

>>> t = string()
>>> t
string()
to_pyarrow(self)[source]#

Convert the Portex type to the corresponding builtin PyArrow DataType.

Returns

The corresponding builtin PyArrow DataType.

Return type

pyarrow.DataType

class graviti.portex.builtin.binary(nullable=False)[source]#

Bases: PortexBuiltinType

Portex primitive type binary.

Parameters

nullable (bool) – Whether it is a nullable type.

Examples

>>> t = binary()
>>> t
binary()
to_pyarrow(self)[source]#

Convert the Portex type to the corresponding builtin PyArrow DataType.

Returns

The corresponding builtin PyArrow DataType.

Return type

pyarrow.DataType

class graviti.portex.builtin.boolean(nullable=False)[source]#

Bases: PortexBuiltinType

Portex primitive type boolean.

Parameters

nullable (bool) – Whether it is a nullable type.

Examples

>>> t = boolean()
>>> t
boolean()
to_pyarrow(self)[source]#

Convert the Portex type to the corresponding builtin PyArrow DataType.

Returns

The corresponding builtin PyArrow DataType.

Return type

pyarrow.DataType

class graviti.portex.builtin.int32(nullable=False)[source]#

Bases: PortexBuiltinType

Portex primitive type int32.

Parameters

nullable (bool) – Whether it is a nullable type.

Examples

>>> t = int32()
>>> t
int32()
to_pyarrow(self)[source]#

Convert the Portex type to the corresponding builtin PyArrow DataType.

Returns

The corresponding builtin PyArrow DataType.

Return type

pyarrow.DataType

class graviti.portex.builtin.int64(nullable=False)[source]#

Bases: PortexBuiltinType

Portex primitive type int64.

Parameters

nullable (bool) – Whether it is a nullable type.

Examples

>>> t = int64()
>>> t
int64()
to_pyarrow(self)[source]#

Convert the Portex type to the corresponding builtin PyArrow DataType.

Returns

The corresponding builtin PyArrow DataType.

Return type

pyarrow.DataType

class graviti.portex.builtin.float32(nullable=False)[source]#

Bases: PortexBuiltinType

Portex primitive type float32.

Parameters

nullable (bool) – Whether it is a nullable type.

Examples

>>> t = float32()
>>> t
float32()
to_pyarrow(self)[source]#

Convert the Portex type to the corresponding builtin PyArrow DataType.

Returns

The corresponding builtin PyArrow DataType.

Return type

pyarrow.DataType

class graviti.portex.builtin.float64(nullable=False)[source]#

Bases: PortexBuiltinType

Portex primitive type float64.

Parameters

nullable (bool) – Whether it is a nullable type.

Examples

>>> t = float64()
>>> t
float64()
to_pyarrow(self)[source]#

Convert the Portex type to the corresponding builtin PyArrow DataType.

Returns

The corresponding builtin PyArrow DataType.

Return type

pyarrow.DataType

class graviti.portex.builtin.record(fields, nullable=False)[source]#

Bases: PortexBuiltinType, graviti.portex.base.PortexRecordBase

Portex complex type record.

Parameters

Examples

Create a record by dict:

>>> t = record({"f0": int32(), "f1": float32()})
>>> t
record(
  fields={
    'f0': int32(),
    'f1': float32(),
  },
)

Create a record by tuple list:

>>> t = record([("f0", string()), ("f1", enum(["v0", "v1"]))])
>>> t
record(
  fields={
    'f0': string(),
    'f1': enum(
      values=['v0', 'v1'],
    ),
  },
)
to_pyarrow(self)[source]#

Convert the Portex type to the corresponding builtin PyArrow DataType.

Returns

The corresponding builtin PyArrow struct DataType.

Return type

pyarrow.DataType

class graviti.portex.builtin.enum(values, nullable=False)[source]#

Bases: PortexBuiltinType

Portex complex type enum.

Parameters
  • values (Iterable[_E]) – The values of the enum members.

  • nullable (bool) – Whether it is a nullable type.

Examples

>>> t = enum(["v0", "v1"])
>>> t
enum(
  values=['v0', 'v1'],
)
to_pyarrow(self)[source]#

Convert the Portex type to the corresponding builtin PyArrow DataType.

Returns

The corresponding builtin PyArrow DataType.

Return type

pyarrow.DataType

class graviti.portex.builtin.array(items, length=None, nullable=False)[source]#

Bases: PortexBuiltinType

Portex complex type array.

Parameters
  • items (graviti.portex.base.PortexType) – The item type of the array.

  • length (Optional[int]) – The length of the array.

  • nullable (bool) – Whether it is a nullable type.

Examples

>>> t = array(int32(0), 100)
>>> t
array(
  items=int32(
    minimum=0,
  ),
  length=100,
)
to_pyarrow(self)[source]#

Convert the Portex type to the corresponding builtin PyArrow DataType.

Returns

The corresponding builtin PyArrow DataType.

Return type

pyarrow.DataType

class graviti.portex.builtin.tensor(shape, items, nullable=False)[source]#

Bases: PortexBuiltinType

Portex complex type tensor.

Parameters
  • shape (Iterable[Optional[int]]) – The shape of the tensor.

  • items (graviti.portex.base.PortexType) – The item type of the tensor.

  • nullable (bool) – Whether it is a nullable type.

Examples

>>> t = tensor((3, 3), float64())
>>> t
tensor(
  shape=(3, 3),
  items=float64(),
)
to_pyarrow(self)[source]#

Convert the Portex type to the corresponding builtin PyArrow DataType.

Returns

The corresponding builtin PyArrow DataType.

Return type

pyarrow.DataType