Kudu C++ client API
scan_predicate.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 #ifndef KUDU_CLIENT_SCAN_PREDICATE_H
18 #define KUDU_CLIENT_SCAN_PREDICATE_H
19 
20 #ifdef KUDU_HEADERS_NO_STUBS
21 #include "kudu/gutil/macros.h"
22 #include "kudu/util/slice.h"
23 #else
24 #include "kudu/client/stubs.h"
25 #endif
26 
27 // NOTE: using stdint.h instead of cstdint because this file is supposed
28 // to be processed by a compiler lacking C++11 support.
29 #include <stdint.h>
30 
31 #include <cstddef>
32 
33 #include "kudu/client/hash.h"
34 #include "kudu/util/kudu_export.h"
35 #include "kudu/util/status.h"
36 
37 namespace kudu {
38 namespace client {
39 
43 class KUDU_EXPORT KuduPredicate {
44  public:
46  enum ComparisonOp {
47  LESS_EQUAL,
48  GREATER_EQUAL,
49  EQUAL,
50  LESS,
51  GREATER,
52  };
53 
54  ~KuduPredicate();
55 
57  KuduPredicate* Clone() const;
58 
63  class KUDU_NO_EXPORT Data;
64 
65  private:
66  friend class ComparisonPredicateData;
67  friend class ErrorPredicateData;
68  friend class InListPredicateData;
69  friend class IsNotNullPredicateData;
70  friend class IsNullPredicateData;
71  friend class KuduTable;
72  friend class ScanConfiguration;
73 
74  explicit KuduPredicate(Data* d);
75 
76  Data* data_;
77  DISALLOW_COPY_AND_ASSIGN(KuduPredicate);
78 };
79 
92 class KUDU_EXPORT KuduBloomFilter {
93  public:
94  ~KuduBloomFilter();
95 
100  void Insert(const Slice& key);
101 
102  private:
103  friend class InBloomFilterPredicateData;
104  friend class KuduBloomFilterBuilder;
105 
106  class KUDU_NO_EXPORT Data;
107 
108  // Owned ptr as per the PIMPL pattern.
109  Data* data_;
110 
116  KuduBloomFilter* Clone() const;
117 
118  KuduBloomFilter();
119 
124  explicit KuduBloomFilter(Data* other_data);
125 
126  DISALLOW_COPY_AND_ASSIGN(KuduBloomFilter);
127 };
128 
131 class KUDU_EXPORT KuduBloomFilterBuilder {
132  public:
135  explicit KuduBloomFilterBuilder(size_t num_keys);
137 
142  KuduBloomFilterBuilder& false_positive_probability(double fpp);
143 
149  KuduBloomFilterBuilder& hash_algorithm(HashAlgorithm hash_algorithm);
150 
156  KuduBloomFilterBuilder& hash_seed(uint32_t hash_seed);
157 
166  Status Build(KuduBloomFilter** bloom_filter);
167 
168  private:
169  class KUDU_NO_EXPORT Data;
170 
171  // Owned ptr as per the PIMPL pattern.
172  Data* data_;
173 
174  DISALLOW_COPY_AND_ASSIGN(KuduBloomFilterBuilder);
175 };
176 
177 } // namespace client
178 } // namespace kudu
179 #endif // KUDU_CLIENT_SCAN_PREDICATE_H
A representation of an operation&#39;s outcome.
Definition: status.h:165
Definition: callbacks.h:28
ComparisonOp
Supported comparison operators.
Definition: scan_predicate.h:46
A representation of comparison predicate for Kudu queries.
Definition: scan_predicate.h:43
Bloom filter to be used with IN Bloom filter predicate.
Definition: scan_predicate.h:92
A wrapper around externally allocated data.
Definition: slice.h:51
A representation of a table on a particular cluster.
Definition: client.h:1020
Builder class to help build KuduBloomFilter to be used with IN Bloom filter predicate.
Definition: scan_predicate.h:131