Skip to content

Commit

Permalink
Move vacuum_ao.c to src/backend/access/appendonly
Browse files Browse the repository at this point in the history
  • Loading branch information
andr-sokolov committed Oct 28, 2024
1 parent 652522d commit a3a5e5b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 39 deletions.
18 changes: 2 additions & 16 deletions src/backend/access/aocs/aocsam_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "catalog/pg_attribute_encoding.h"
#include "catalog/storage.h"
#include "catalog/storage_xlog.h"
#include "cdb/appendonly_vacuum.h"
#include "cdb/cdbappendonlyam.h"
#include "cdb/cdbaocsam.h"
#include "cdb/cdbvars.h"
Expand Down Expand Up @@ -1397,21 +1398,6 @@ aoco_relation_copy_data(Relation rel, const RelFileNode *newrnode)
smgrclose(dstrel);
}

static void
aoco_vacuum_rel(Relation onerel, VacuumParams *params,
BufferAccessStrategy bstrategy)
{
/*
* We VACUUM an AO_COLUMN table through multiple phases. vacuum_rel()
* orchestrates the phases and calls itself again for each phase, so we
* get here for every phase. ao_vacuum_rel() is a wrapper of dedicated
* ao_vacuum_rel_*() functions for the specific phases.
*/
ao_vacuum_rel(onerel, params, bstrategy);

return;
}

static void
aoco_relation_add_columns(Relation rel, List *newvals, List *constraints, TupleDesc oldDesc)
{
Expand Down Expand Up @@ -2811,7 +2797,7 @@ static const TableAmRoutine ao_column_methods = {
.relation_copy_for_cluster = aoco_relation_copy_for_cluster,
.relation_add_columns = aoco_relation_add_columns,
.relation_rewrite_columns = aoco_relation_rewrite_columns,
.relation_vacuum = aoco_vacuum_rel,
.relation_vacuum = ao_vacuum_rel,
.scan_analyze_next_block = aoco_scan_analyze_next_block,
.scan_analyze_next_tuple = aoco_scan_analyze_next_tuple,
.relation_acquire_sample_rows = aoco_acquire_sample_rows,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/access/appendonly/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ OBJS = appendonlyam_handler.o appendonlyam.o aosegfiles.o aomd.o \
appendonlyblockdirectory.o appendonly_visimap.o \
appendonly_visimap_entry.o appendonly_visimap_store.o \
appendonly_compaction.o appendonly_visimap_udf.o \
appendonly_blkdir_udf.o aomd_filehandler.o
appendonly_blkdir_udf.o aomd_filehandler.o appendonly_vacuum.o

include $(top_srcdir)/src/backend/common.mk

Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
#include "utils/lsyscache.h"
#include "utils/pg_rusage.h"
#include "cdb/cdbappendonlyblockdirectory.h"
#include "cdb/appendonly_vacuum.h"


static void vacuum_appendonly_index(Relation indexRelation,
Expand All @@ -163,6 +164,7 @@ static void ao_vacuum_rel_recycle_dead_segments(Relation onerel, VacuumParams *p
BufferAccessStrategy bstrategy, AOVacuumRelStats *vacrelstats);
static AOVacuumRelStats *init_vacrelstats(void);
static void cleanup_vacrelstats(AOVacuumRelStats **vacrelstatsp);
static void scan_index(Relation indrel, Relation aorel, int elevel, BufferAccessStrategy vac_strategy);

static void
ao_vacuum_rel_pre_cleanup(Relation onerel, VacuumParams *params, BufferAccessStrategy bstrategy, AOVacuumRelStats *vacrelstats)
Expand Down Expand Up @@ -781,7 +783,7 @@ cleanup_vacrelstats(AOVacuumRelStats **vacrelstats)
*
* We use this when we have no deletions to do.
*/
void
static void
scan_index(Relation indrel, Relation aorel, int elevel, BufferAccessStrategy vac_strategy)
{
IndexBulkDeleteResult *stats;
Expand Down
18 changes: 2 additions & 16 deletions src/backend/access/appendonly/appendonlyam_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "catalog/pg_type.h"
#include "catalog/storage.h"
#include "catalog/storage_xlog.h"
#include "cdb/appendonly_vacuum.h"
#include "cdb/cdbappendonlyam.h"
#include "cdb/cdbvars.h"
#include "commands/progress.h"
Expand Down Expand Up @@ -1161,21 +1162,6 @@ appendonly_relation_copy_data(Relation rel, const RelFileNode *newrnode)
smgrclose(dstrel);
}

static void
appendonly_vacuum_rel(Relation onerel, VacuumParams *params,
BufferAccessStrategy bstrategy)
{
/*
* We VACUUM an AO_ROW table through multiple phases. vacuum_rel()
* orchestrates the phases and calls itself again for each phase, so we
* get here for every phase. ao_vacuum_rel() is a wrapper of dedicated
* ao_vacuum_rel_*() functions for the specific phases.
*/
ao_vacuum_rel(onerel, params, bstrategy);

return;
}

static void
appendonly_relation_add_columns(Relation rel, List *newvals, List *constraints, TupleDesc oldDesc)
{
Expand Down Expand Up @@ -2455,7 +2441,7 @@ static const TableAmRoutine ao_row_methods = {
.relation_copy_for_cluster = appendonly_relation_copy_for_cluster,
.relation_add_columns = appendonly_relation_add_columns,
.relation_rewrite_columns = appendonly_relation_rewrite_columns,
.relation_vacuum = appendonly_vacuum_rel,
.relation_vacuum = ao_vacuum_rel,
.scan_analyze_next_block = appendonly_scan_analyze_next_block,
.scan_analyze_next_tuple = appendonly_scan_analyze_next_tuple,
.relation_acquire_sample_rows = appendonly_acquire_sample_rows,
Expand Down
2 changes: 1 addition & 1 deletion src/backend/commands/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ OBJS = amcmds.o aggregatecmds.o alter.o analyze.o async.o cluster.o comment.o \
vacuum.o variable.o view.o

OBJS += analyzefuncs.o analyzeutils.o extprotocolcmds.o exttablecmds.o queue.o
OBJS += resgroupcmds.o tablecmds_gp.o vacuum_ao.o
OBJS += resgroupcmds.o tablecmds_gp.o

include $(top_srcdir)/src/backend/common.mk
10 changes: 10 additions & 0 deletions src/include/cdb/appendonly_vacuum.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef APPENDONLY_VACUUM_H
#define APPENDONLY_VACUUM_H

#include <commands/vacuum.h>
#include <utils/relcache.h>
#include <storage/buf.h>

void ao_vacuum_rel(Relation rel, VacuumParams *params, BufferAccessStrategy bstrategy);

#endif /* APPENDONLY_VACUUM_H */
4 changes: 0 additions & 4 deletions src/include/commands/vacuum.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,6 @@ extern int gp_acquire_sample_rows_func(Relation onerel, int elevel,
/* in commands/vacuumlazy.c */
extern void lazy_vacuum_rel_heap(Relation onerel,
VacuumParams *params, BufferAccessStrategy bstrategy);
extern void scan_index(Relation indrel, Relation aorel, int elevel, BufferAccessStrategy bstrategy);

/* in commands/vacuum_ao.c */
extern void ao_vacuum_rel(Relation rel, VacuumParams *params, BufferAccessStrategy bstrategy);

extern bool std_typanalyze(VacAttrStats *stats);

Expand Down

0 comments on commit a3a5e5b

Please sign in to comment.