Class DatabaseDestination

java.lang.Object
io.github.flink.gcp.connector.spanner.DatabaseDestination
All Implemented Interfaces:
Serializable

@Public public final class DatabaseDestination extends Object implements Serializable
A fully-qualified Spanner database reference: project, instance and database.

The instance is part of the identity because a database id is unique only within one instance, and a project may hold several instances.

A database, not a table, is as far as the sink's destination goes: a Mutation names the table it applies to, so one sink writes to as many tables as its serializer produces. The other sinks of this project take a destination resolver for that; here the mutation already carries the answer, which is why there is none — and why the mutation-cell weights are read for the whole database rather than for one table.

Instances are pure database identity: equals(Object) and hashCode() are defined over exactly (project, instance, database). Nothing about how the client reaches the database — the emulator endpoint, the RPC priority — belongs here; those are options of the direction that takes them, because they choose a path to the data rather than the data's address.

This type sits at the module root rather than under sink because both source APIs take the same value.

Instances are immutable and cheap to reuse.

See Also:
  • Method Details

    • of

      public static DatabaseDestination of(String project, String instance, String database)
      Creates a DatabaseDestination from bare ids, not resource paths.
      Parameters:
      project - the Google Cloud project id
      instance - the Spanner instance id
      database - the Spanner database id
      Returns:
      the database reference
      Throws:
      IllegalArgumentException - if a component is null or blank, has leading or trailing whitespace, or contains '/' — a separator would make the composed resource path address a different resource
    • getProject

      public String getProject()
      Returns the Google Cloud project id, given as a bare id rather than a resource path.
    • getInstance

      public String getInstance()
      Returns the Spanner instance id, given as a bare id rather than a resource path.
    • getDatabase

      public String getDatabase()
      Returns the Spanner database id, given as a bare id rather than a resource path.
    • toString

      public String toString()
      Returns the database as the resource name Spanner itself uses, projects/P/instances/I/databases/D.
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object