|
144 | 144 | #include "utils/fmgroids.h" |
145 | 145 | #include "utils/snapmgr.h" |
146 | 146 |
|
| 147 | +#include "machine_learning.h" |
147 | 148 |
|
148 | 149 | /* Check PostgreSQL version (9.6.0 contains important changes in planner) */ |
149 | 150 | #if PG_VERSION_NUM < 90600 |
@@ -237,12 +238,6 @@ extern double auto_tuning_convergence_error; |
237 | 238 |
|
238 | 239 | /* Machine learning parameters */ |
239 | 240 |
|
240 | | -/* Max number of matrix rows - max number of possible neighbors. */ |
241 | | -#define aqo_K (30) |
242 | | - |
243 | | -extern const double object_selection_prediction_threshold; |
244 | | -extern const double object_selection_threshold; |
245 | | -extern const double learning_rate; |
246 | 241 | extern int aqo_k; |
247 | 242 | extern double log_selectivity_lower_bound; |
248 | 243 |
|
@@ -285,17 +280,13 @@ extern bool find_query(uint64 qhash, QueryContextData *ctx); |
285 | 280 | extern bool update_query(uint64 qhash, uint64 fhash, |
286 | 281 | bool learn_aqo, bool use_aqo, bool auto_tuning); |
287 | 282 | extern bool add_query_text(uint64 query_hash, const char *query_string); |
288 | | -extern bool load_fss_ext(uint64 fs, int fss, |
289 | | - int ncols, double **matrix, double *targets, int *rows, |
| 283 | +extern bool load_fss_ext(uint64 fs, int fss, OkNNrdata *data, |
290 | 284 | List **relids, bool isSafe); |
291 | | -extern bool load_fss(uint64 fhash, int fss_hash, |
292 | | - int ncols, double **matrix, double *targets, int *rows, |
293 | | - List **relids); |
294 | | -extern bool update_fss_ext(uint64 fhash, int fsshash, int nrows, int ncols, |
295 | | - double **matrix, double *targets, List *relids, |
296 | | - bool isTimedOut); |
297 | | -extern bool update_fss(uint64 fhash, int fss_hash, int nrows, int ncols, |
298 | | - double **matrix, double *targets, List *relids); |
| 285 | +extern bool load_fss(uint64 fhash, int fss_hash, OkNNrdata *data, List **relids); |
| 286 | +extern bool update_fss_ext(uint64 fhash, int fsshash, OkNNrdata *data, |
| 287 | + List *relids, bool isTimedOut); |
| 288 | +extern bool update_fss(uint64 fhash, int fss_hash, OkNNrdata *data, |
| 289 | + List *relids); |
299 | 290 | QueryStat *get_aqo_stat(uint64 query_hash); |
300 | 291 | void update_aqo_stat(uint64 query_hash, QueryStat * stat); |
301 | 292 | extern bool my_index_insert(Relation indexRelation, Datum *values, bool *isnull, |
@@ -324,14 +315,6 @@ void aqo_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, |
324 | 315 | uint64 count, bool execute_once); |
325 | 316 | void aqo_ExecutorEnd(QueryDesc *queryDesc); |
326 | 317 |
|
327 | | -/* Machine learning techniques */ |
328 | | -extern double OkNNr_predict(int nrows, int ncols, |
329 | | - double **matrix, const double *targets, |
330 | | - double *features); |
331 | | -extern int OkNNr_learn(int matrix_rows, int matrix_cols, |
332 | | - double **matrix, double *targets, |
333 | | - double *features, double target); |
334 | | - |
335 | 318 | /* Automatic query tuning */ |
336 | 319 | extern void automatical_query_tuning(uint64 query_hash, QueryStat * stat); |
337 | 320 |
|
|
0 commit comments