Skip to content
This repository was archived by the owner on Sep 27, 2019. It is now read-only.

Commit ca8366c

Browse files
pmenonapavlo
authored andcommitted
Documentation
1 parent 84429f4 commit ca8366c

File tree

2 files changed

+179
-94
lines changed

2 files changed

+179
-94
lines changed

src/include/index/art_index.h

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,47 @@ class ArtIndex : public Index {
3232
// Forward declare iterator class for later
3333
class Iterator;
3434

35-
/// Insert the given key-value pair into the index
3635
bool InsertEntry(const storage::Tuple *key, ItemPointer *value) override;
3736

38-
/// Delete the given key-value pair from the index
3937
bool DeleteEntry(const storage::Tuple *key, ItemPointer *value) override;
4038

41-
/// Insert the given key-value pair into the index, but only if the predicate
42-
/// returns false for every instance of the given key in the index
4339
bool CondInsertEntry(const storage::Tuple *key, ItemPointer *value,
4440
std::function<bool(const void *)> predicate) override;
4541

46-
/// Scan the range of keys between [start,end] inclusive, placing results in
47-
/// the provided result vector
42+
/**
43+
* Perform a range scan of keys between [start,end] inclusive.
44+
*
45+
* @param start The start key
46+
* @param end The end key
47+
* @param[out] result Where the results of the scan are stored
48+
* @param scan_predicate
49+
*/
4850
void ScanRange(const storage::Tuple *start, const storage::Tuple *end,
4951
std::vector<ItemPointer *> &result);
5052

51-
/// Perform a scan, using the predicate, and place the results into the
52-
/// provided result vector
53+
/**
54+
* ArtIndex throws away the first three arguments and only uses the conjuncts
55+
* from the scan predicate.
56+
*
57+
* @param scan_predicate The only predicate that's actually used.
58+
* @param[out] result Where the results of the scan are stored
59+
*/
5360
void Scan(const std::vector<type::Value> &values,
5461
const std::vector<oid_t> &key_column_ids,
5562
const std::vector<ExpressionType> &expr_types,
5663
ScanDirectionType scan_direction,
5764
std::vector<ItemPointer *> &result,
5865
const ConjunctionScanPredicate *scan_predicate) override;
5966

60-
/// Perform a limited scan
67+
/**
68+
* ArtIndex throws away the first three arguments and only uses the conjuncts
69+
* from the scan predicate.
70+
*
71+
* @param scan_predicate The only parameter that's used
72+
* @param[out] result Where the results of the scan are stored
73+
* @param limit How many results to actually return
74+
* @param offset How many items to exclude from the results
75+
*/
6176
void ScanLimit(const std::vector<type::Value> &values,
6277
const std::vector<oid_t> &key_column_ids,
6378
const std::vector<ExpressionType> &expr_types,
@@ -66,10 +81,8 @@ class ArtIndex : public Index {
6681
const ConjunctionScanPredicate *scan_predicate, uint64_t limit,
6782
uint64_t offset) override;
6883

69-
/// Scan the entire index, placing results in the provided result vector
7084
void ScanAllKeys(std::vector<ItemPointer *> &result) override;
7185

72-
/// Scan all values for the given key, placing results in the provided vector
7386
void ScanKey(const storage::Tuple *key,
7487
std::vector<ItemPointer *> &result) override;
7588

@@ -81,19 +94,30 @@ class ArtIndex : public Index {
8194
// TODO(pmenon): Implement me
8295
size_t GetMemoryFootprint() override { return 0; }
8396

84-
/// Does the index need GC
8597
// TODO(pmenon): Implement me
8698
bool NeedGC() override { return false; }
8799

88-
/// Perform any necessary GC on the index
89100
// TODO(pmenon): Implement me
90101
void PerformGC() override {}
91102

92-
/// These two functions are for testing so we can inject custom key loading
93-
/// functions without bringing up a full-blown database/table.
103+
/**
104+
* Configure the load-key function for this index. The load-key function
105+
* retrieves the key associated with a given value in the tree. This is
106+
* necessary because an ART index does not always store the whole key in the
107+
* tree due to prefix compression.
108+
*
109+
* @param load_func The loading key function pointer
110+
* @param ctx An opaque pointer to some user-provided context. This context is
111+
* passed as the first argument to the load-key function on each invocation.
112+
*/
94113
void SetLoadKeyFunc(art::Tree::LoadKeyFunction load_func, void *ctx);
95114

96-
/// Construct an ART key from a Peloton key
115+
/**
116+
* Convert the provided Peloton key into an ART-based key
117+
*
118+
* @param tuple The input key we'd like to convert
119+
* @param[out] key Where the art-compatible key is written to
120+
*/
97121
void ConstructArtKey(const AbstractTuple &tuple, art::Key &key) const {
98122
key_constructor_.ConstructKey(tuple, key);
99123
}
@@ -112,10 +136,21 @@ class ArtIndex : public Index {
112136
explicit KeyConstructor(const catalog::Schema &key_schema)
113137
: key_schema_(key_schema) {}
114138

115-
/// Given an input Peloton key, construct an equivalent art::Key
139+
/**
140+
* Given an input Peloton key, construct an equivalent art::Key
141+
*
142+
* @param input_key The input (i.e., Peloton key)
143+
* @param[out] tree_key Where the tree-compatible key is written
144+
*/
116145
void ConstructKey(const AbstractTuple &input_key, art::Key &tree_key) const;
117146

118-
/// Generate the minimum and maximum key
147+
/**
148+
* Generate the minimum and maximum key, storing the results in the provided
149+
* min_key and max_key function parameters
150+
*
151+
* @param[out] min_key Where the minimum key is written
152+
* @param[out] max_key Where the maximum key is written
153+
*/
119154
void ConstructMinMaxKey(art::Key &min_key, art::Key &max_key) const;
120155

121156
private:

0 commit comments

Comments
 (0)