Interface TableAccessor

    • Method Detail

      • 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

        Tuple readPrimary​(Tuple pkey)
                   throws StreamBaseException
        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

        PreparedQuery prepare​(String predicate,
                              Schema args)
                       throws StreamBaseException
        Prepare an index-accessing query.
        Parameters:
        predicate - Predicate which may reference table fields and fields present in args. 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:
        PreparedQuery
      • insert

        void insert​(Tuple row)
             throws StreamBaseException
        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

        Tuple replace​(Tuple row)
               throws StreamBaseException
        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

        Tuple delete​(Tuple pkey)
              throws StreamBaseException
        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
      • 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