Class PartitionedTableImpl

All Implemented Interfaces:
LogOutputAppendable, LivenessManager, LivenessNode, LivenessReferent, PartitionedTable, Serializable
Direct Known Subclasses:
SourcePartitionedTable

public class PartitionedTableImpl extends LivenessArtifact implements PartitionedTable
PartitionedTable implementation.
See Also:
  • Constructor Details

  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class ReferenceCounted
    • table

      @ConcurrentMethod public Table table()
      Description copied from interface: PartitionedTable
      Get the "raw" partitioned table underlying this PartitionedTable.

      The raw table can be converted back into a partitioned table using PartitionedTableFactory.of(Table) or PartitionedTableFactory.of(Table, Collection, boolean, String, TableDefinition, boolean).

      Specified by:
      table in interface PartitionedTable
      Returns:
      The underlying partitioned table
    • keyColumnNames

      @ConcurrentMethod public Set<String> keyColumnNames()
      Description copied from interface: PartitionedTable
      Get the names of all "key" columns that are part of table().getDefinition(). If there are no key columns, the result will be empty. This set is explicitly ordered.
      Specified by:
      keyColumnNames in interface PartitionedTable
      Returns:
      The key column names
    • uniqueKeys

      @ConcurrentMethod public boolean uniqueKeys()
      Description copied from interface: PartitionedTable

      Are the keys (key column values for a row considered as a tuple) in the underlying partitioned table unique?

      If keys are unique, one can expect that table().selectDistinct(keyColumnNames.toArray(String[]::new)) is equivalent to table().view(keyColumnNames.toArray(String[]::new)).

      Specified by:
      uniqueKeys in interface PartitionedTable
      Returns:
      Whether the keys in the underlying partitioned table are unique
    • constituentColumnName

      @ConcurrentMethod public String constituentColumnName()
      Description copied from interface: PartitionedTable
      Get the name of the "constituent" column of tables.
      Specified by:
      constituentColumnName in interface PartitionedTable
      Returns:
      The constituent column name
    • constituentDefinition

      @ConcurrentMethod public TableDefinition constituentDefinition()
      Description copied from interface: PartitionedTable
      Get a definition shared by or mutually compatible with all constituent tables.
      Specified by:
      constituentDefinition in interface PartitionedTable
      Returns:
      The constituent definition
    • constituentChangesPermitted

      @ConcurrentMethod public boolean constituentChangesPermitted()
      Description copied from interface: PartitionedTable

      Can the constituents of the underlying partitioned table change?

      This is completely unrelated to whether the constituents themselves are refreshing, or whether the underlying partitioned table is refreshing. Note that the underlying partitioned table must be refreshing if it contains any refreshing constituents.

      PartitionedTables that specify constituentChangesPermitted() == false must be guaranteed to never change their constituents. Formally, it is expected that table() will never report additions, removals, or shifts, and that any modifications reported will not change values in the constituent column (that is, table().getColumnSource(constituentColumnName())).

      Specified by:
      constituentChangesPermitted in interface PartitionedTable
      Returns:
      Whether the constituents of the underlying partitioned table can change
    • proxy

      @ConcurrentMethod public PartitionedTable.Proxy proxy(boolean requireMatchingKeys, boolean sanityCheckJoinOperations)
      Description copied from interface: PartitionedTable

      Make a proxy that allows table operations to be applied to the constituent tables of this PartitionedTable.

      Each operation thus applied will produce a new PartitionedTable with the results as in PartitionedTable.transform(UnaryOperator, Dependency...) or PartitionedTable.partitionedTransform(PartitionedTable, BinaryOperator, Dependency...), and return a new proxy to that PartitionedTable.

      Specified by:
      proxy in interface PartitionedTable
      Parameters:
      requireMatchingKeys - Whether to ensure that both partitioned tables have all the same keys present when a proxied operation uses this and another PartitionedTable as inputs for a partitioned transform
      sanityCheckJoinOperations - Whether to check that proxied join operations will only find a given join key in one constituent table for this and the table argument if it is also a proxy
      Returns:
      A proxy that allows table operations to be applied to the constituent tables of this PartitionedTable
    • merge

      public Table merge()
      Description copied from interface: PartitionedTable
      Make a new Table that contains the rows from all the constituent tables of this PartitionedTable, in the same relative order as the underlying partitioned table and its constituents. If constituent tables contain extra columns not in the constituent definition, those columns will be ignored. If constituent tables are missing columns in the constituent definition, the corresponding output rows will be null.
      Specified by:
      merge in interface PartitionedTable
      Returns:
      A merged representation of the constituent tables
    • filter

      @ConcurrentMethod public PartitionedTableImpl filter(@NotNull @NotNull Collection<? extends Filter> filters)
      Description copied from interface: PartitionedTable

      Make a new PartitionedTable from the result of applying filters to the underlying partitioned table.

      filters must not reference the constituent column.

      Specified by:
      filter in interface PartitionedTable
      Parameters:
      filters - The filters to apply. Must not reference the constituent column.
      Returns:
      The filtered PartitionedTable
    • sort

      @ConcurrentMethod public PartitionedTable sort(@NotNull @NotNull Collection<SortColumn> sortColumns)
      Description copied from interface: PartitionedTable

      Make a new PartitionedTable from the result of applying sortColumns to the underlying partitioned table.

      sortColumns must not reference the constituent column.

      Specified by:
      sort in interface PartitionedTable
      Parameters:
      sortColumns - The columns to sort by. Must not reference the constituent column.
      Returns:
      The sorted PartitionedTable
    • transform

      @ConcurrentMethod public PartitionedTable transform(@Nullable @Nullable ExecutionContext executionContext, @NotNull @NotNull UnaryOperator<Table> transformer, boolean expectRefreshingResults, @NotNull @NotNull NotificationQueue.Dependency... dependencies)
      Description copied from interface: PartitionedTable

      Apply transformer to all constituent tables, and produce a new PartitionedTable containing the results. The transformer will be invoked in the provided ExecutionContext.

      transformer must be stateless, safe for concurrent use, and able to return a valid result for an empty input table.

      Specified by:
      transform in interface PartitionedTable
      Parameters:
      executionContext - The ExecutionContext to use for the transformer
      transformer - The UnaryOperator to apply to all constituent tables
      expectRefreshingResults - Whether to expect that the results of applying transformer may be refreshing. If true, the resulting PartitionedTable will always be backed by a refreshing table. This hint is important for transforms to static inputs that might produce refreshing output, in order to ensure correct liveness management; incorrectly specifying false will result in exceptions.
      dependencies - Additional dependencies that must be satisfied before applying transformer to added or modified constituents during update processing; use this when transformer uses additional Table or PartitionedTable inputs besides the constituents of this
      Returns:
      The new PartitionedTable containing the resulting constituents
    • partitionedTransform

      public PartitionedTable partitionedTransform(@NotNull @NotNull PartitionedTable other, @Nullable @Nullable ExecutionContext executionContext, @NotNull @NotNull BinaryOperator<Table> transformer, boolean expectRefreshingResults, @NotNull @NotNull NotificationQueue.Dependency... dependencies)
      Description copied from interface: PartitionedTable

      Apply transformer to all constituent tables found in this and other with the same key column values, and produce a new PartitionedTable containing the results. The transformer will be invoked in the provided ExecutionContext.

      Note that other's key columns must match this PartitionedTable's key columns. Two matching mechanisms are supported, and will be attempted in the order listed:

      1. Match by column name. Both PartitionedTables must have all the same key column names. Like-named columns must have the same data type and component type.
      2. Match by column order. Both PartitionedTables must have their matchable columns in the same order within their key column names. Like-positioned columns must have the same data type and component type.

      transformer must be stateless, safe for concurrent use, and able to return a valid result for empty input tables. It is required to install an ExecutionContext to access any QueryLibrary/QueryScope/QueryCompiler functionality from the transformer.

      Specified by:
      partitionedTransform in interface PartitionedTable
      Parameters:
      other - The other PartitionedTable to find constituents in
      executionContext - The ExecutionContext to use for the transformer
      transformer - The BinaryOperator to apply to all pairs of constituent tables
      expectRefreshingResults - Whether to expect that the results of applying transformer may be refreshing. If true, the resulting PartitionedTable will always be backed by a refreshing table. This hint is important for transforms to static inputs that might produce refreshing output, in order to ensure correct liveness management; incorrectly specifying false will result in exceptions.
      dependencies - Additional dependencies that must be satisfied before applying transformer to added, modified, or newly-matched constituents during update processing; use this when transformer uses additional Table or PartitionedTable inputs besides the constituents of this or other
      Returns:
      The new PartitionedTable containing the resulting constituents
    • constituentFor

      @ConcurrentMethod public Table constituentFor(@NotNull @NotNull Object... keyColumnValues)
      Description copied from interface: PartitionedTable

      Get a single constituent by its corresponding key column values.

      The keyColumnValues can be thought of as a tuple constraining the values for the corresponding key columns for the result row. If there are no matching rows, the result is null. If there are multiple matching rows, an UnsupportedOperationException is thrown.

      The result will be managed by the enclosing liveness scope.

      Note that if PartitionedTable.constituentChangesPermitted(), this method may return different results if invoked multiple times.

      Specified by:
      constituentFor in interface PartitionedTable
      Parameters:
      keyColumnValues - Ordered, boxed values for the key columns in the same order as PartitionedTable.keyColumnNames()
      Returns:
      The constituent at the single row in PartitionedTable.table() matching the keyColumnValues, or null if no matches were found
    • constituents

      @ConcurrentMethod public Table[] constituents()
      Description copied from interface: PartitionedTable
      Get all the current constituents.

      The results will be managed by the enclosing liveness scope.

      Note that if PartitionedTable.constituentChangesPermitted(), this method may return different results if invoked multiple times.

      Specified by:
      constituents in interface PartitionedTable
      Returns:
      An array of all current constituents