forked from vincentlaucsb/csv-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfastpycsv_predicate.hpp
More file actions
57 lines (50 loc) · 1.75 KB
/
Copy pathfastpycsv_predicate.hpp
File metadata and controls
57 lines (50 loc) · 1.75 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include "fastpycsv_bindings.hpp"
enum class RowPredicateOp {
EQUAL,
LESS,
LESS_EQUAL,
GREATER,
GREATER_EQUAL
};
class RowPredicate {
public:
RowPredicate(std::string column, std::string value, bool case_sensitive = true);
RowPredicate(std::string column, std::string value, RowPredicateOp op, bool case_sensitive = true);
explicit RowPredicate(std::vector<RowPredicate> predicates);
const std::string& column() const noexcept;
const std::string& value() const noexcept;
bool case_sensitive() const noexcept;
RowPredicateOp op() const noexcept;
bool is_all_of() const noexcept;
const std::vector<RowPredicate>& children() const noexcept;
bool matches(csv::string_view candidate) const;
size_t column_index(const std::vector<std::string>& columns) const;
void validate_columns(const std::vector<std::string>& columns) const;
private:
std::string column_;
std::string value_;
RowPredicateOp op_ = RowPredicateOp::EQUAL;
bool case_sensitive_ = true;
long double numeric_value_ = 0;
bool has_numeric_value_ = false;
std::vector<RowPredicate> children_;
};
const RowPredicate* optional_row_predicate(nb::object predicate);
std::vector<std::uint8_t> excluded_rows_for_predicate(
const DataFrame<>& frame,
const std::vector<std::uint8_t>& deleted_rows,
const RowPredicate* predicate
);
std::vector<std::uint8_t> included_rows_for_predicate(
const DataFrame<>& frame,
const std::vector<std::uint8_t>& deleted_rows,
const RowPredicate& predicate
);
size_t mark_matching_rows(
const DataFrame<>& frame,
std::vector<std::uint8_t>& deleted_rows,
size_t& pending_delete_count,
const RowPredicate& predicate
);
void init_CSVPredicate(nb::module_& m);