@@ -40,48 +40,11 @@ struct PERSPECTIVE_EXPORT t_expression_error {
4040 t_index m_column;
4141};
4242
43- /* *
44- * @brief Contains the metadata for a single expression and the methods which
45- * will compute the expression's output.
46- */
47- class PERSPECTIVE_EXPORT t_computed_expression {
48- public:
49- PSP_NON_COPYABLE (t_computed_expression);
50-
51- t_computed_expression (
52- std::string expression_alias,
53- std::string expression_string,
54- std::string parsed_expression_string,
55- const std::vector<std::pair<std::string, std::string>>& column_ids,
56- t_dtype dtype
57- );
58-
59- void compute (
60- const std::shared_ptr<t_data_table>& source_table,
61- const t_gstate::t_mapping& pkey_map,
62- const std::shared_ptr<t_data_table>& destination_table,
63- t_expression_vocab& vocab,
64- t_regex_mapping& regex_mapping
65- ) const ;
66-
67- const std::string& get_expression_alias () const ;
68- const std::string& get_expression_string () const ;
69- const std::string& get_parsed_expression_string () const ;
70- const std::vector<std::pair<std::string, std::string>>&
71- get_column_ids () const ;
72- t_dtype get_dtype () const ;
73-
74- private:
75- std::string m_expression_alias;
76- std::string m_expression_string;
77- std::string m_parsed_expression_string;
78- std::vector<std::pair<std::string, std::string>> m_column_ids;
79- t_dtype m_dtype;
80- };
43+ class PERSPECTIVE_EXPORT t_computed_expression;
8144
8245class PERSPECTIVE_EXPORT t_computed_expression_parser {
8346public:
84- static void init ();
47+ t_computed_expression_parser ();
8548
8649 /* *
8750 * @brief Given expression strings, validate the expression's dtype and
@@ -100,7 +63,7 @@ class PERSPECTIVE_EXPORT t_computed_expression_parser {
10063 * @param schema
10164 * @return std::shared_ptr<t_computed_expression>
10265 */
103- static std::shared_ptr<t_computed_expression> precompute (
66+ std::shared_ptr<t_computed_expression> precompute (
10467 const std::string& expression_alias,
10568 const std::string& expression_string,
10669 const std::string& parsed_expression_string,
@@ -110,7 +73,7 @@ class PERSPECTIVE_EXPORT t_computed_expression_parser {
11073 const std::shared_ptr<t_schema>& schema,
11174 t_expression_vocab& vocab,
11275 t_regex_mapping& regex_mapping
113- );
76+ ) const ;
11477
11578 /* *
11679 * @brief Returns the dtype of the given expression, or `DTYPE_NONE`
@@ -132,7 +95,7 @@ class PERSPECTIVE_EXPORT t_computed_expression_parser {
13295 * @param error_string
13396 * @return t_dtype
13497 */
135- static t_dtype get_dtype (
98+ t_dtype get_dtype (
13699 const std::string& expression_alias,
137100 const std::string& expression_string,
138101 const std::string& parsed_expression_string,
@@ -143,12 +106,9 @@ class PERSPECTIVE_EXPORT t_computed_expression_parser {
143106 t_expression_error& error,
144107 t_expression_vocab& vocab,
145108 t_regex_mapping& regex_mapping
146- );
147-
148- static std::shared_ptr<exprtk::parser<t_tscalar>> PARSER ;
109+ ) const ;
149110
150- // Applied to the parser
151- static std::size_t PARSER_COMPILE_OPTIONS ;
111+ std::shared_ptr<exprtk::parser<t_tscalar>> m_parser;
152112
153113 // Static computed functions have no state
154114 static computed_function::bucket BUCKET_FN ;
@@ -176,6 +136,46 @@ class PERSPECTIVE_EXPORT t_computed_expression_parser {
176136 static t_tscalar FALSE_SCALAR ;
177137};
178138
139+ /* *
140+ * @brief Contains the metadata for a single expression and the methods which
141+ * will compute the expression's output.
142+ */
143+ class PERSPECTIVE_EXPORT t_computed_expression {
144+ public:
145+ PSP_NON_COPYABLE (t_computed_expression);
146+
147+ t_computed_expression (
148+ std::string expression_alias,
149+ std::string expression_string,
150+ std::string parsed_expression_string,
151+ const std::vector<std::pair<std::string, std::string>>& column_ids,
152+ t_dtype dtype
153+ );
154+
155+ void compute (
156+ const std::shared_ptr<t_data_table>& source_table,
157+ const t_gstate::t_mapping& pkey_map,
158+ const std::shared_ptr<t_data_table>& destination_table,
159+ t_expression_vocab& vocab,
160+ t_regex_mapping& regex_mapping
161+ ) const ;
162+
163+ const std::string& get_expression_alias () const ;
164+ const std::string& get_expression_string () const ;
165+ const std::string& get_parsed_expression_string () const ;
166+ const std::vector<std::pair<std::string, std::string>>&
167+ get_column_ids () const ;
168+ t_dtype get_dtype () const ;
169+
170+ private:
171+ std::string m_expression_alias;
172+ std::string m_expression_string;
173+ std::string m_parsed_expression_string;
174+ t_computed_expression_parser m_computed_expression_parser;
175+ std::vector<std::pair<std::string, std::string>> m_column_ids;
176+ t_dtype m_dtype;
177+ };
178+
179179/* *
180180 * @brief a `t_schema`-like container for validated expression results that
181181 * offers fast lookups.
0 commit comments