mirror of https://github.com/citusdata/citus.git
Columnar: clean up old references to cstore.
parent
941c8fbf32
commit
53f7b019d5
|
@ -1,6 +1,6 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* cstore.c
|
||||
* columnar.c
|
||||
*
|
||||
* This file contains...
|
||||
*
|
||||
|
@ -21,7 +21,7 @@
|
|||
#include "utils/rel.h"
|
||||
|
||||
#include "citus_version.h"
|
||||
#include "columnar/cstore.h"
|
||||
#include "columnar/columnar.h"
|
||||
|
||||
/* Default values for option parameters */
|
||||
#define DEFAULT_STRIPE_ROW_COUNT 150000
|
||||
|
@ -57,7 +57,7 @@ void
|
|||
columnar_init_gucs()
|
||||
{
|
||||
DefineCustomEnumVariable("columnar.compression",
|
||||
"Compression type for cstore.",
|
||||
"Compression type for columnar.",
|
||||
NULL,
|
||||
&columnar_compression,
|
||||
DEFAULT_COMPRESSION_TYPE,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* cstore_compression.c
|
||||
* columnar_compression.c
|
||||
*
|
||||
* This file contains compression/decompression functions definitions
|
||||
* used in cstore_fdw.
|
||||
* used for columnar.
|
||||
*
|
||||
* Copyright (c) 2016, Citus Data, Inc.
|
||||
*
|
||||
|
@ -14,7 +14,7 @@
|
|||
#include "postgres.h"
|
||||
|
||||
#include "citus_version.h"
|
||||
#include "columnar/cstore.h"
|
||||
#include "columnar/columnar.h"
|
||||
#include "common/pg_lzcompress.h"
|
||||
|
||||
#if HAVE_LIBLZ4
|
||||
|
@ -29,21 +29,22 @@
|
|||
* The information at the start of the compressed data. This decription is taken
|
||||
* from pg_lzcompress in pre-9.5 version of PostgreSQL.
|
||||
*/
|
||||
typedef struct CStoreCompressHeader
|
||||
typedef struct ColumnarCompressHeader
|
||||
{
|
||||
int32 vl_len_; /* varlena header (do not touch directly!) */
|
||||
int32 rawsize;
|
||||
} CStoreCompressHeader;
|
||||
} ColumnarCompressHeader;
|
||||
|
||||
/*
|
||||
* Utilities for manipulation of header information for compressed data
|
||||
*/
|
||||
|
||||
#define CSTORE_COMPRESS_HDRSZ ((int32) sizeof(CStoreCompressHeader))
|
||||
#define CSTORE_COMPRESS_RAWSIZE(ptr) (((CStoreCompressHeader *) (ptr))->rawsize)
|
||||
#define CSTORE_COMPRESS_RAWDATA(ptr) (((char *) (ptr)) + CSTORE_COMPRESS_HDRSZ)
|
||||
#define CSTORE_COMPRESS_SET_RAWSIZE(ptr, len) (((CStoreCompressHeader *) (ptr))->rawsize = \
|
||||
(len))
|
||||
#define COLUMNAR_COMPRESS_HDRSZ ((int32) sizeof(ColumnarCompressHeader))
|
||||
#define COLUMNAR_COMPRESS_RAWSIZE(ptr) (((ColumnarCompressHeader *) (ptr))->rawsize)
|
||||
#define COLUMNAR_COMPRESS_RAWDATA(ptr) (((char *) (ptr)) + COLUMNAR_COMPRESS_HDRSZ)
|
||||
#define COLUMNAR_COMPRESS_SET_RAWSIZE(ptr, \
|
||||
len) (((ColumnarCompressHeader *) (ptr))->rawsize = \
|
||||
(len))
|
||||
|
||||
|
||||
/*
|
||||
|
@ -116,7 +117,7 @@ CompressBuffer(StringInfo inputBuffer,
|
|||
case COMPRESSION_PG_LZ:
|
||||
{
|
||||
uint64 maximumLength = PGLZ_MAX_OUTPUT(inputBuffer->len) +
|
||||
CSTORE_COMPRESS_HDRSZ;
|
||||
COLUMNAR_COMPRESS_HDRSZ;
|
||||
bool compressionResult = false;
|
||||
|
||||
resetStringInfo(outputBuffer);
|
||||
|
@ -124,14 +125,14 @@ CompressBuffer(StringInfo inputBuffer,
|
|||
|
||||
int32 compressedByteCount = pglz_compress((const char *) inputBuffer->data,
|
||||
inputBuffer->len,
|
||||
CSTORE_COMPRESS_RAWDATA(
|
||||
COLUMNAR_COMPRESS_RAWDATA(
|
||||
outputBuffer->data),
|
||||
PGLZ_strategy_always);
|
||||
if (compressedByteCount >= 0)
|
||||
{
|
||||
CSTORE_COMPRESS_SET_RAWSIZE(outputBuffer->data, inputBuffer->len);
|
||||
COLUMNAR_COMPRESS_SET_RAWSIZE(outputBuffer->data, inputBuffer->len);
|
||||
SET_VARSIZE_COMPRESSED(outputBuffer->data,
|
||||
compressedByteCount + CSTORE_COMPRESS_HDRSZ);
|
||||
compressedByteCount + COLUMNAR_COMPRESS_HDRSZ);
|
||||
compressionResult = true;
|
||||
}
|
||||
|
||||
|
@ -224,11 +225,11 @@ DecompressBuffer(StringInfo buffer,
|
|||
case COMPRESSION_PG_LZ:
|
||||
{
|
||||
StringInfo decompressedBuffer = NULL;
|
||||
uint32 compressedDataSize = VARSIZE(buffer->data) - CSTORE_COMPRESS_HDRSZ;
|
||||
uint32 decompressedDataSize = CSTORE_COMPRESS_RAWSIZE(buffer->data);
|
||||
uint32 compressedDataSize = VARSIZE(buffer->data) - COLUMNAR_COMPRESS_HDRSZ;
|
||||
uint32 decompressedDataSize = COLUMNAR_COMPRESS_RAWSIZE(buffer->data);
|
||||
int32 decompressedByteCount = 0;
|
||||
|
||||
if (compressedDataSize + CSTORE_COMPRESS_HDRSZ != buffer->len)
|
||||
if (compressedDataSize + COLUMNAR_COMPRESS_HDRSZ != buffer->len)
|
||||
{
|
||||
ereport(ERROR, (errmsg("cannot decompress the buffer"),
|
||||
errdetail("Expected %u bytes, but received %u bytes",
|
||||
|
@ -238,11 +239,13 @@ DecompressBuffer(StringInfo buffer,
|
|||
char *decompressedData = palloc0(decompressedDataSize);
|
||||
|
||||
#if PG_VERSION_NUM >= 120000
|
||||
decompressedByteCount = pglz_decompress(CSTORE_COMPRESS_RAWDATA(buffer->data),
|
||||
decompressedByteCount = pglz_decompress(COLUMNAR_COMPRESS_RAWDATA(
|
||||
buffer->data),
|
||||
compressedDataSize, decompressedData,
|
||||
decompressedDataSize, true);
|
||||
#else
|
||||
decompressedByteCount = pglz_decompress(CSTORE_COMPRESS_RAWDATA(buffer->data),
|
||||
decompressedByteCount = pglz_decompress(COLUMNAR_COMPRESS_RAWDATA(
|
||||
buffer->data),
|
||||
compressedDataSize, decompressedData,
|
||||
decompressedDataSize);
|
||||
#endif
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
#include "optimizer/restrictinfo.h"
|
||||
#include "utils/relcache.h"
|
||||
|
||||
#include "columnar/cstore.h"
|
||||
#include "columnar/cstore_customscan.h"
|
||||
#include "columnar/cstore_tableam.h"
|
||||
#include "columnar/columnar.h"
|
||||
#include "columnar/columnar_customscan.h"
|
||||
#include "columnar/columnar_tableam.h"
|
||||
|
||||
typedef struct ColumnarScanPath
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ const struct CustomExecMethods ColumnarExecuteMethods = {
|
|||
|
||||
/*
|
||||
* columnar_customscan_init installs the hook required to intercept the postgres planner and
|
||||
* provide extra paths for cstore tables
|
||||
* provide extra paths for columnar tables
|
||||
*/
|
||||
void
|
||||
columnar_customscan_init()
|
||||
|
@ -158,7 +158,7 @@ ColumnarSetRelPathlistHook(PlannerInfo *root, RelOptInfo *rel, Index rti,
|
|||
}
|
||||
|
||||
/*
|
||||
* Here we want to inspect if this relation pathlist hook is accessing a cstore table.
|
||||
* Here we want to inspect if this relation pathlist hook is accessing a columnar table.
|
||||
* If that is the case we want to insert an extra path that pushes down the projection
|
||||
* into the scan of the table to minimize the data read.
|
||||
*/
|
||||
|
@ -173,7 +173,7 @@ ColumnarSetRelPathlistHook(PlannerInfo *root, RelOptInfo *rel, Index rti,
|
|||
|
||||
Path *customPath = CreateColumnarScanPath(rel, rte);
|
||||
|
||||
ereport(DEBUG1, (errmsg("pathlist hook for cstore table am")));
|
||||
ereport(DEBUG1, (errmsg("pathlist hook for columnar table am")));
|
||||
|
||||
/* we propose a new path that will be the only path for scanning this relation */
|
||||
clear_paths(rel);
|
||||
|
@ -204,7 +204,7 @@ CreateColumnarScanPath(RelOptInfo *rel, RangeTblEntry *rte)
|
|||
path->pathtarget = rel->reltarget;
|
||||
|
||||
/*
|
||||
* Add cost estimates for a cstore table scan, row count is the rows estimated by
|
||||
* Add cost estimates for a columnar table scan, row count is the rows estimated by
|
||||
* postgres' planner.
|
||||
*/
|
||||
path->rows = rel->rows;
|
||||
|
@ -216,7 +216,7 @@ CreateColumnarScanPath(RelOptInfo *rel, RangeTblEntry *rte)
|
|||
|
||||
|
||||
/*
|
||||
* ColumnarScanCost calculates the cost of scanning the cstore table. The cost is estimated
|
||||
* ColumnarScanCost calculates the cost of scanning the columnar table. The cost is estimated
|
||||
* by using all stripe metadata to estimate based on the columns to read how many pages
|
||||
* need to be read.
|
||||
*/
|
||||
|
@ -277,13 +277,13 @@ ColumnarScanPath_PlanCustomPath(PlannerInfo *root,
|
|||
static Node *
|
||||
ColumnarScan_CreateCustomScanState(CustomScan *cscan)
|
||||
{
|
||||
ColumnarScanState *cstorescanstate = (ColumnarScanState *) newNode(
|
||||
ColumnarScanState *columnarScanState = (ColumnarScanState *) newNode(
|
||||
sizeof(ColumnarScanState), T_CustomScanState);
|
||||
|
||||
CustomScanState *cscanstate = &cstorescanstate->custom_scanstate;
|
||||
CustomScanState *cscanstate = &columnarScanState->custom_scanstate;
|
||||
cscanstate->methods = &ColumnarExecuteMethods;
|
||||
|
||||
cstorescanstate->qual = cscan->scan.plan.qual;
|
||||
columnarScanState->qual = cscan->scan.plan.qual;
|
||||
|
||||
return (Node *) cscanstate;
|
||||
}
|
||||
|
@ -338,9 +338,9 @@ ColumnarAttrNeeded(ScanState *ss)
|
|||
|
||||
|
||||
static TupleTableSlot *
|
||||
ColumnarScanNext(ColumnarScanState *cstorescanstate)
|
||||
ColumnarScanNext(ColumnarScanState *columnarScanState)
|
||||
{
|
||||
CustomScanState *node = (CustomScanState *) cstorescanstate;
|
||||
CustomScanState *node = (CustomScanState *) columnarScanState;
|
||||
|
||||
/*
|
||||
* get information from the estate and scan state
|
||||
|
@ -352,7 +352,7 @@ ColumnarScanNext(ColumnarScanState *cstorescanstate)
|
|||
|
||||
if (scandesc == NULL)
|
||||
{
|
||||
/* the cstore access method does not use the flags, they are specific to heap */
|
||||
/* the columnar access method does not use the flags, they are specific to heap */
|
||||
uint32 flags = 0;
|
||||
Bitmapset *attr_needed = ColumnarAttrNeeded(&node->ss);
|
||||
|
||||
|
@ -363,7 +363,7 @@ ColumnarScanNext(ColumnarScanState *cstorescanstate)
|
|||
scandesc = columnar_beginscan_extended(node->ss.ss_currentRelation,
|
||||
estate->es_snapshot,
|
||||
0, NULL, NULL, flags, attr_needed,
|
||||
cstorescanstate->qual);
|
||||
columnarScanState->qual);
|
||||
bms_free(attr_needed);
|
||||
|
||||
node->ss.ss_currentScanDesc = scandesc;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* cstore_debug.c
|
||||
* columnar_debug.c
|
||||
*
|
||||
* Helper functions to debug column store.
|
||||
*
|
||||
|
@ -24,8 +24,8 @@
|
|||
#include "utils/rel.h"
|
||||
#include "utils/tuplestore.h"
|
||||
|
||||
#include "columnar/cstore.h"
|
||||
#include "columnar/cstore_version_compat.h"
|
||||
#include "columnar/columnar.h"
|
||||
#include "columnar/columnar_version_compat.h"
|
||||
|
||||
static void MemoryContextTotals(MemoryContext context, MemoryContextCounters *counters);
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
#include "safe_lib.h"
|
||||
|
||||
#include "citus_version.h"
|
||||
#include "columnar/cstore.h"
|
||||
#include "columnar/cstore_version_compat.h"
|
||||
#include "columnar/columnar.h"
|
||||
#include "columnar/columnar_version_compat.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include "access/heapam.h"
|
||||
|
@ -668,7 +668,7 @@ GetHighestUsedAddressAndId(uint64 storageId,
|
|||
*highestUsedId = 0;
|
||||
|
||||
/* file starts with metapage */
|
||||
*highestUsedAddress = CSTORE_BYTES_PER_PAGE;
|
||||
*highestUsedAddress = COLUMNAR_BYTES_PER_PAGE;
|
||||
|
||||
foreach(stripeMetadataCell, stripeMetadataList)
|
||||
{
|
||||
|
@ -1182,8 +1182,8 @@ InitMetapage(Relation relation)
|
|||
|
||||
ColumnarMetapage *metapage = palloc0(sizeof(ColumnarMetapage));
|
||||
metapage->storageId = GetNextStorageId();
|
||||
metapage->versionMajor = CSTORE_VERSION_MAJOR;
|
||||
metapage->versionMinor = CSTORE_VERSION_MINOR;
|
||||
metapage->versionMajor = COLUMNAR_VERSION_MAJOR;
|
||||
metapage->versionMinor = COLUMNAR_VERSION_MINOR;
|
||||
|
||||
/* create the first block */
|
||||
Buffer newBuffer = ReadBuffer(relation, P_NEW);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* cstore_reader.c
|
||||
* columnar_reader.c
|
||||
*
|
||||
* This file contains function definitions for reading cstore files. This
|
||||
* This file contains function definitions for reading columnar tables. This
|
||||
* includes the logic for reading file level metadata, reading row stripes,
|
||||
* and skipping unrelated row chunks and columns.
|
||||
*
|
||||
|
@ -36,8 +36,8 @@
|
|||
#include "utils/lsyscache.h"
|
||||
#include "utils/rel.h"
|
||||
|
||||
#include "columnar/cstore.h"
|
||||
#include "columnar/cstore_version_compat.h"
|
||||
#include "columnar/columnar.h"
|
||||
#include "columnar/columnar_version_compat.h"
|
||||
|
||||
/* static function declarations */
|
||||
static StripeBuffers * LoadFilteredStripeBuffers(Relation relation,
|
||||
|
@ -80,7 +80,7 @@ static Datum ColumnDefaultValue(TupleConstr *tupleConstraints,
|
|||
Form_pg_attribute attributeForm);
|
||||
|
||||
/*
|
||||
* ColumnarBeginRead initializes a cstore read operation. This function returns a
|
||||
* ColumnarBeginRead initializes a columnar read operation. This function returns a
|
||||
* read handle that's used during reading rows and finishing the read operation.
|
||||
*/
|
||||
TableReadState *
|
||||
|
@ -117,7 +117,7 @@ ColumnarBeginRead(Relation relation, TupleDesc tupleDescriptor,
|
|||
|
||||
|
||||
/*
|
||||
* ColumnarReadNextRow tries to read a row from the cstore file. On success, it sets
|
||||
* ColumnarReadNextRow tries to read a row from the columnar table. On success, it sets
|
||||
* column values and nulls, and returns true. If there are no more rows to read,
|
||||
* the function returns false.
|
||||
*/
|
||||
|
@ -235,7 +235,7 @@ ColumnarRescan(TableReadState *readState)
|
|||
}
|
||||
|
||||
|
||||
/* Finishes a cstore read operation. */
|
||||
/* Finishes a columnar read operation. */
|
||||
void
|
||||
ColumnarEndRead(TableReadState *readState)
|
||||
{
|
||||
|
|
|
@ -50,16 +50,14 @@
|
|||
#include "utils/lsyscache.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
#include "columnar/cstore.h"
|
||||
#include "columnar/cstore_customscan.h"
|
||||
#include "columnar/cstore_tableam.h"
|
||||
#include "columnar/cstore_version_compat.h"
|
||||
#include "columnar/columnar.h"
|
||||
#include "columnar/columnar_customscan.h"
|
||||
#include "columnar/columnar_tableam.h"
|
||||
#include "columnar/columnar_version_compat.h"
|
||||
#include "distributed/commands.h"
|
||||
#include "distributed/commands/utility_hook.h"
|
||||
#include "distributed/metadata_cache.h"
|
||||
|
||||
#define CSTORE_TABLEAM_NAME "columnar"
|
||||
|
||||
/*
|
||||
* Timing parameters for truncate locking heuristics.
|
||||
*
|
||||
|
@ -159,7 +157,7 @@ columnar_beginscan(Relation relation, Snapshot snapshot,
|
|||
|
||||
attr_needed = bms_add_range(attr_needed, 0, natts - 1);
|
||||
|
||||
/* the cstore access method does not use the flags, they are specific to heap */
|
||||
/* the columnar access method does not use the flags, they are specific to heap */
|
||||
flags = 0;
|
||||
|
||||
TableScanDesc scandesc = columnar_beginscan_extended(relation, snapshot, nkeys, key,
|
||||
|
@ -618,7 +616,7 @@ columnar_relation_copy_data(Relation rel, const RelFileNode *newrnode)
|
|||
* we should copy data from OldHeap to NewHeap.
|
||||
*
|
||||
* In general TableAM case this can also be called for the CLUSTER command
|
||||
* which is not applicable for cstore since it doesn't support indexes.
|
||||
* which is not applicable for columnar since it doesn't support indexes.
|
||||
*/
|
||||
static void
|
||||
columnar_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
|
||||
|
@ -647,11 +645,11 @@ columnar_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,
|
|||
Assert(sourceDesc->natts == targetDesc->natts);
|
||||
|
||||
/* read settings from old heap, relfilenode will be swapped at the end */
|
||||
ColumnarOptions cstoreOptions = { 0 };
|
||||
ReadColumnarOptions(OldHeap->rd_id, &cstoreOptions);
|
||||
ColumnarOptions columnarOptions = { 0 };
|
||||
ReadColumnarOptions(OldHeap->rd_id, &columnarOptions);
|
||||
|
||||
TableWriteState *writeState = ColumnarBeginWrite(NewHeap->rd_node,
|
||||
cstoreOptions,
|
||||
columnarOptions,
|
||||
targetDesc);
|
||||
|
||||
TableReadState *readState = ColumnarBeginRead(OldHeap, sourceDesc,
|
||||
|
@ -814,7 +812,7 @@ LogRelationStats(Relation rel, int elevel)
|
|||
|
||||
/*
|
||||
* TruncateColumnar truncates the unused space at the end of main fork for
|
||||
* a cstore table. This unused space can be created by aborted transactions.
|
||||
* a columnar table. This unused space can be created by aborted transactions.
|
||||
*
|
||||
* This implementation is based on heap_vacuum_rel in vacuumlazy.c with some
|
||||
* changes so it suits columnar store relations.
|
||||
|
@ -1162,9 +1160,10 @@ columnar_tableam_finish()
|
|||
int64
|
||||
ColumnarGetChunksFiltered(TableScanDesc scanDesc)
|
||||
{
|
||||
ColumnarScanDesc cstoreScanDesc = (ColumnarScanDesc) scanDesc;
|
||||
TableReadState *readState = cstoreScanDesc->cs_readState;
|
||||
ColumnarScanDesc columnarScanDesc = (ColumnarScanDesc) scanDesc;
|
||||
TableReadState *readState = columnarScanDesc->cs_readState;
|
||||
|
||||
/* readState is initialized lazily */
|
||||
if (readState != NULL)
|
||||
{
|
||||
return readState->chunksFiltered;
|
||||
|
@ -1609,7 +1608,7 @@ alter_columnar_table_set(PG_FUNCTION_ARGS)
|
|||
options.compressionType = ParseCompressionType(NameStr(*compressionName));
|
||||
if (options.compressionType == COMPRESSION_TYPE_INVALID)
|
||||
{
|
||||
ereport(ERROR, (errmsg("unknown compression type for cstore table: %s",
|
||||
ereport(ERROR, (errmsg("unknown compression type for columnar table: %s",
|
||||
quote_identifier(NameStr(*compressionName)))));
|
||||
}
|
||||
ereport(DEBUG1, (errmsg("updating compression to %s",
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* cstore_writer.c
|
||||
* columnar_writer.c
|
||||
*
|
||||
* This file contains function definitions for writing cstore files. This
|
||||
* This file contains function definitions for writing columnar tables. This
|
||||
* includes the logic for writing file level metadata, writing row stripes,
|
||||
* and calculating chunk skip nodes.
|
||||
*
|
||||
|
@ -29,8 +29,8 @@
|
|||
#include "utils/rel.h"
|
||||
#include "utils/relfilenodemap.h"
|
||||
|
||||
#include "columnar/cstore.h"
|
||||
#include "columnar/cstore_version_compat.h"
|
||||
#include "columnar/columnar.h"
|
||||
#include "columnar/columnar_version_compat.h"
|
||||
|
||||
static StripeBuffers * CreateEmptyStripeBuffers(uint32 stripeMaxRowCount,
|
||||
uint32 chunkRowCount,
|
||||
|
@ -53,11 +53,9 @@ static Datum DatumCopy(Datum datum, bool datumTypeByValue, int datumTypeLength);
|
|||
static StringInfo CopyStringInfo(StringInfo sourceString);
|
||||
|
||||
/*
|
||||
* ColumnarBeginWrite initializes a cstore data load operation and returns a table
|
||||
* ColumnarBeginWrite initializes a columnar data load operation and returns a table
|
||||
* handle. This handle should be used for adding the row values and finishing the
|
||||
* data load operation. If the cstore footer file already exists, we read the
|
||||
* footer and then seek to right after the last stripe where the new stripes
|
||||
* will be added.
|
||||
* data load operation.
|
||||
*/
|
||||
TableWriteState *
|
||||
ColumnarBeginWrite(RelFileNode relfilenode,
|
||||
|
@ -118,7 +116,7 @@ ColumnarBeginWrite(RelFileNode relfilenode,
|
|||
|
||||
|
||||
/*
|
||||
* ColumnarWriteRow adds a row to the cstore file. If the stripe is not initialized,
|
||||
* ColumnarWriteRow adds a row to the columnar table. If the stripe is not initialized,
|
||||
* we create structures to hold stripe data and skip list. Then, we serialize and
|
||||
* append data to serialized value buffer for each of the columns and update
|
||||
* corresponding skip nodes. Then, whole chunk data is compressed at every
|
||||
|
@ -214,10 +212,8 @@ ColumnarWriteRow(TableWriteState *writeState, Datum *columnValues, bool *columnN
|
|||
|
||||
|
||||
/*
|
||||
* ColumnarEndWrite finishes a cstore data load operation. If we have an unflushed
|
||||
* stripe, we flush it. Then, we sync and close the cstore data file. Last, we
|
||||
* flush the footer to a temporary file, and atomically rename this temporary
|
||||
* file to the original footer file.
|
||||
* ColumnarEndWrite finishes a columnar data load operation. If we have an unflushed
|
||||
* stripe, we flush it.
|
||||
*/
|
||||
void
|
||||
ColumnarEndWrite(TableWriteState *writeState)
|
||||
|
@ -373,7 +369,7 @@ WriteToSmgr(Relation rel, uint64 logicalOffset, char *data, uint32 dataLength)
|
|||
XLogBeginInsert();
|
||||
|
||||
/*
|
||||
* Since cstore will mostly write whole pages we force the transmission of the
|
||||
* Since columnar will mostly write whole pages we force the transmission of the
|
||||
* whole image in the buffer
|
||||
*/
|
||||
XLogRegisterBuffer(0, buffer, REGBUF_FORCE_IMAGE);
|
||||
|
|
|
@ -17,11 +17,11 @@
|
|||
|
||||
#include "citus_version.h"
|
||||
|
||||
#include "columnar/cstore.h"
|
||||
#include "columnar/columnar.h"
|
||||
#include "columnar/mod.h"
|
||||
|
||||
#ifdef HAS_TABLEAM
|
||||
#include "columnar/cstore_tableam.h"
|
||||
#include "columnar/columnar_tableam.h"
|
||||
#endif
|
||||
|
||||
void
|
||||
|
|
|
@ -14,4 +14,4 @@ COMMENT ON FUNCTION pg_catalog.alter_columnar_table_reset(
|
|||
stripe_row_count bool,
|
||||
compression bool,
|
||||
compression_level bool)
|
||||
IS 'reset on or more options on a cstore table to the system defaults';
|
||||
IS 'reset on or more options on a columnar table to the system defaults';
|
||||
|
|
|
@ -14,4 +14,4 @@ COMMENT ON FUNCTION pg_catalog.alter_columnar_table_reset(
|
|||
stripe_row_count bool,
|
||||
compression bool,
|
||||
compression_level bool)
|
||||
IS 'reset on or more options on a cstore table to the system defaults';
|
||||
IS 'reset on or more options on a columnar table to the system defaults';
|
||||
|
|
|
@ -14,4 +14,4 @@ COMMENT ON FUNCTION pg_catalog.alter_columnar_table_set(
|
|||
stripe_row_count int,
|
||||
compression name,
|
||||
compression_level int)
|
||||
IS 'set one or more options on a cstore table, when set to NULL no change is made';
|
||||
IS 'set one or more options on a columnar table, when set to NULL no change is made';
|
||||
|
|
|
@ -14,4 +14,4 @@ COMMENT ON FUNCTION pg_catalog.alter_columnar_table_set(
|
|||
stripe_row_count int,
|
||||
compression name,
|
||||
compression_level int)
|
||||
IS 'set one or more options on a cstore table, when set to NULL no change is made';
|
||||
IS 'set one or more options on a columnar table, when set to NULL no change is made';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "citus_version.h"
|
||||
|
||||
#include "postgres.h"
|
||||
#include "columnar/cstore.h"
|
||||
#include "columnar/columnar.h"
|
||||
|
||||
#if HAS_TABLEAM
|
||||
|
||||
|
@ -47,9 +47,9 @@
|
|||
#include "utils/rel.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
#include "columnar/cstore_customscan.h"
|
||||
#include "columnar/cstore_tableam.h"
|
||||
#include "columnar/cstore_version_compat.h"
|
||||
#include "columnar/columnar_customscan.h"
|
||||
#include "columnar/columnar_tableam.h"
|
||||
#include "columnar/columnar_version_compat.h"
|
||||
|
||||
|
||||
/*
|
||||
|
@ -178,12 +178,12 @@ columnar_init_write_state(Relation relation, TupleDesc tupdesc,
|
|||
*/
|
||||
MemoryContext oldContext = MemoryContextSwitchTo(WriteStateContext);
|
||||
|
||||
ColumnarOptions cstoreOptions = { 0 };
|
||||
ReadColumnarOptions(relation->rd_id, &cstoreOptions);
|
||||
ColumnarOptions columnarOptions = { 0 };
|
||||
ReadColumnarOptions(relation->rd_id, &columnarOptions);
|
||||
|
||||
SubXidWriteState *stackEntry = palloc0(sizeof(SubXidWriteState));
|
||||
stackEntry->writeState = ColumnarBeginWrite(relation->rd_node,
|
||||
cstoreOptions,
|
||||
columnarOptions,
|
||||
tupdesc);
|
||||
stackEntry->subXid = currentSubXid;
|
||||
stackEntry->next = hashEntry->writeStateStack;
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
#include "access/xact.h"
|
||||
#include "catalog/dependency.h"
|
||||
#include "catalog/pg_am.h"
|
||||
#include "columnar/cstore.h"
|
||||
#include "columnar/cstore_tableam.h"
|
||||
#include "columnar/columnar.h"
|
||||
#include "columnar/columnar_tableam.h"
|
||||
#include "distributed/colocation_utils.h"
|
||||
#include "distributed/commands.h"
|
||||
#include "distributed/commands/utility_hook.h"
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
#include "utils/ruleutils.h"
|
||||
#include "utils/varlena.h"
|
||||
|
||||
#include "columnar/cstore_tableam.h"
|
||||
#include "columnar/columnar_tableam.h"
|
||||
|
||||
/* Shard related configuration */
|
||||
int ShardCount = 32;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* cstore.h
|
||||
* columnar.h
|
||||
*
|
||||
* Type and function declarations for Columnar
|
||||
*
|
||||
|
@ -11,8 +11,8 @@
|
|||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef CSTORE_H
|
||||
#define CSTORE_H
|
||||
#ifndef COLUMNAR_H
|
||||
#define COLUMNAR_H
|
||||
#include "postgres.h"
|
||||
|
||||
#include "fmgr.h"
|
||||
|
@ -37,22 +37,17 @@
|
|||
#define COMPRESSION_LEVEL_MIN 1
|
||||
#define COMPRESSION_LEVEL_MAX 19
|
||||
|
||||
/* String representations of compression types */
|
||||
#define COMPRESSION_STRING_NONE "none"
|
||||
#define COMPRESSION_STRING_PG_LZ "pglz"
|
||||
|
||||
/* Columnar file signature */
|
||||
#define CSTORE_MAGIC_NUMBER "citus_cstore"
|
||||
#define CSTORE_VERSION_MAJOR 1
|
||||
#define CSTORE_VERSION_MINOR 7
|
||||
#define COLUMNAR_VERSION_MAJOR 1
|
||||
#define COLUMNAR_VERSION_MINOR 7
|
||||
|
||||
/* miscellaneous defines */
|
||||
#define CSTORE_TUPLE_COST_MULTIPLIER 10
|
||||
#define CSTORE_POSTSCRIPT_SIZE_LENGTH 1
|
||||
#define CSTORE_POSTSCRIPT_SIZE_MAX 256
|
||||
#define CSTORE_BYTES_PER_PAGE (BLCKSZ - SizeOfPageHeaderData)
|
||||
#define COLUMNAR_TUPLE_COST_MULTIPLIER 10
|
||||
#define COLUMNAR_POSTSCRIPT_SIZE_LENGTH 1
|
||||
#define COLUMNAR_POSTSCRIPT_SIZE_MAX 256
|
||||
#define COLUMNAR_BYTES_PER_PAGE (BLCKSZ - SizeOfPageHeaderData)
|
||||
|
||||
/* Enumaration for cstore file's compression method */
|
||||
/* Enumaration for columnar table's compression method */
|
||||
typedef enum
|
||||
{
|
||||
COMPRESSION_TYPE_INVALID = -1,
|
||||
|
@ -67,7 +62,7 @@ typedef enum
|
|||
|
||||
/*
|
||||
* ColumnarOptions holds the option values to be used when reading or writing
|
||||
* a cstore file. To resolve these values, we first check foreign table's options,
|
||||
* a columnar table. To resolve these values, we first check foreign table's options,
|
||||
* and if not present, we then fall back to the default values specified above.
|
||||
*/
|
||||
typedef struct ColumnarOptions
|
||||
|
@ -93,7 +88,7 @@ typedef struct ColumnarTableDDLContext
|
|||
|
||||
/*
|
||||
* StripeMetadata represents information about a stripe. This information is
|
||||
* stored in the cstore file's footer.
|
||||
* stored in the metadata table "columnar.stripe".
|
||||
*/
|
||||
typedef struct StripeMetadata
|
||||
{
|
||||
|
@ -107,13 +102,6 @@ typedef struct StripeMetadata
|
|||
} StripeMetadata;
|
||||
|
||||
|
||||
/* DataFileMetadata represents the metadata of a cstore file. */
|
||||
typedef struct DataFileMetadata
|
||||
{
|
||||
List *stripeMetadataList;
|
||||
} DataFileMetadata;
|
||||
|
||||
|
||||
/* ColumnChunkSkipNode contains statistics for a ColumnChunkData. */
|
||||
typedef struct ColumnChunkSkipNode
|
||||
{
|
||||
|
@ -207,7 +195,7 @@ typedef struct ColumnBuffers
|
|||
} ColumnBuffers;
|
||||
|
||||
|
||||
/* StripeBuffers represents data for a row stripe in a cstore file. */
|
||||
/* StripeBuffers represents data for a row stripe. */
|
||||
typedef struct StripeBuffers
|
||||
{
|
||||
uint32 columnCount;
|
||||
|
@ -216,7 +204,7 @@ typedef struct StripeBuffers
|
|||
} StripeBuffers;
|
||||
|
||||
|
||||
/* TableReadState represents state of a cstore file read operation. */
|
||||
/* TableReadState represents state of a columnar scan. */
|
||||
typedef struct TableReadState
|
||||
{
|
||||
List *stripeList;
|
||||
|
@ -242,7 +230,7 @@ typedef struct TableReadState
|
|||
} TableReadState;
|
||||
|
||||
|
||||
/* TableWriteState represents state of a cstore file write operation. */
|
||||
/* TableWriteState represents state of a columnar write operation. */
|
||||
typedef struct TableWriteState
|
||||
{
|
||||
TupleDesc tupleDescriptor;
|
||||
|
@ -274,7 +262,7 @@ extern void columnar_init_gucs(void);
|
|||
|
||||
extern CompressionType ParseCompressionType(const char *compressionTypeString);
|
||||
|
||||
/* Function declarations for writing to a cstore file */
|
||||
/* Function declarations for writing to a columnar table */
|
||||
extern TableWriteState * ColumnarBeginWrite(RelFileNode relfilenode,
|
||||
ColumnarOptions options,
|
||||
TupleDesc tupleDescriptor);
|
||||
|
@ -284,7 +272,7 @@ extern void ColumnarFlushPendingWrites(TableWriteState *state);
|
|||
extern void ColumnarEndWrite(TableWriteState *state);
|
||||
extern bool ContainsPendingWrites(TableWriteState *state);
|
||||
|
||||
/* Function declarations for reading from a cstore file */
|
||||
/* Function declarations for reading from columnar table */
|
||||
extern TableReadState * ColumnarBeginRead(Relation relation,
|
||||
TupleDesc tupleDescriptor,
|
||||
List *projectedColumnList,
|
||||
|
@ -366,8 +354,8 @@ logical_to_smgr(uint64 logicalOffset)
|
|||
{
|
||||
SmgrAddr addr;
|
||||
|
||||
addr.blockno = logicalOffset / CSTORE_BYTES_PER_PAGE;
|
||||
addr.offset = SizeOfPageHeaderData + (logicalOffset % CSTORE_BYTES_PER_PAGE);
|
||||
addr.blockno = logicalOffset / COLUMNAR_BYTES_PER_PAGE;
|
||||
addr.offset = SizeOfPageHeaderData + (logicalOffset % COLUMNAR_BYTES_PER_PAGE);
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
@ -379,7 +367,7 @@ logical_to_smgr(uint64 logicalOffset)
|
|||
static inline uint64
|
||||
smgr_to_logical(SmgrAddr addr)
|
||||
{
|
||||
return CSTORE_BYTES_PER_PAGE * addr.blockno + addr.offset - SizeOfPageHeaderData;
|
||||
return COLUMNAR_BYTES_PER_PAGE * addr.blockno + addr.offset - SizeOfPageHeaderData;
|
||||
}
|
||||
|
||||
|
||||
|
@ -398,4 +386,4 @@ next_block_start(SmgrAddr addr)
|
|||
}
|
||||
|
||||
|
||||
#endif /* CSTORE_H */
|
||||
#endif /* COLUMNAR_H */
|
|
@ -1,9 +1,9 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* cstore_customscan.h
|
||||
* columnar_customscan.h
|
||||
*
|
||||
* Forward declarations of functions to hookup the custom scan feature of
|
||||
* cstore.
|
||||
* columnar.
|
||||
*
|
||||
* $Id$
|
||||
*
|
|
@ -1,6 +1,6 @@
|
|||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* cstore_version_compat.h
|
||||
* columnar_version_compat.h
|
||||
*
|
||||
* Compatibility macros for writing code agnostic to PostgreSQL versions
|
||||
*
|
||||
|
@ -11,8 +11,8 @@
|
|||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef CSTORE_COMPAT_H
|
||||
#define CSTORE_COMPAT_H
|
||||
#ifndef COLUMNAR_COMPAT_H
|
||||
#define COLUMNAR_COMPAT_H
|
||||
|
||||
#if PG_VERSION_NUM < 100000
|
||||
|
||||
|
@ -43,4 +43,4 @@
|
|||
#define table_endscan heap_endscan
|
||||
#endif
|
||||
|
||||
#endif /* CSTORE_COMPAT_H */
|
||||
#endif /* COLUMNAR_COMPAT_H */
|
|
@ -2,7 +2,7 @@
|
|||
*
|
||||
* mod.h
|
||||
*
|
||||
* Type and function declarations for CStore
|
||||
* Type and function declarations for columnar
|
||||
*
|
||||
* Copyright (c) 2016, Citus Data, Inc.
|
||||
*
|
||||
|
|
|
@ -246,7 +246,7 @@ SELECT alter_columnar_table_reset('not_a_columnar_table', compression => true);
|
|||
ERROR: table not_a_columnar_table is not a columnar table
|
||||
-- verify you can't use a compression that is not known
|
||||
SELECT alter_columnar_table_set('table_options', compression => 'foobar');
|
||||
ERROR: unknown compression type for cstore table: foobar
|
||||
ERROR: unknown compression type for columnar table: foobar
|
||||
-- verify cannot set out of range compression levels
|
||||
SELECT alter_columnar_table_set('table_options', compression_level => 0);
|
||||
ERROR: compression level out of range
|
||||
|
|
Loading…
Reference in New Issue