Class Table

java.lang.Object
net.quasardb.qdb.ts.Table
All Implemented Interfaces:
Serializable

public class Table extends Object implements Serializable
Represents a timeseries Table. Upon construction, actively resolves metadata such as the associated Columns. Can also be used to construct new QuasarDB timeseries tables.
See Also:
  • Field Details

    • name

      protected String name
    • shardSizeMillis

      protected long shardSizeMillis
    • shardSizeSecs

      protected long shardSizeSecs
    • columns

      protected Column[] columns
  • Constructor Details

    • Table

      public Table(Session session, String name)
      Initialize a new timeseries table.
      Parameters:
      session - Active connection with the QdbCluster
      name - Timeseries name. Must already exist.
    • Table

      public Table(Column[] columns, long shardSizeMillis, String name)
      Initialize a new timeseries table.
      Parameters:
      columns - Table columns
      name - Timeseries name. Must already exist.
  • Method Details

    • likeOther

      public static Table likeOther(Table other, String name)
      Creates a new table object with the exact same structure and shard size as another table. This is an efficient way to initialize large sets of tables that all share a common shard size / schema, as no lookups with the QuasarDB cluster are performed.
      Parameters:
      other - Table to use the schema and shard size of
      name - Name of the new table to be initialized.
    • create

      public static Table create(Session session, String name, Table skeleton)
      Create new timeseries table by copying a 'skeleton' table's schema and using the default shard size.
      Parameters:
      session - Active session with the QuasarDB cluster.
      name - Unique identifier for this timeseries table.
      skeleton - Skeleton table's schema to be copied.
      Returns:
      Reference to the newly created timeseries table.
    • create

      public static Table create(Session session, String name, Table skeleton, long shardSize)
      Create new timeseries table by copying a 'skeleton' table's schema.
      Parameters:
      session - Active session with the QuasarDB cluster.
      name - Unique identifier for this timeseries table.
      skeleton - Skeleton table's schema to be copied.
      shardSize - The size of the shards in ms.
      Returns:
      Reference to the newly created timeseries table.
    • create

      public static Table create(Session session, String name, Column[] columns)
      Create new timeseries table with a default shard size.
      Parameters:
      session - Active session with the QuasarDB cluster.
      name - Unique identifier for this timeseries table.
      columns - Column definitions of this table. The ordering of the array will persist through the table definition and cannot be changed after creation.
      Returns:
      Reference to the newly created timeseries table.
    • create

      public static Table create(Session session, String name, Column[] columns, long shardSize)
      Create new timeseries table.
      Parameters:
      session - Active session with the QuasarDB cluster.
      name - Unique identifier for this timeseries table.
      columns - Column definitions of this table. The ordering of the array will persist through the table definition and cannot be changed after creation.
      shardSize - The size of the shards in ms.
      Returns:
      Reference to the newly created timeseries table.
    • remove

      public static void remove(Session session, String name)
      Remove existing timeseries table.
      Parameters:
      session - Active session with the QuasarDB cluster
      name - Unique identifier for this timeseries table.
    • remove

      public static void remove(Session session, Table table)
      Remove existing timeseries table.
      Parameters:
      session - Active session with the QuasarDB cluster
      table - Table to remove
    • reader

      public static Reader reader(Session session, String name, TimeRange[] ranges)
      Initializes new reader for a timeseries table that filters for a time range.
      Parameters:
      session - Active session with the QuasarDB cluster.
      name - Timeseries table name. Must already exist.
      ranges - Time ranges to look for.
    • reader

      public static Reader reader(Session session, String name)
      Initializes new reader for a timeseries table.
      Parameters:
      session - Active session with the QuasarDB cluster.
      name - Timeseries table name. Must already exist.
    • reader

      public static Reader reader(Session session, Table table, TimeRange[] ranges)
      Initializes new reader for a timeseries table that filters for a time range.
      Parameters:
      session - Active session with the QuasarDB cluster.
      table - Timeseries table.
      ranges - Time time ranges to look for.
    • reader

      public static Reader reader(Session session, Table table)
      Initializes new reader for a timeseries table,
      Parameters:
      session - Active session with the QuasarDB cluster.
      table - Timeseries table.
    • attachTag

      public static void attachTag(Session session, Table table, String tag)
      Attaches a tag to an existing table.
      Parameters:
      session - Active session with the QuasarDB cluster
      table - Timeseries table
      tag - Tag to attach
    • attachTag

      public static void attachTag(Session session, String tableName, String tag)
      Attaches a tag to an existing table.
      Parameters:
      session - Active session with the QuasarDB cluster
      tableName - Name of the timeseries table
      tag - Tag to attach
    • attachTags

      public static void attachTags(Session session, Table table, List<String> tags)
      Attaches tags to an existing table.
      Parameters:
      session - Active session with the QuasarDB cluster
      table - Timeseries table
      tags - Tags to attach
    • attachTags

      public static void attachTags(Session session, String tableName, List<String> tags)
      Attaches tags to an existing table.
      Parameters:
      session - Active session with the QuasarDB cluster
      tableName - Name of the timeseries table
      tags - Tags to attach
    • getName

      public String getName()
      Returns the table name.
    • getShardSizeMillis

      public long getShardSizeMillis()
      Returns this table's shard size (in milliseconds)
    • getShardSize

      public long getShardSize()
      Returns this table's shard size (in seconds)
    • getShardSizeMillis

      public static long getShardSizeMillis(Session session, Table table)
      Returns the shard size (in milliseconds) of the table.
    • getShardSize

      public static long getShardSize(Session session, Table table)
      Returns the shard size (in seconds) of the table.
    • getShardSize

      public static long getShardSize(Session session, String tableName)
      Returns the shard size (in milliseconds) of the table.
    • getColumns

      public static Column[] getColumns(Session session, String name)
      Returns column layout of table.
      Parameters:
      session - Active session with the QuasarDB cluster.
      name - Unique identifier for this timeseries table.
    • getColumns

      public Column[] getColumns()
      Returns column representation of this table.
    • getColumnByName

      public Column getColumnByName(String name)
      Returns reference to Column object for column with a certain name.
      Parameters:
      name - The name to search for.
    • hasColumnWithName

      public boolean hasColumnWithName(String name)
      Returns `true` if table has a column with the name.
      Parameters:
      name - The name to search for.
    • getColumnTypes

      public Column.Type[] getColumnTypes()
      Returns the types of each of the columns.
    • getColumnTypesAsValueTypes

      public Value.Type[] getColumnTypesAsValueTypes()
      Returns the types of the values that are used to represent data for each column.
    • columnIndexById

      public int columnIndexById(String id)
      Utility function that looks up a column's index by its id. The first column starts with 0.
      Parameters:
      id - String identifier of the column.
      Returns:
      The index of the column inside the timeseries table definition.
    • toString

      public String toString()
      Overrides:
      toString in class Object