Export is_decompress_chunk_path / is_gapfill_path

This patch adds the 'ts_' prefix to the function names of
is_decompress_chunk_path and is_gapfill_path and makes them available
for use by other parts of TimescaleDB.
This commit is contained in:
Jan Nidzwetzki 2023-08-29 14:47:57 +02:00 committed by Jan Nidzwetzki
parent fa04a067e0
commit 08231c8aac
6 changed files with 51 additions and 37 deletions

View File

@ -10,6 +10,19 @@
#include "cross_module_fn.h"
#include "compat/compat.h"
#include "export.h"
#include "gapfill.h"
bool
ts_is_gapfill_path(Path *path)
{
if (IsA(path, CustomPath))
{
CustomPath *cpath = castNode(CustomPath, path);
if (strcmp(cpath->methods->CustomName, GAPFILL_PATH_NAME) == 0)
return true;
}
return false;
}
/*
* stub function to trigger locf and interpolate in gapfill node

13
src/gapfill.h Normal file
View File

@ -0,0 +1,13 @@
/*
* This file and its contents are licensed under the Apache License 2.0.
* Please see the included NOTICE for copyright information and
* LICENSE-APACHE for a copy of the license.
*/
#ifndef TIMESCALEDB_GAPFILL_H
#define TIMESCALEDB_GAPFILL_H
#define GAPFILL_PATH_NAME "GapFill"
extern bool ts_is_gapfill_path(Path *path);
#endif

View File

@ -68,6 +68,27 @@ create_group_subpath(PlannerInfo *root, RelOptInfo *rel, List *group, List *path
}
}
ChunkAppendPath *
ts_chunk_append_path_copy(ChunkAppendPath *ca, List *subpaths)
{
ListCell *lc;
double total_cost = 0, rows = 0;
ChunkAppendPath *new = palloc(sizeof(ChunkAppendPath));
memcpy(new, ca, sizeof(ChunkAppendPath));
new->cpath.custom_paths = subpaths;
foreach (lc, subpaths)
{
Path *child = lfirst(lc);
total_cost += child->total_cost;
rows += child->rows;
}
new->cpath.path.total_cost = total_cost;
new->cpath.path.rows = rows;
return new;
}
Path *
ts_chunk_append_path_create(PlannerInfo *root, RelOptInfo *rel, Hypertable *ht, Path *subpath,
bool parallel_aware, bool ordered, List *nested_oids)

View File

@ -22,6 +22,7 @@ typedef struct ChunkAppendPath
int first_partial_path;
} ChunkAppendPath;
extern TSDLLEXPORT ChunkAppendPath *ts_chunk_append_path_copy(ChunkAppendPath *ca, List *subpaths);
extern Path *ts_chunk_append_path_create(PlannerInfo *root, RelOptInfo *rel, Hypertable *ht,
Path *subpath, bool parallel_aware, bool ordered,
List *nested_oids);

View File

@ -23,6 +23,7 @@
#include "planner.h"
#include "import/planner.h"
#include "utils.h"
#include "gapfill.h"
#include "guc.h"
#include "estimate.h"
@ -38,19 +39,6 @@
* optimization fixes the statistics and adds the HashAggregate plan if appropriate.
* */
#define GAPFILL_PATH_NAME "GapFill"
static bool
is_gapfill_path(Path *path)
{
if (IsA(path, CustomPath))
{
CustomPath *cpath = castNode(CustomPath, path);
if (strcmp(cpath->methods->CustomName, GAPFILL_PATH_NAME) == 0)
return true;
}
return false;
}
/* Add a parallel HashAggregate plan.
* This code is similar to parts of create_grouping_paths */
static void
@ -163,7 +151,7 @@ ts_plan_add_hashagg(PlannerInfo *root, RelOptInfo *input_rel, RelOptInfo *output
return;
/* Don't add HashAgg path if this is a gapfill query */
if (is_gapfill_path(linitial(output_rel->pathlist)))
if (ts_is_gapfill_path(linitial(output_rel->pathlist)))
return;
MemSet(&agg_costs, 0, sizeof(AggClauseCosts));

View File

@ -56,7 +56,6 @@ static OpExpr *fix_indexqual(IndexOptInfo *index, RestrictInfo *rinfo, AttrNumbe
static bool build_skip_qual(PlannerInfo *root, SkipScanPath *skip_scan_path, IndexPath *index_path,
Var *var);
static List *build_subpath(PlannerInfo *root, List *subpaths, double ndistinct);
static ChunkAppendPath *copy_chunk_append_path(ChunkAppendPath *ca, List *subpaths);
static Var *get_distinct_var(PlannerInfo *root, IndexPath *index_path,
SkipScanPath *skip_scan_path);
static TargetEntry *tlist_member_match_var(Var *var, List *targetlist);
@ -293,7 +292,7 @@ tsl_skip_scan_paths_add(PlannerInfo *root, RelOptInfo *input_rel, RelOptInfo *ou
* information used for creating the original one and we don't want to
* duplicate all the checks done when creating the original one.
*/
subpath = (Path *) copy_chunk_append_path(ca, new_paths);
subpath = (Path *) ts_chunk_append_path_copy(ca, new_paths);
}
else
{
@ -318,27 +317,6 @@ tsl_skip_scan_paths_add(PlannerInfo *root, RelOptInfo *input_rel, RelOptInfo *ou
}
}
static ChunkAppendPath *
copy_chunk_append_path(ChunkAppendPath *ca, List *subpaths)
{
ListCell *lc;
double total_cost = 0, rows = 0;
ChunkAppendPath *new = palloc(sizeof(ChunkAppendPath));
memcpy(new, ca, sizeof(ChunkAppendPath));
new->cpath.custom_paths = subpaths;
foreach (lc, subpaths)
{
Path *child = lfirst(lc);
total_cost += child->total_cost;
rows += child->rows;
}
new->cpath.path.total_cost = total_cost;
new->cpath.path.rows = rows;
return new;
}
static SkipScanPath *
skip_scan_path_create(PlannerInfo *root, IndexPath *index_path, double ndistinct)
{