Google Cloud Bigtable C++ Client 2.13.0
A C++ Client Library for Google Cloud Bigtable
Loading...
Searching...
No Matches
table_config.h
1// Copyright 2017 Google Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_TABLE_CONFIG_H
16#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_TABLE_CONFIG_H
17
18#include "google/cloud/bigtable/column_family.h"
19#include "google/cloud/bigtable/version.h"
20#include <google/bigtable/admin/v2/bigtable_table_admin.pb.h>
21#include <map>
22#include <string>
23#include <vector>
24
25namespace google {
26namespace cloud {
27namespace bigtable {
28GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
29/// Specify the initial schema for a new table.
30class TableConfig {
31 public:
33
34 TableConfig(std::map<std::string, GcRule> column_families,
35 std::vector<std::string> initial_splits)
36 : column_families_(std::move(column_families)),
37 initial_splits_(std::move(initial_splits)),
39
40 /// Move the contents to the proto to create tables.
41 // Note that this function returns a copy intentionally, the object does not
42 // have the proto as a member variable, it constructs the proto from its own
43 // data structures for "reasons".
44 ::google::bigtable::admin::v2::CreateTableRequest as_proto() &&;
45
46 using TimestampGranularity =
47 ::google::bigtable::admin::v2::Table::TimestampGranularity;
48 // NOLINTNEXTLINE(readability-identifier-naming)
49 constexpr static TimestampGranularity MILLIS =
50 ::google::bigtable::admin::v2::Table::MILLIS;
51 // NOLINTNEXTLINE(readability-identifier-naming)
52 constexpr static TimestampGranularity TIMESTAMP_GRANULARITY_UNSPECIFIED =
53 ::google::bigtable::admin::v2::Table::TIMESTAMP_GRANULARITY_UNSPECIFIED;
54
55 ///@{
56 /// @name Accessors and modifiers for all attributes
57 std::map<std::string, GcRule> const& column_families() const {
58 return column_families_;
59 }
60 void add_column_family(std::string column_family_name, GcRule gc_rule) {
61 column_families_.emplace(std::move(column_family_name), std::move(gc_rule));
62 }
63
64 std::vector<std::string> const& initial_splits() const {
65 return initial_splits_;
66 }
67 void add_initial_split(std::string split) {
68 initial_splits_.emplace_back(std::move(split));
69 }
70
71 /**
72 * Return the timestamp granularity parameter.
73 *
74 * Cloud Bigtable currently supports only millisecond granularity in the
75 * cell timestamps, both `TIMESTAMP_GRANULARITY_UNSPECIFIED` and `MILLIS`
76 * have the same effect.
77 */
78 TimestampGranularity timestamp_granularity() const { return granularity_; }
79
80 /**
81 * Set the timestamp granularity parameter.
82 *
83 * Cloud Bigtable currently supports only millisecond granularity in the
84 * cell timestamps, both `TIMESTAMP_GRANULARITY_UNSPECIFIED` and `MILLIS`
85 * have the same effect. Creating cells with higher granularity than the
86 * supported value is rejected by the server.
87 */
88 void set_timestamp_granularity(TimestampGranularity new_value) {
89 granularity_ = new_value;
90 }
91 ///@}
92
93 private:
94 std::map<std::string, GcRule> column_families_;
95 std::vector<std::string> initial_splits_;
96 ::google::bigtable::admin::v2::Table::TimestampGranularity granularity_;
97};
98
99GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
100} // namespace bigtable
101} // namespace cloud
102} // namespace google
103
104#endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_BIGTABLE_TABLE_CONFIG_H
Implement a thin wrapper around google::bigtable::admin::v2::GcRule.
Definition: column_family.h:36
Specify the initial schema for a new table.
Definition: table_config.h:30
::google::bigtable::admin::v2::CreateTableRequest as_proto() &&
Move the contents to the proto to create tables.
TableConfig()
Definition: table_config.h:32
void add_initial_split(std::string split)
Return the timestamp granularity parameter.
Definition: table_config.h:67
static constexpr TimestampGranularity MILLIS
Definition: table_config.h:49
TimestampGranularity timestamp_granularity() const
Return the timestamp granularity parameter.
Definition: table_config.h:78
TableConfig(std::map< std::string, GcRule > column_families, std::vector< std::string > initial_splits)
Definition: table_config.h:34
std::vector< std::string > const & initial_splits() const
Return the timestamp granularity parameter.
Definition: table_config.h:64
void set_timestamp_granularity(TimestampGranularity new_value)
Set the timestamp granularity parameter.
Definition: table_config.h:88
std::map< std::string, GcRule > const & column_families() const
Return the timestamp granularity parameter.
Definition: table_config.h:57
void add_column_family(std::string column_family_name, GcRule gc_rule)
Return the timestamp granularity parameter.
Definition: table_config.h:60
static constexpr TimestampGranularity TIMESTAMP_GRANULARITY_UNSPECIFIED
Definition: table_config.h:52
Contains all the Cloud Bigtable C++ client APIs.
Definition: admin_client.h:28