Kudu C++ client API
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
client.h
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing,
12 // software distributed under the License is distributed on an
13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, either express or implied. See the License for the
15 // specific language governing permissions and limitations
16 // under the License.
17 
24 
25 #ifndef KUDU_CLIENT_CLIENT_H
26 #define KUDU_CLIENT_CLIENT_H
27 
28 #include <stdint.h>
29 
30 #include <cstddef>
31 #include <map>
32 #include <string>
33 #include <vector>
34 
35 #include "kudu/client/row_result.h"
36 #include "kudu/client/scan_predicate.h"
37 #include "kudu/client/schema.h"
38 #include "kudu/client/shared_ptr.h" // IWYU pragma: keep
39 #ifdef KUDU_HEADERS_NO_STUBS
40 #include <gtest/gtest_prod.h>
41 
42 #include "kudu/gutil/macros.h"
43 #include "kudu/gutil/port.h"
44 #else
45 #include "kudu/client/stubs.h"
46 #endif
47 #include "kudu/util/kudu_export.h"
48 #include "kudu/util/slice.h"
49 #include "kudu/util/status.h"
50 
51 namespace kudu {
52 
53 class AuthzTokenTest;
54 class ClientStressTest_TestUniqueClientIds_Test;
55 class KuduPartialRow;
56 class MonoDelta;
57 class Partition;
58 class PartitionSchema;
59 class SecurityUnknownTskTest;
60 
61 namespace client {
62 class KuduClient;
63 class KuduTable;
64 } // namespace client
65 
66 namespace tools {
67 class LeaderMasterProxy;
68 } // namespace tools
69 
70 namespace client {
71 
72 class KuduDelete;
73 class KuduInsert;
74 class KuduLoggingCallback;
75 class KuduPartitioner;
76 class KuduScanBatch;
77 class KuduSession;
78 class KuduStatusCallback;
79 class KuduTableAlterer;
80 class KuduTableCreator;
81 class KuduTablet;
82 class KuduTabletServer;
83 class KuduUpdate;
84 class KuduUpsert;
85 class KuduValue;
86 class KuduWriteOperation;
87 class ResourceMetrics;
88 
89 namespace internal {
90 template <class ReqClass, class RespClass>
91 class AsyncLeaderMasterRpc; // IWYU pragma: keep
92 class Batcher;
93 class ErrorCollector;
94 class GetTableSchemaRpc;
95 class LookupRpc;
96 class MetaCache;
97 class RemoteTablet;
98 class RemoteTabletServer;
99 class ReplicaController;
100 class RetrieveAuthzTokenRpc;
101 class WriteRpc;
102 } // namespace internal
103 
116 void KUDU_EXPORT InstallLoggingCallback(KuduLoggingCallback* cb);
117 
124 void KUDU_EXPORT UninstallLoggingCallback();
125 
141 void KUDU_EXPORT SetVerboseLogLevel(int level);
142 
152 Status KUDU_EXPORT SetInternalSignalNumber(int signum) WARN_UNUSED_RESULT;
153 
165 Status KUDU_EXPORT DisableSaslInitialization() WARN_UNUSED_RESULT;
166 
167 
190 Status KUDU_EXPORT DisableOpenSSLInitialization() WARN_UNUSED_RESULT;
191 
194 std::string KUDU_EXPORT GetShortVersionString();
195 
198 std::string KUDU_EXPORT GetAllVersionInfo();
199 
204 class KUDU_EXPORT KuduClientBuilder {
205  public:
206  KuduClientBuilder();
207  ~KuduClientBuilder();
208 
212  KuduClientBuilder& clear_master_server_addrs();
213 
219  KuduClientBuilder& master_server_addrs(const std::vector<std::string>& addrs);
220 
228  KuduClientBuilder& add_master_server_addr(const std::string& addr);
229 
239  KuduClientBuilder& default_admin_operation_timeout(const MonoDelta& timeout);
240 
248  KuduClientBuilder& default_rpc_timeout(const MonoDelta& timeout);
249 
257  KuduClientBuilder& import_authentication_credentials(std::string authn_creds);
258 
268  KuduClientBuilder& num_reactors(int num_reactors);
269 
280  Status Build(sp::shared_ptr<KuduClient>* client);
281 
282  private:
283  class KUDU_NO_EXPORT Data;
284 
285  friend class internal::ReplicaController;
286 
287  // Owned.
288  Data* data_;
289 
290  DISALLOW_COPY_AND_ASSIGN(KuduClientBuilder);
291 };
292 
319 class KUDU_EXPORT KuduClient : public sp::enable_shared_from_this<KuduClient> {
320  public:
321  ~KuduClient();
322 
327  KuduTableCreator* NewTableCreator();
328 
337  Status IsCreateTableInProgress(const std::string& table_name,
338  bool* create_in_progress);
339 
345  Status DeleteTable(const std::string& table_name);
346 
348 
359  Status DeleteTableInCatalogs(const std::string& table_name,
360  bool modify_external_catalogs) KUDU_NO_EXPORT;
362 
369  KuduTableAlterer* NewTableAlterer(const std::string& table_name);
370 
379  Status IsAlterTableInProgress(const std::string& table_name,
380  bool* alter_in_progress);
388  Status GetTableSchema(const std::string& table_name,
389  KuduSchema* schema);
390 
397  Status ListTabletServers(std::vector<KuduTabletServer*>* tablet_servers);
398 
406  Status ListTables(std::vector<std::string>* tables,
407  const std::string& filter = "");
408 
416  Status TableExists(const std::string& table_name, bool* exists);
417 
434  Status OpenTable(const std::string& table_name,
435  sp::shared_ptr<KuduTable>* table);
436 
442  sp::shared_ptr<KuduSession> NewSession();
443 
445 
458  Status GetTablet(const std::string& tablet_id,
459  KuduTablet** tablet) KUDU_NO_EXPORT;
460 
468  std::string GetMasterAddresses() const KUDU_NO_EXPORT;
469 
471 
475 
476  CLOSEST_REPLICA,
477 
482  FIRST_REPLICA
483  };
484 
487  bool IsMultiMaster() const;
488 
490  const MonoDelta& default_admin_operation_timeout() const;
491 
493  const MonoDelta& default_rpc_timeout() const;
494 
497  static const uint64_t kNoTimestamp;
498 
509  uint64_t GetLatestObservedTimestamp() const;
510 
525  void SetLatestObservedTimestamp(uint64_t ht_timestamp);
526 
538  Status ExportAuthenticationCredentials(std::string* authn_creds) const;
539 
541 
547  std::string GetHiveMetastoreUris() const KUDU_NO_EXPORT;
548 
554  bool GetHiveMetastoreSaslEnabled() const KUDU_NO_EXPORT;
555 
565  std::string GetHiveMetastoreUuid() const KUDU_NO_EXPORT;
566 
573  std::string location() const KUDU_NO_EXPORT;
575 
576  private:
577  class KUDU_NO_EXPORT Data;
578 
579  template <class ReqClass, class RespClass>
580  friend class internal::AsyncLeaderMasterRpc;
581 
582  friend class ClientTest;
583  friend class ConnectToClusterBaseTest;
584  friend class KuduClientBuilder;
585  friend class KuduPartitionerBuilder;
586  friend class KuduScanToken;
587  friend class KuduScanTokenBuilder;
588  friend class KuduScanner;
589  friend class KuduSession;
590  friend class KuduTable;
591  friend class KuduTableAlterer;
592  friend class KuduTableCreator;
593  friend class internal::Batcher;
594  friend class internal::GetTableSchemaRpc;
595  friend class internal::LookupRpc;
596  friend class internal::MetaCache;
597  friend class internal::RemoteTablet;
598  friend class internal::RemoteTabletServer;
599  friend class internal::RetrieveAuthzTokenRpc;
600  friend class internal::WriteRpc;
601  friend class kudu::AuthzTokenTest;
602  friend class kudu::SecurityUnknownTskTest;
603  friend class tools::LeaderMasterProxy;
604 
605  FRIEND_TEST(kudu::ClientStressTest, TestUniqueClientIds);
606  FRIEND_TEST(ClientTest, TestCacheAuthzTokens);
607  FRIEND_TEST(ClientTest, TestGetSecurityInfoFromMaster);
608  FRIEND_TEST(ClientTest, TestGetTabletServerBlacklist);
609  FRIEND_TEST(ClientTest, TestMasterDown);
610  FRIEND_TEST(ClientTest, TestMasterLookupPermits);
611  FRIEND_TEST(ClientTest, TestMetaCacheExpiry);
612  FRIEND_TEST(ClientTest, TestNonCoveringRangePartitions);
613  FRIEND_TEST(ClientTest, TestRetrieveAuthzTokenInParallel);
614  FRIEND_TEST(ClientTest, TestReplicatedTabletWritesWithLeaderElection);
615  FRIEND_TEST(ClientTest, TestScanFaultTolerance);
616  FRIEND_TEST(ClientTest, TestScanTimeout);
617  FRIEND_TEST(ClientTest, TestWriteWithDeadMaster);
618  FRIEND_TEST(MasterFailoverTest, TestPauseAfterCreateTableIssued);
619 
620  KuduClient();
621 
622  // Owned.
623  Data* data_;
624 
625  DISALLOW_COPY_AND_ASSIGN(KuduClient);
626 };
627 
629 class KUDU_EXPORT KuduTabletServer {
630  public:
631  ~KuduTabletServer();
632 
635  const std::string& uuid() const;
636 
639  const std::string& hostname() const;
640 
643  uint16_t port() const;
644 
651  const std::string& location() const KUDU_NO_EXPORT;
653 
654  private:
655  class KUDU_NO_EXPORT Data;
656 
657  friend class KuduClient;
658  friend class KuduScanner;
659  friend class KuduScanTokenBuilder;
660 
661  KuduTabletServer();
662 
663  // Owned.
664  Data* data_;
665 
666  DISALLOW_COPY_AND_ASSIGN(KuduTabletServer);
667 };
668 
670 class KUDU_EXPORT KuduReplica {
671  public:
672  ~KuduReplica();
673 
678  bool is_leader() const;
679 
681  const KuduTabletServer& ts() const;
682 
683  private:
684  friend class KuduClient;
685  friend class KuduScanTokenBuilder;
686  friend class internal::ReplicaController;
687 
688  class KUDU_NO_EXPORT Data;
689 
690  KuduReplica();
691 
692  // Owned.
693  Data* data_;
694 
695  DISALLOW_COPY_AND_ASSIGN(KuduReplica);
696 };
697 
699 class KUDU_EXPORT KuduTablet {
700  public:
701  ~KuduTablet();
702 
705  const std::string& id() const;
706 
712  const std::vector<const KuduReplica*>& replicas() const;
713 
714  private:
715  friend class KuduClient;
716  friend class KuduScanTokenBuilder;
717 
718  class KUDU_NO_EXPORT Data;
719 
720  KuduTablet();
721 
722  // Owned.
723  Data* data_;
724 
725  DISALLOW_COPY_AND_ASSIGN(KuduTablet);
726 };
727 
729 class KUDU_EXPORT KuduTableCreator {
730  public:
731  ~KuduTableCreator();
732 
744  KuduTableCreator& table_name(const std::string& name);
745 
756  KuduTableCreator& schema(const KuduSchema* schema);
757 
774  KuduTableCreator& add_hash_partitions(const std::vector<std::string>& columns,
775  int32_t num_buckets);
776 
792  KuduTableCreator& add_hash_partitions(const std::vector<std::string>& columns,
793  int32_t num_buckets, int32_t seed);
794 
807  KuduTableCreator& set_range_partition_columns(const std::vector<std::string>& columns);
808 
813  };
814 
843  KuduTableCreator& add_range_partition(KuduPartialRow* lower_bound,
844  KuduPartialRow* upper_bound,
845  RangePartitionBound lower_bound_type = INCLUSIVE_BOUND,
846  RangePartitionBound upper_bound_type = EXCLUSIVE_BOUND);
847 
856  KuduTableCreator& add_range_partition_split(KuduPartialRow* split_row);
857 
863  KuduTableCreator& split_rows(const std::vector<const KuduPartialRow*>& split_rows)
864  ATTRIBUTE_DEPRECATED("use add_range_partition_split() instead");
865 
875  KuduTableCreator& num_replicas(int n_replicas);
876 
884  KuduTableCreator& extra_configs(const std::map<std::string, std::string>& extra_configs);
885 
895  KuduTableCreator& timeout(const MonoDelta& timeout);
896 
904  KuduTableCreator& wait(bool wait);
905 
919  Status Create();
920 
921  private:
922  class KUDU_NO_EXPORT Data;
923 
924  friend class KuduClient;
925 
926  explicit KuduTableCreator(KuduClient* client);
927 
928  // Owned.
929  Data* data_;
930 
931  DISALLOW_COPY_AND_ASSIGN(KuduTableCreator);
932 };
933 
954 class KUDU_EXPORT KuduTable : public sp::enable_shared_from_this<KuduTable> {
955  public:
956  ~KuduTable();
957 
959  const std::string& name() const;
960 
968  const std::string& id() const;
969 
971  const KuduSchema& schema() const;
972 
974  int num_replicas() const;
975 
979  KuduInsert* NewInsert();
980 
984  KuduUpsert* NewUpsert();
985 
989  KuduUpdate* NewUpdate();
990 
994  KuduDelete* NewDelete();
995 
1019  KuduPredicate* NewComparisonPredicate(const Slice& col_name,
1021  KuduValue* value);
1022 
1046  KuduPredicate* NewInListPredicate(const Slice& col_name,
1047  std::vector<KuduValue*>* values);
1048 
1059  KuduPredicate* NewIsNotNullPredicate(const Slice& col_name);
1060 
1071  KuduPredicate* NewIsNullPredicate(const Slice& col_name);
1072 
1075  KuduClient* client() const;
1076 
1078  const PartitionSchema& partition_schema() const;
1079 
1081  const std::map<std::string, std::string>& extra_configs() const;
1082 
1084 
1094  Status ListPartitions(std::vector<Partition>* partitions) KUDU_NO_EXPORT;
1095 
1097 
1098  private:
1099  class KUDU_NO_EXPORT Data;
1100 
1101  friend class KuduClient;
1102  friend class KuduPartitioner;
1103 
1104  KuduTable(const sp::shared_ptr<KuduClient>& client,
1105  const std::string& name,
1106  const std::string& id,
1107  int num_replicas,
1108  const KuduSchema& schema,
1109  const PartitionSchema& partition_schema,
1110  const std::map<std::string, std::string>& extra_configs);
1111 
1112  // Owned.
1113  Data* data_;
1114 
1115  DISALLOW_COPY_AND_ASSIGN(KuduTable);
1116 };
1117 
1129 class KUDU_EXPORT KuduTableAlterer {
1130  public:
1131  ~KuduTableAlterer();
1132 
1138  KuduTableAlterer* RenameTo(const std::string& new_name);
1139 
1149  KuduColumnSpec* AddColumn(const std::string& name);
1150 
1159  KuduColumnSpec* AlterColumn(const std::string& name);
1160 
1168  KuduTableAlterer* DropColumn(const std::string& name);
1169 
1201  KuduTableAlterer* AddRangePartition(
1202  KuduPartialRow* lower_bound,
1203  KuduPartialRow* upper_bound,
1206 
1234  KuduTableAlterer* DropRangePartition(
1235  KuduPartialRow* lower_bound,
1236  KuduPartialRow* upper_bound,
1239 
1249  KuduTableAlterer* AlterExtraConfig(const std::map<std::string, std::string>& extra_configs);
1250 
1260  KuduTableAlterer* timeout(const MonoDelta& timeout);
1261 
1273  KuduTableAlterer* wait(bool wait);
1274 
1276 
1285  KuduTableAlterer* modify_external_catalogs(bool modify_external_catalogs) KUDU_NO_EXPORT;
1286 
1288 
1293  Status Alter();
1294 
1295  private:
1296  class KUDU_NO_EXPORT Data;
1297 
1298  friend class KuduClient;
1299 
1300  KuduTableAlterer(KuduClient* client,
1301  const std::string& name);
1302 
1303  // Owned.
1304  Data* data_;
1305 
1306  DISALLOW_COPY_AND_ASSIGN(KuduTableAlterer);
1307 };
1308 
1314 class KUDU_EXPORT KuduError {
1315  public:
1316  ~KuduError();
1317 
1319  const Status& status() const;
1320 
1322  const KuduWriteOperation& failed_op() const;
1323 
1331  KuduWriteOperation* release_failed_op();
1332 
1343  bool was_possibly_successful() const;
1344 
1345  private:
1346  class KUDU_NO_EXPORT Data;
1347 
1348  friend class internal::Batcher;
1349  friend class internal::ErrorCollector;
1350  friend class KuduSession;
1351 
1352  KuduError(KuduWriteOperation* failed_op, const Status& error);
1353 
1354  // Owned.
1355  Data* data_;
1356 
1357  DISALLOW_COPY_AND_ASSIGN(KuduError);
1358 };
1359 
1360 
1419 class KUDU_EXPORT KuduSession : public sp::enable_shared_from_this<KuduSession> {
1420  public:
1421  ~KuduSession();
1422 
1424  enum FlushMode {
1430 
1458 
1471  MANUAL_FLUSH
1472  };
1473 
1482  Status SetFlushMode(FlushMode m) WARN_UNUSED_RESULT;
1483 
1505 
1520  COMMIT_WAIT
1521  };
1522 
1528  Status SetExternalConsistencyMode(ExternalConsistencyMode m)
1529  WARN_UNUSED_RESULT;
1530 
1548  Status SetMutationBufferSpace(size_t size_bytes) WARN_UNUSED_RESULT;
1549 
1573  Status SetMutationBufferFlushWatermark(double watermark_pct)
1574  WARN_UNUSED_RESULT;
1575 
1597  Status SetMutationBufferFlushInterval(unsigned int millis) WARN_UNUSED_RESULT;
1598 
1623  Status SetMutationBufferMaxNum(unsigned int max_num) WARN_UNUSED_RESULT;
1624 
1630  void SetTimeoutMillis(int millis);
1631 
1635 
1659  Status Apply(KuduWriteOperation* write_op) WARN_UNUSED_RESULT;
1660 
1675  Status Flush() WARN_UNUSED_RESULT;
1676 
1717  void FlushAsync(KuduStatusCallback* cb);
1718 
1721  Status Close() WARN_UNUSED_RESULT;
1722 
1731  bool HasPendingOperations() const;
1732 
1754  int CountBufferedOperations() const
1755  ATTRIBUTE_DEPRECATED("this method is experimental and will disappear "
1756  "in a future release");
1757 
1782  Status SetErrorBufferSpace(size_t size_bytes);
1783 
1793  int CountPendingErrors() const;
1794 
1805  void GetPendingErrors(std::vector<KuduError*>* errors, bool* overflowed);
1806 
1808  KuduClient* client() const;
1809 
1810  private:
1811  class KUDU_NO_EXPORT Data;
1812 
1813  friend class KuduClient;
1814  friend class internal::Batcher;
1815  friend class ClientTest;
1816  FRIEND_TEST(ClientTest, TestAutoFlushBackgroundApplyBlocks);
1817  FRIEND_TEST(ClientTest, TestAutoFlushBackgroundAndErrorCollector);
1818 
1819  explicit KuduSession(const sp::shared_ptr<KuduClient>& client);
1820 
1821  // Owned.
1822  Data* data_;
1823 
1824  DISALLOW_COPY_AND_ASSIGN(KuduSession);
1825 };
1826 
1827 
1832 class KUDU_EXPORT KuduScanner {
1833  public:
1835  enum ReadMode {
1844 
1865 
1876  READ_YOUR_WRITES
1877  };
1878 
1882  enum OrderMode {
1889 
1894  ORDERED
1895  };
1896 
1900  enum { kScanTimeoutMillis = 30000 };
1901 
1907  explicit KuduScanner(KuduTable* table);
1908  ~KuduScanner();
1909 
1919  Status SetProjectedColumnNames(const std::vector<std::string>& col_names)
1920  WARN_UNUSED_RESULT;
1921 
1931  Status SetProjectedColumnIndexes(const std::vector<int>& col_indexes)
1932  WARN_UNUSED_RESULT;
1933 
1939  Status SetProjectedColumns(const std::vector<std::string>& col_names)
1940  WARN_UNUSED_RESULT
1941  ATTRIBUTE_DEPRECATED("use SetProjectedColumnNames() instead");
1942 
1951  Status AddConjunctPredicate(KuduPredicate* pred) WARN_UNUSED_RESULT;
1952 
1961  Status AddLowerBound(const KuduPartialRow& key);
1962 
1970  Status AddLowerBoundRaw(const Slice& key)
1971  ATTRIBUTE_DEPRECATED("use AddLowerBound() instead");
1972 
1981  Status AddExclusiveUpperBound(const KuduPartialRow& key);
1982 
1990  Status AddExclusiveUpperBoundRaw(const Slice& key)
1991  ATTRIBUTE_DEPRECATED("use AddExclusiveUpperBound() instead");
1992 
2001  Status AddLowerBoundPartitionKeyRaw(const Slice& partition_key);
2002 
2011  Status AddExclusiveUpperBoundPartitionKeyRaw(const Slice& partition_key);
2012 
2019  Status SetCacheBlocks(bool cache_blocks);
2020 
2022  Status Open();
2023 
2042  Status KeepAlive();
2043 
2052  void Close();
2053 
2062  bool HasMoreRows() const;
2063 
2075  Status NextBatch(std::vector<KuduRowResult>* rows)
2076  ATTRIBUTE_DEPRECATED("use NextBatch(KuduScanBatch*) instead");
2077 
2086  Status NextBatch(KuduScanBatch* batch);
2087 
2096  Status GetCurrentServer(KuduTabletServer** server);
2097 
2099  const ResourceMetrics& GetResourceMetrics() const;
2100 
2107  Status SetBatchSizeBytes(uint32_t batch_size);
2108 
2116  Status SetSelection(KuduClient::ReplicaSelection selection)
2117  WARN_UNUSED_RESULT;
2118 
2124  Status SetReadMode(ReadMode read_mode) WARN_UNUSED_RESULT;
2125 
2131  Status SetOrderMode(OrderMode order_mode) WARN_UNUSED_RESULT
2132  ATTRIBUTE_DEPRECATED("use SetFaultTolerant() instead");
2133 
2146  Status SetFaultTolerant() WARN_UNUSED_RESULT;
2147 
2153  Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros) WARN_UNUSED_RESULT;
2154 
2164  Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2165 
2167 
2182  Status SetDiffScan(uint64_t start_timestamp, uint64_t end_timestamp)
2183  WARN_UNUSED_RESULT KUDU_NO_EXPORT;
2184 
2186 
2192  Status SetTimeoutMillis(int millis);
2193 
2195  KuduSchema GetProjectionSchema() const;
2196 
2198  //
2204  static const uint64_t NO_FLAGS = 0;
2212  static const uint64_t PAD_UNIXTIME_MICROS_TO_16_BYTES = 1 << 0;
2213 
2241  Status SetRowFormatFlags(uint64_t flags);
2243 
2249  Status SetLimit(int64_t limit) WARN_UNUSED_RESULT;
2250 
2256  std::string ToString() const;
2257 
2258  private:
2259  class KUDU_NO_EXPORT Data;
2260 
2261  friend class KuduScanToken;
2262  FRIEND_TEST(ClientTest, TestBlockScannerHijackingAttempts);
2263  FRIEND_TEST(ClientTest, TestScanCloseProxy);
2264  FRIEND_TEST(ClientTest, TestScanFaultTolerance);
2265  FRIEND_TEST(ClientTest, TestScanNoBlockCaching);
2266  FRIEND_TEST(ClientTest, TestScanTimeout);
2267  FRIEND_TEST(ClientTest, TestReadAtSnapshotNoTimestampSet);
2268  FRIEND_TEST(ConsistencyITest, TestSnapshotScanTimestampReuse);
2269  FRIEND_TEST(ScanTokenTest, TestScanTokens);
2270 
2271  // Owned.
2272  Data* data_;
2273 
2274  DISALLOW_COPY_AND_ASSIGN(KuduScanner);
2275 };
2276 
2297 class KUDU_EXPORT KuduScanToken {
2298  public:
2299 
2300  ~KuduScanToken();
2301 
2312  Status IntoKuduScanner(KuduScanner** scanner) const WARN_UNUSED_RESULT;
2313 
2315  const KuduTablet& tablet() const;
2316 
2324  Status Serialize(std::string* buf) const WARN_UNUSED_RESULT;
2325 
2337  static Status DeserializeIntoScanner(KuduClient* client,
2338  const std::string& serialized_token,
2339  KuduScanner** scanner) WARN_UNUSED_RESULT;
2340 
2341  private:
2342  class KUDU_NO_EXPORT Data;
2343 
2344  friend class KuduScanTokenBuilder;
2345 
2346  KuduScanToken();
2347 
2348  // Owned.
2349  Data* data_;
2350 
2351  DISALLOW_COPY_AND_ASSIGN(KuduScanToken);
2352 };
2353 
2357 class KUDU_EXPORT KuduScanTokenBuilder {
2358  public:
2359 
2365  explicit KuduScanTokenBuilder(KuduTable* table);
2367 
2377  Status SetProjectedColumnNames(const std::vector<std::string>& col_names)
2378  WARN_UNUSED_RESULT;
2379 
2381  Status SetProjectedColumnIndexes(const std::vector<int>& col_indexes)
2382  WARN_UNUSED_RESULT;
2383 
2385  Status AddConjunctPredicate(KuduPredicate* pred) WARN_UNUSED_RESULT;
2386 
2388  Status AddLowerBound(const KuduPartialRow& key) WARN_UNUSED_RESULT;
2389 
2398  Status AddUpperBound(const KuduPartialRow& key) WARN_UNUSED_RESULT;
2399 
2401  Status SetCacheBlocks(bool cache_blocks) WARN_UNUSED_RESULT;
2402 
2409  Status SetBatchSizeBytes(uint32_t batch_size) WARN_UNUSED_RESULT;
2410 
2418  Status SetSelection(KuduClient::ReplicaSelection selection)
2419  WARN_UNUSED_RESULT;
2420 
2422  Status SetReadMode(KuduScanner::ReadMode read_mode) WARN_UNUSED_RESULT;
2423 
2425  Status SetFaultTolerant() WARN_UNUSED_RESULT;
2426 
2428  Status SetSnapshotMicros(uint64_t snapshot_timestamp_micros)
2429  WARN_UNUSED_RESULT;
2430 
2432  Status SetSnapshotRaw(uint64_t snapshot_timestamp) WARN_UNUSED_RESULT;
2433 
2435  Status SetDiffScan(uint64_t start_timestamp, uint64_t end_timestamp)
2436  WARN_UNUSED_RESULT KUDU_NO_EXPORT;
2437 
2439  Status SetTimeoutMillis(int millis) WARN_UNUSED_RESULT;
2440 
2449  Status Build(std::vector<KuduScanToken*>* tokens) WARN_UNUSED_RESULT;
2450 
2451  private:
2452  class KUDU_NO_EXPORT Data;
2453 
2454  // Owned.
2455  Data* data_;
2456 
2457  DISALLOW_COPY_AND_ASSIGN(KuduScanTokenBuilder);
2458 };
2459 
2461 class KUDU_EXPORT KuduPartitionerBuilder {
2462  public:
2467  explicit KuduPartitionerBuilder(sp::shared_ptr<KuduTable> table);
2469 
2475  KuduPartitionerBuilder* SetBuildTimeout(MonoDelta timeout);
2476 
2495  Status Build(KuduPartitioner** partitioner);
2496  private:
2497  class KUDU_NO_EXPORT Data;
2498 
2499  // Owned.
2500  Data* data_;
2501 
2502  DISALLOW_COPY_AND_ASSIGN(KuduPartitionerBuilder);
2503 };
2504 
2515 class KUDU_EXPORT KuduPartitioner {
2516  public:
2517  ~KuduPartitioner();
2518 
2522  int NumPartitions() const;
2523 
2535  Status PartitionRow(const KuduPartialRow& row, int* partition);
2536  private:
2537  class KUDU_NO_EXPORT Data;
2538 
2539  friend class KuduPartitionerBuilder;
2540 
2541  explicit KuduPartitioner(Data* data);
2542  Data* data_; // Owned.
2543 };
2544 
2545 
2546 } // namespace client
2547 } // namespace kudu
2548 #endif
The interface for all logging callbacks.
Definition: callbacks.h:44
A single row update to be sent to the cluster.
Definition: write_op.h:194
A representation of a table&#39;s schema.
Definition: schema.h:531
A representation of an operation&#39;s outcome.
Definition: status.h:145
A constant cell value with a specific type.
Definition: value.h:35
Builder for Partitioner instances.
Definition: client.h:2461
ExternalConsistencyMode
The possible external consistency modes on which Kudu operates.
Definition: client.h:1485
A single row insert to be sent to the cluster.
Definition: write_op.h:142
Builder API for specifying or altering a column within a table schema.
Definition: schema.h:295
static const uint64_t kNoTimestamp
Definition: client.h:497
ReplicaSelection
Policy with which to choose amongst multiple replicas.
Definition: client.h:473
A single row upsert to be sent to the cluster.
Definition: write_op.h:167
Builds scan tokens for a table.
Definition: client.h:2357
ComparisonOp
Supported comparison operators.
Definition: scan_predicate.h:37
Alters an existing table based on the provided steps.
Definition: client.h:1129
OrderMode
Definition: client.h:1882
Definition: client.h:1888
Smart pointer typedefs for externally-faced code.
Definition: client.h:2515
A representation of comparison predicate for Kudu queries.
Definition: scan_predicate.h:34
An exclusive bound.
Definition: client.h:811
This class represents an error which occurred in a write operation.
Definition: client.h:1314
A handle for a connection to a cluster.
Definition: client.h:319
An inclusive bound.
Definition: client.h:812
In-memory representation of a remote tablet server.
Definition: client.h:629
The interface for all status callbacks.
Definition: callbacks.h:161
A wrapper around externally allocated data.
Definition: slice.h:50
A representation of a table on a particular cluster.
Definition: client.h:954
This class is a representation of a single scan.
Definition: client.h:1832
ReadMode
The read modes for scanners.
Definition: client.h:1835
A &quot;factory&quot; for KuduClient objects.
Definition: client.h:204
A single-row write operation to be sent to a Kudu table.
Definition: write_op.h:65
Select the LEADER replica.
Definition: client.h:474
RangePartitionBound
Range partition bound type.
Definition: client.h:810
In-memory representation of a remote tablet.
Definition: client.h:699
In-memory representation of a remote tablet&#39;s replica.
Definition: client.h:670
FlushMode
Modes of flush operations.
Definition: client.h:1424
A scan descriptor limited to a single physical contiguous location.
Definition: client.h:2297
A single row delete to be sent to the cluster.
Definition: write_op.h:221
A helper class to create a new table with the desired options.
Definition: client.h:729
A row which may only contain values for a subset of the columns.
Definition: partial_row.h:68
Representation of a Kudu client session.
Definition: client.h:1419
A representation of a time interval.
Definition: monotime.h:44