pub struct Table(/* private fields */);
Implementations§
Source§impl Table
impl Table
Sourcepub fn get_index(&self) -> Option<String>
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()
Sourcepub fn get_client(&self, py: Python<'_>) -> Client
pub fn get_client(&self, py: Python<'_>) -> Client
Sourcepub fn get_name(&self) -> String
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.
Sourcepub fn clear(&self, py: Python<'_>) -> PyResult<()>
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
.
Sourcepub fn delete(&self, py: Python<'_>, lazy: bool) -> PyResult<()>
pub fn delete(&self, py: Python<'_>, lazy: bool) -> PyResult<()>
Delete this Table
and cleans up associated resources.
Table
s 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 thisTable
lazily. When false (the default), the delete will occur immediately, assuming it has noView
instances registered to it (which must be deleted first, otherwise this method will throw an error). When true, theTable
will only be marked for deltion once itsView
dependency count reaches 0.
§Python Examples
table = client.table("x,y\n1,2\n3,4")
# ...
table.delete(lazy=True)
Sourcepub fn make_port(&self, py: Python<'_>) -> PyResult<i32>
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.
Sourcepub fn on_delete(&self, py: Python<'_>, callback: Py<PyAny>) -> PyResult<u32>
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.
pub fn remove( &self, py: Python<'_>, input: Py<PyAny>, format: Option<String>, ) -> PyResult<()>
Sourcepub fn remove_delete(&self, py: Python<'_>, callback_id: u32) -> PyResult<()>
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
.
Sourcepub fn schema(&self, py: Python<'_>) -> PyResult<HashMap<String, String>>
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"
- AString
data type (encoded internally as a dictionary)
Note that all Table
columns are nullable, regardless of the data
type.
Sourcepub fn validate_expressions(
&self,
py: Python<'_>,
expression: Py<PyAny>,
) -> PyResult<Py<PyAny>>
pub fn validate_expressions( &self, py: Python<'_>, expression: Py<PyAny>, ) -> PyResult<Py<PyAny>>
Validates the given expressions.
Sourcepub fn view(&self, py: Python<'_>, config: Option<Py<PyDict>>) -> PyResult<View>
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"],
)
Sourcepub fn replace(
&self,
py: Python<'_>,
input: Py<PyAny>,
format: Option<String>,
) -> PyResult<()>
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
.
Sourcepub fn update(
&self,
py: Python<'_>,
input: Py<PyAny>,
port_id: Option<u32>,
format: Option<String>,
) -> PyResult<()>
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 thisTable
. The schema of aTable
is immutable after creation, so this method cannot be called with a schema.options
- Options for this update step - seeperspective_client::UpdateOptions
.
Trait Implementations§
Source§impl<'py> IntoPyObject<'py> for Table
impl<'py> IntoPyObject<'py> for Table
Source§type Output = Bound<'py, <Table as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <Table as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClassBaseType for Table
impl PyClassBaseType for Table
type LayoutAsBase = PyClassObject<Table>
type BaseNativeType = <Table as PyClassImpl>::BaseNativeType
type Initializer = PyClassInitializer<Table>
type PyClassMutability = <Table as PyClassImpl>::PyClassMutability
Source§impl PyClassImpl for Table
impl PyClassImpl for Table
Source§const IS_BASETYPE: bool = true
const IS_BASETYPE: bool = true
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§type ThreadChecker = SendablePyClass<Table>
type ThreadChecker = SendablePyClass<Table>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature<Table> for PyClassImplCollector<Table>
impl PyClassNewTextSignature<Table> for PyClassImplCollector<Table>
fn new_text_signature(self) -> Option<&'static str>
Source§impl PyMethods<Table> for PyClassImplCollector<Table>
impl PyMethods<Table> for PyClassImplCollector<Table>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for Table
impl PyTypeInfo for Table
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
Source§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
Source§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self
into an owned Python object, dropping type information.