Class Cluster

java.lang.Object
com.couchbase.analytics.client.java.Cluster
All Implemented Interfaces:
Queryable, Closeable, AutoCloseable

public class Cluster extends Object implements Queryable, Closeable
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • newInstance

      public static Cluster newInstance(String connectionString, Credential credential)
    • newInstance

      public static Cluster newInstance(String connectionString, Credential credential, Consumer<ClusterOptions> options)
    • database

      public Database database(String name)
      Returns the database in this cluster with the given name.

      A database is a container for Scopes.

      If the database does not exist, this method still returns a non-null object, but operations using that object fail with an exception indicating the database does not exist.

    • executeQuery

      public QueryResult executeQuery(String statement, Consumer<QueryOptions> options)
      Description copied from interface: Queryable
      Executes a query statement using the specified options (query parameters, etc.), and buffers all result rows in memory.

      If the results are not known to fit in memory, consider using the streaming version that takes a row action callback: Queryable.executeStreamingQuery(String, Consumer, Consumer).

      Specified by:
      executeQuery in interface Queryable
      Parameters:
      statement - The Analytics SQL++ statement to execute.
      options - A callback for specifying custom query options.
      Returns:
      A query result consisting of metadata and a list of rows.
    • executeStreamingQuery

      public QueryMetadata executeStreamingQuery(String statement, Consumer<Row> rowAction, Consumer<QueryOptions> options)
      Description copied from interface: Queryable
      Executes a query statement using the specified options, (query parameters, etc.), and passes result rows to the given rowAction callback, one by one as they arrive from the server.

      The callback action is guaranteed to execute in the same thread (or virtual thread) that called this method. If the callback throws an exception, the query is cancelled and the exception is re-thrown by this method.

      Specified by:
      executeStreamingQuery in interface Queryable
      Parameters:
      statement - The Analytics SQL++ statement to execute.
      options - A callback for specifying custom query options.
      Returns:
      Query metadata.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable