Package com.streambase.sb.operator
Interface TableAccessor
public interface TableAccessor
A handle for accessing a table. Retrieve an instance in an Operator via
Operator.getTableAccessor(String)
.- Since:
- 7.2
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionDelete a row in the table based on primary key.The fields from the schema which make up the primary key.The schema for rows in this table.void
Insert a new row into the table.Prepare an index-accessing query.readPrimary
(Tuple pkey) Read a row from the table by primary key.Replace a row in the table, or insert if there is no existing row with matching primary key.long
size
(boolean slowAndAccurate) Return the number of rows in the tablevoid
truncate()
Truncate the table, by removing all rows
-
Field Details
-
QUERY_ARGUMENT_QUALIFIER
- See Also:
-
-
Method Details
-
getSchema
Schema getSchema()The schema for rows in this table.- Returns:
- Table schema
-
getPrimaryKeyFields
List<Schema.Field> getPrimaryKeyFields()The fields from the schema which make up the primary key.- Returns:
- Primary key fields
-
createRow
Tuple createRow()- Returns:
- a new row object suitable for adding to or querying from the table.
-
readPrimary
Read a row from the table by primary key. The row is read only, and valid until the table is modified.- Parameters:
pkey
- row object with primary key material populated.- Returns:
- The matching table row if any, or null.
- Throws:
StreamBaseException
- if the key is invalid
-
prepare
Prepare an index-accessing query.- Parameters:
predicate
- Predicate which may reference table fields and fields present inargs
. Table fields may be referenced unqualified (as defined in the table),args
fields may be referenced by the "input" prefix.args
- Schema for tuples that will be an argument to this prepared query. May be null if not needed.- Returns:
- A prepared query object which may be used to execute queries as long as this table is around.
- Throws:
StreamBaseException
- if the predicate fails to parse or there is some other issue with preparing the query- See Also:
-
insert
Insert a new row into the table. Data will be copied into the table, the row object can be reused after the row is inserted.- Parameters:
row
- Row values to insert into the able. Should not collide with existing row.- Throws:
StreamBaseException
- If the table is read only or if the row collides with another row.
-
replace
Replace a row in the table, or insert if there is no existing row with matching primary key. Data will be copied into the table, the row object can be reused after the row is inserted.- Parameters:
row
- Row to replace with.- Returns:
- The previous row, or null if there was no previous row. The row is read only.
- Throws:
StreamBaseException
- if the table is read only
-
delete
Delete a row in the table based on primary key.- Parameters:
pkey
- Row object to use for primary key data.- Returns:
- Deleted row or null if there was no matching row. The row is read only.
- Throws:
StreamBaseException
- if the table is read only
-
truncate
Truncate the table, by removing all rows- Throws:
StreamBaseException
- Truncation failed
-
size
long size(boolean slowAndAccurate) Return the number of rows in the table- Parameters:
slowAndAccurate
- For some table implementations accurate results can be expensive. For in-memory query tables, exact results are inexpensive and always returned.- Returns:
- The number of rows in the table
- Since:
- 7.2.5
-