Google Cloud Spanner C++ Client 2.13.0
A C++ Client Library for Google Cloud Spanner
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
google::cloud::spanner::KeySet Class Reference

The KeySet class is a regular type that represents a collection of Keys. More...

#include <google/cloud/spanner/keys.h>

Public Member Functions

 KeySet ()=default
 Constructs an empty KeySet. More...
 
 KeySet (KeySet const &)=default
 
KeySetoperator= (KeySet const &)=default
 
 KeySet (KeySet &&)=default
 
KeySetoperator= (KeySet &&)=default
 
KeySetAddKey (Key key)
 Adds the given key to the KeySet. More...
 
KeySetAddRange (KeyBound start, KeyBound end)
 Adds a range of keys defined by the given KeyBounds. More...
 

Static Public Member Functions

static KeySet All ()
 Returns a KeySet that represents the set of "All" keys for the index. More...
 

Friends

Equality
bool operator== (KeySet const &a, KeySet const &b)
 
bool operator!= (KeySet const &a, KeySet const &b)
 

Detailed Description

The KeySet class is a regular type that represents a collection of Keys.

Users can construct a KeySet instance, then add Keys and ranges of Keys to the set. The caller is responsible for ensuring that all keys in a given KeySet instance contain the same number and types of values.

Users may also optionally construct an instance that represents all keys with KeySet::All().

Example
auto delete_albums = spanner::DeleteMutationBuilder(
"Albums", spanner::KeySet()
.Build();
The KeySet class is a regular type that represents a collection of Keys.
Definition: keys.h:157
KeySet & AddKey(Key key)
Adds the given key to the KeySet.
spanner_internal::DeleteMutationBuilder DeleteMutationBuilder
A helper class to construct "delete" mutations.
Definition: mutations.h:355
Key MakeKey(Ts &&... ts)
Constructs a Key from the given arguments.
Definition: keys.h:51
Example
void DeleteAll(google::cloud::spanner::Client client) {
namespace spanner = ::google::cloud::spanner;
// Delete all the performances, venues, albums and singers.
auto commit = client.Commit(spanner::Mutations{
});
if (!commit) throw std::move(commit).status();
std::cout << "delete-all was successful\n";
}
Performs database client operations on Spanner.
Definition: client.h:124
StatusOr< CommitResult > Commit(std::function< StatusOr< Mutations >(Transaction)> const &mutator, std::unique_ptr< TransactionRerunPolicy > rerun_policy, std::unique_ptr< BackoffPolicy > backoff_policy, Options opts={})
Commits a read-write transaction.
static KeySet All()
Returns a KeySet that represents the set of "All" keys for the index.
Definition: keys.h:165
std::vector< Mutation > Mutations
An ordered sequence of mutations to pass to Client::Commit() or return from the Client::Commit() muta...
Definition: mutations.h:99
Mutation MakeDeleteMutation(std::string table_name, KeySet keys)
Creates a simple "delete" mutation for the values in keys.
Definition: mutations.h:369

Constructor & Destructor Documentation

◆ KeySet() [1/3]

google::cloud::spanner::KeySet::KeySet ( )
default

Constructs an empty KeySet.

◆ KeySet() [2/3]

google::cloud::spanner::KeySet::KeySet ( KeySet const &  )
default

◆ KeySet() [3/3]

google::cloud::spanner::KeySet::KeySet ( KeySet &&  )
default

Member Function Documentation

◆ AddKey()

KeySet & google::cloud::spanner::KeySet::AddKey ( Key  key)

Adds the given key to the KeySet.

Example
auto delete_albums = spanner::DeleteMutationBuilder(
"Albums", spanner::KeySet()
.Build();

◆ AddRange()

KeySet & google::cloud::spanner::KeySet::AddRange ( KeyBound  start,
KeyBound  end 
)

Adds a range of keys defined by the given KeyBounds.

Example
auto delete_albums = spanner::DeleteMutationBuilder(
"Albums", spanner::KeySet()
.Build();

◆ All()

static KeySet google::cloud::spanner::KeySet::All ( )
inlinestatic

Returns a KeySet that represents the set of "All" keys for the index.

Example
void DeleteAll(google::cloud::spanner::Client client) {
namespace spanner = ::google::cloud::spanner;
// Delete all the performances, venues, albums and singers.
auto commit = client.Commit(spanner::Mutations{
});
if (!commit) throw std::move(commit).status();
std::cout << "delete-all was successful\n";
}

◆ operator=() [1/2]

KeySet & google::cloud::spanner::KeySet::operator= ( KeySet &&  )
default

◆ operator=() [2/2]

KeySet & google::cloud::spanner::KeySet::operator= ( KeySet const &  )
default

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( KeySet const &  a,
KeySet const &  b 
)
friend

◆ operator==

bool operator== ( KeySet const &  a,
KeySet const &  b 
)
friend