forked from Uradouby/cs660-pa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndexPredicate.cpp
More file actions
32 lines (23 loc) · 920 Bytes
/
Copy pathIndexPredicate.cpp
File metadata and controls
32 lines (23 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <db/IndexPredicate.h>
using namespace db;
IndexPredicate::IndexPredicate(Op op, const Field *fvalue) : op(op), fvalue(fvalue) {}
// Get the field from the predicate
const Field *IndexPredicate::getField() const {
return fvalue;
}
// Get the operator from the predicate
Op IndexPredicate::getOp() const {
return op;
}
// Check if two predicates are equal
bool IndexPredicate::operator==(const IndexPredicate &other) const {
return (op == other.op) && (fvalue->compare(Op::EQUALS, other.fvalue));
}
std::size_t std::hash<IndexPredicate>::operator()(const IndexPredicate &ipd) const {
// Compute the hash for the operation
std::size_t opHash = std::hash<int>{}(static_cast<int>(ipd.getOp()));
// Compute the hash for the Field's address (pointer)
std::size_t fieldHash = std::hash<const Field*>{}(ipd.getField());
// Combine the two hashes
return opHash * fieldHash;
}