8000 One more small step of code refactoring. · postgrespro/aqo@521c8b6 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 521c8b6

Browse files
committed
One more small step of code refactoring.
We realized that plan serialization procedure and operations of removing substring is heavy. Core serialization code should be redesigned and rewrited.
1 parent 15b664f commit 521c8b6

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

aqo.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,6 @@ extern ExplainOneNode_hook_type prev_ExplainOneNode_hook;
274274
extern void ppi_hook(ParamPathInfo *ppi);
275275

276276
/* Hash functions */
277-
int get_query_hash(Query *parse, const char *query_text);
278-
extern int get_fss_for_object(List *relidslist, List *clauselist,
279-
List *selectivities, int *nfeatures,
280-
double **features);
281277
void get_eclasses(List *clauselist, int *nargs, int **args_hash,
282278
int **eclass_hash);
283279
int get_clause_hash(Expr *clause, int nargs, int *args_hash, int *eclass_hash);

cardinality_estimation.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "optimizer/optimizer.h"
2121

2222
#include "aqo.h"
23+
#include "hash.h"
2324

2425

2526
/*

hash.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ get_query_hash(Query *parse, const char *query_text)
6666
char *str_repr;
6767
int hash;
6868

69+
/* XXX: remove_locations and remove_consts are heavy routines. */
6970
str_repr = remove_locations(remove_consts(nodeToString(parse)));
7071
hash = DatumGetInt32(hash_any((const unsigned char *) str_repr,
7172
strlen(str_repr) * sizeof(*str_repr)));
@@ -344,7 +345,7 @@ get_unordered_int_list_hash(List *lst)
344345
* "<start_pattern>[^<end_pattern>]*" are replaced with substring
345346
* "<start_pattern>".
346347
*/
347-
char *
348+
static char *
348349
replace_patterns(const char *str, const char *start_pattern,
349350
bool (*end_pattern) (char ch))
350351
{
@@ -399,7 +400,7 @@ get_relidslist_hash(List *relidslist)
399400
* Returns the C-string in which the substrings of kind "{CONST.*}" are
400401
* replaced with substring "{CONST}".
401402
*/
402-
char *
403+
static char *
403404
remove_consts(const char *str)
404405
{
405406
char *res;
@@ -413,7 +414,7 @@ remove_consts(const char *str)
413414
* Returns the C-string in which the substrings of kind " :location.*}" are
414415
* replaced with substring " :location}".
415416
*/
416-
char *
417+
static char *
417418
remove_locations(const char *str)
418419
{
419420
return replace_patterns(str, " :location", is_brace);

hash.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
#include "nodes/pg_list.h"
55

6+
extern int get_query_hash(Query *parse, const char *query_text);
7+
extern int get_fss_for_object(List *relidslist, List *clauselist,
8+
List *selectivities, int *nfeatures,
9+
double **features);
610
extern int get_int_array_hash(int *arr, int len);
711
extern int get_grouped_exprs_hash(int fss, List *group_exprs);
812

ignorance.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef IGNORANCE_H
22
#define IGNORANCE_H
33

4-
#include "postgres.h"
5-
64
extern bool aqo_log_ignorance;
75

86
extern void set_ignorance(bool newval, void *extra);

path_utils.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "path_utils.h"
2020

2121
#include "aqo.h"
22+
#include "hash.h"
2223

2324

2425
/*

path_utils.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#ifndef PATH_UTILS_H
22
#define PATH_UTILS_H
33

4-
#include "postgres.h"
5-
64
#include "nodes/extensible.h"
75
#include "nodes/pathnodes.h"
86
#include "optimizer/planmain.h"

preprocessing.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include "commands/extension.h"
6464

6565
#include "aqo.h"
66+
#include "hash.h"
6667
#include "preprocessing.h"
6768

6869

0 commit comments

Comments
 (0)
0