Struct Table

Source
pub struct Table(/* private fields */);

Implementations§

Source§

impl Table

Source

pub fn get_index(&self) -> Option<String>

Returns the name of the index column for the table.

§Python Examples
table = perspective.table("x,y\n1,2\n3,4", index="x");
index = client.get_index()
Source

pub fn get_client(&self, py: Python<'_>) -> Client

Get a copy of the Client this Table came from.

Source

pub fn get_limit(&self) -> Option<u32>

Returns the user-specified row limit for this table.

Source

pub fn get_name(&self) -> String

Returns the user-specified name for this table, or the auto-generated name if a name was not specified when the table was created.

Source

pub fn clear(&self, py: Python<'_>) -> PyResult<()>

Removes all the rows in the Table, but preserves everything else including the schema, index, and any callbacks or registered View instances.

Calling Table::clear, like Table::update and Table::remove, will trigger an update event to any registered listeners via View::on_update.

Source

pub fn columns(&self, py: Python<'_>) -> PyResult<Vec<String>>

Returns the column names of this Table in “natural” order (the ordering implied by the input format).

§Python Examples
columns = table.columns()
Source

pub fn delete(&self, py: Python<'_>, lazy: bool) -> PyResult<()>

Delete this Table and cleans up associated resources.

Tables do not stop consuming resources or processing updates when they are garbage collected in their host language - you must call this method to reclaim these.

§Arguments
  • options An options dictionary.
    • lazy Whether to delete this Table lazily. When false (the default), the delete will occur immediately, assuming it has no View instances registered to it (which must be deleted first, otherwise this method will throw an error). When true, the Table will only be marked for deltion once its View dependency count reaches 0.
§Python Examples
table = client.table("x,y\n1,2\n3,4")

# ...

table.delete(lazy=True)
Source

pub fn make_port(&self, py: Python<'_>) -> PyResult<i32>

Create a unique channel ID on this Table, which allows View::on_update callback calls to be associated with the Table::update which caused them.

Source

pub fn on_delete(&self, py: Python<'_>, callback: Py<PyAny>) -> PyResult<u32>

Register a callback which is called exactly once, when this Table is deleted with the Table::delete method.

Table::on_delete resolves when the subscription message is sent, not when the delete event occurs.

Source

pub fn remove( &self, py: Python<'_>, input: Py<PyAny>, format: Option<String>, ) -> PyResult<()>

Source

pub fn remove_delete(&self, py: Python<'_>, callback_id: u32) -> PyResult<()>

Removes a listener with a given ID, as returned by a previous call to Table::on_delete.

Source

pub fn schema(&self, py: Python<'_>) -> PyResult<HashMap<String, String>>

Returns a table’s Schema, a mapping of column names to column types.

The mapping of a Table’s column names to data types is referred to as a Schema. Each column has a unique name and a data type, one of:

  • "boolean" - A boolean type
  • "date" - A timesonze-agnostic date type (month/day/year)
  • "datetime" - A millisecond-precision datetime type in the UTC timezone
  • "float" - A 64 bit float
  • "integer" - A signed 32 bit integer (the integer type supported by JavaScript)
  • "string" - A String data type (encoded internally as a dictionary)

Note that all Table columns are nullable, regardless of the data type.

Source

pub fn validate_expressions( &self, py: Python<'_>, expression: Py<PyAny>, ) -> PyResult<Py<PyAny>>

Validates the given expressions.

Source

pub fn view(&self, py: Python<'_>, config: Option<Py<PyDict>>) -> PyResult<View>

Create a new View from this table with a specified ViewConfigUpdate.

See View struct.

§Examples
view view = table.view(
    columns=["Sales"],
    aggregates={"Sales": "sum"},
    group_by=["Region", "State"],
)
Source

pub fn size(&self, py: Python<'_>) -> PyResult<usize>

Returns the number of rows in a Table.

Source

pub fn replace( &self, py: Python<'_>, input: Py<PyAny>, format: Option<String>, ) -> PyResult<()>

Removes all the rows in the Table, but preserves everything else including the schema, index, and any callbacks or registered View instances.

Calling Table::clear, like Table::update and Table::remove, will trigger an update event to any registered listeners via View::on_update.

Source

pub fn update( &self, py: Python<'_>, input: Py<PyAny>, port_id: Option<u32>, format: Option<String>, ) -> PyResult<()>

Updates the rows of this table and any derived View instances.

Calling Table::update will trigger the View::on_update callbacks register to derived View, and the call itself will not resolve until all derived View’s are notified.

When updating a Table with an index, Table::update supports partial updates, by omitting columns from the update data.

§Arguments
  • input - The input data for this Table. The schema of a Table is immutable after creation, so this method cannot be called with a schema.
  • options - Options for this update step - see perspective_client::UpdateOptions.

Trait Implementations§

Source§

impl<'py> IntoPyObject<'py> for Table

Source§

type Target = Table

The Python output type
Source§

type Output = Bound<'py, <Table as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
Source§

type Error = PyErr

The type returned in the event of a conversion error.
Source§

fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>

Performs the conversion.
Source§

impl PyClass for Table

Source§

type Frozen = False

Whether the pyclass is frozen. Read more
Source§

impl PyClassBaseType for Table

Source§

type LayoutAsBase = PyClassObject<Table>

Source§

type BaseNativeType = <Table as PyClassImpl>::BaseNativeType

Source§

type Initializer = PyClassInitializer<Table>

Source§

type PyClassMutability = <Table as PyClassImpl>::PyClassMutability

Source§

impl PyClassImpl for Table

Source§

const IS_BASETYPE: bool = true

#[pyclass(subclass)]
Source§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
Source§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
Source§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
Source§

const IS_IMMUTABLE_TYPE: bool = false

#[pyclass(immutable_type)]
Source§

type BaseType = PyAny

Base class
Source§

type ThreadChecker = SendablePyClass<Table>

This handles following two situations: Read more
Source§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

Immutable or mutable
Source§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
Source§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
Source§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
Source§

fn items_iter() -> PyClassItemsIter

Source§

fn doc(py: Python<'_>) -> PyResult<&'static CStr>

Rendered class doc
Source§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

Source§

fn dict_offset() -> Option<isize>

Source§

fn weaklist_offset() -> Option<isize>

Source§

impl PyClassNewTextSignature<Table> for PyClassImplCollector<Table>

Source§

fn new_text_signature(self) -> Option<&'static str>

Source§

impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a Table

Source§

type Holder = Option<PyRef<'py, Table>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

Source§

impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a mut Table

Source§

type Holder = Option<PyRefMut<'py, Table>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

Source§

impl PyMethods<Table> for PyClassImplCollector<Table>

Source§

fn py_methods(self) -> &'static PyClassItems

Source§

impl PyTypeInfo for Table

Source§

const NAME: &'static str = "Table"

Class name.
Source§

const MODULE: Option<&'static str>

Module name, if any.
Source§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
Source§

fn type_object(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
Source§

fn is_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.
Source§

fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.
Source§

impl DerefToPyAny for Table

Auto Trait Implementations§

§

impl Freeze for Table

§

impl !RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl !UnwindSafe for Table

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<'py, T> IntoPyObjectExt<'py> for T
where T: IntoPyObject<'py>,

Source§

fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>

Converts self into an owned Python object, dropping type information.
Source§

fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>

Converts self into an owned Python object, dropping type information and unbinding it from the 'py lifetime.
Source§

fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>

Converts self into a Python object. Read more
Source§

impl<T> PyErrArguments for T
where T: for<'py> IntoPyObject<'py> + Send + Sync,

Source§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
Source§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

Source§

const NAME: &'static str = <T as PyTypeInfo>::NAME

Name of self. This is used in error messages, for example.
Source§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Ungil for T
where T: Send,