graviti.paging.lists#

Paging list related class.

Module Contents#

Classes#

PagingListBase

PagingListBase is the base class of the paging list related classes.

PagingList

PagingList is a list composed of multiple lists (pages).

MappedPagingList

MappedPagingList is a list composed of multiple mapped pages.

PyArrowPagingList

PyArrowPagingList is a list composed of multiple pyarrow arrays (pages).

class graviti.paging.lists.PagingListBase(iterable)[source]#

Bases: Sequence[_T], graviti.utility.ReprMixin

PagingListBase is the base class of the paging list related classes.

Parameters
  • array – The input sequence.

  • iterable (Iterable[_T]) –

get_item(self, index)[source]#

Get the element in PagingList at the given index.

Parameters

index (int) – The input index.

Returns

The element at the given index.

Return type

_T

get_slice(self, index)[source]#

Get the sliced PagingList at the given slice.

Parameters
  • index (slice) – The input slice.

  • self (_PLB) –

Returns

The sliced PagingList at the given slice.

Return type

_PLB

set_item(self, index, value)[source]#

Update the element value in PagingList at the given index.

Parameters
  • index (int) – The element index.

  • value (_T) – The value needs to be set into the PagingList.

Return type

None

set_slice(self, index, values)[source]#

Update the element values at the given slice with input PagingList.

Parameters
  • index (slice) – The element slice.

  • values (_PLB) – The PagingList which contains the elements to be set.

  • self (_PLB) –

Raises

ValueError – When the input size mismatches with the slice size (when step != 1).

Return type

None

set_slice_iterable(self, index, values)[source]#

Update the element values in PagingList at the given slice with iterable object.

Parameters
  • index (slice) – The element slice.

  • values (Iterable[_T]) – The iterable object which contains the elements to be set.

Raises

ValueError – When the assign input size mismatches with the slice size (when step != 1).

Return type

None

extend(self, values)[source]#

Extend PagingList by appending elements from another PagingList.

Parameters
  • values (_PLB) – The PagingList which contains the elements to be extended.

  • self (_PLB) –

Return type

None

extend_iterable(self, values)[source]#

Extend PagingList by appending elements from the iterable.

Parameters

values (Iterable[_T]) – Elements to be extended into the PagingList.

Return type

None

extend_nulls(self, size)[source]#

Extend PagingList by appending nulls.

Parameters

size (int) – The size of the nulls to be extended.

Return type

None

copy(self)[source]#

Return a copy of the paging list.

Returns

A copy of the paging list.

Parameters

self (_PLB) –

Return type

_PLB

class graviti.paging.lists.PagingList(iterable)[source]#

Bases: PagingListBase[_T]

PagingList is a list composed of multiple lists (pages).

Parameters

iterable (Iterable[_T]) –

classmethod from_factory(cls, factory, keys, mapper)[source]#

Create PagingList from LazyFactory.

Parameters
  • factory (graviti.paging.factory.LazyFactory) – The parent LazyFactory instance.

  • keys (Tuple[str, Ellipsis]) – The keys to access the array from factory.

  • mapper (Callable[[Any], _T]) – A callable object to convert every item in the pyarrow array.

  • cls (Type[_PL]) –

Returns

The PagingList instance created from given factory.

Return type

_PL

class graviti.paging.lists.MappedPagingList(iterable)[source]#

Bases: PagingListBase[_T]

MappedPagingList is a list composed of multiple mapped pages.

Parameters

iterable (Iterable[_T]) –

classmethod from_array(cls, array, mapper)[source]#

Create MappedPagingList from the source array.

Parameters
  • array (Sequence[_T]) – The source array of the paging list.

  • mapper (Callable[[Any], _T]) – A callable object to convert every item in the pyarrow array.

  • cls (Type[_MPL]) –

Returns

The PagingList instance created from the given array.

Return type

_MPL

classmethod from_factory(cls, factory, keys, mapper)[source]#

Create MappedPagingList from LazyFactory.

Parameters
  • factory (graviti.paging.factory.LazyFactory) – The parent LazyFactory instance.

  • keys (Tuple[str, Ellipsis]) – The keys to access the array from factory.

  • mapper (Callable[[Any], _T]) – A callable object to convert every item in the pyarrow array.

  • cls (Type[_MPL]) –

Returns

The PagingList instance created from given factory.

Return type

_MPL

copy(self, copier, mapper)[source]#

Return a copy of the paging list.

Parameters
  • copier (Callable[[_T], _T]) – A callable object to convert loaded items in the source page to the copied page.

  • mapper (Callable[[Any], _T]) – The mapper of the new mapped page.

  • self (_MPL) –

Returns

A copy of the paging list.

Return type

_MPL

class graviti.paging.lists.PyArrowPagingList(iterable)[source]#

Bases: PagingListBase[_T]

PyArrowPagingList is a list composed of multiple pyarrow arrays (pages).

Parameters
  • array – The input pyarrow array.

  • iterable (Iterable[_T]) –

classmethod from_pyarrow(cls, array)[source]#

Create PyArrowPagingList from pyarrow array.

Parameters
  • array (pyarrow.Array) – The input pyarrow array.

  • cls (Type[_PPL]) –

Returns

The PyArrowPagingList instance created from given pyarrow array.

Return type

_PPL

classmethod from_factory(cls, factory, keys, patype)[source]#

Create PyArrowPagingList from LazyFactory.

Parameters
  • factory (graviti.paging.factory.LazyFactory) – The parent LazyFactory instance.

  • keys (Tuple[str, Ellipsis]) – The keys to access the array from factory.

  • patype (pyarrow.DataType) – The pyarrow DataType of the elements in the list.

  • cls (Type[_PPL]) –

Returns

The PyArrowPagingList instance created from given factory.

Return type

_PPL

get_slice(self, index)[source]#

Get the sliced PyArrowPagingList at the given slice.

Parameters
  • index (slice) – The input slice.

  • self (_PPL) –

Returns

The sliced PyArrowPagingList at the given slice.

Return type

_PPL

set_slice(self, index, values)[source]#

Update the element values at the given slice with input PyArrowPagingList.

Parameters
  • index (slice) – The element slice.

  • values (_PPL) – The PyArrowPagingList which contains the elements to be set.

  • self (_PPL) –

Raises

ArrowTypeError – When two pyarrow types mismatch.

Return type

None

extend(self, values)[source]#

Extend PyArrowPagingList by appending elements from another PyArrowPagingList.

Parameters
  • values (_PPL) – The PyArrowPagingList which contains the elements to be extended.

  • self (_PPL) –

Raises

ArrowTypeError – When two pyarrow types mismatch.

Return type

None

extend_nulls(self, size)[source]#

Extend PyArrowPagingList by appending nulls.

Parameters

size (int) – The size of the nulls to be extended.

Return type

None

copy(self)[source]#

Return a copy of the paging list.

Returns

A copy of the paging list.

Parameters

self (_PPL) –

Return type

_PPL

to_pyarrow(self)[source]#

Convert the paging list to pyarrow ChunkedArray.

Returns

The pyarrow ChunkedArray.

Return type

pyarrow.ChunkedArray