Merge pull request #3 from citusdata/add_reindent

Add 'make reindent'
merge-cstore-pykello
Hadi Moshayedi 2020-09-07 15:51:09 -07:00 committed by GitHub
commit 85a51fb2ef
13 changed files with 143 additions and 112 deletions

26
.gitattributes vendored Normal file
View File

@ -0,0 +1,26 @@
* whitespace=space-before-tab,trailing-space
*.[chly] whitespace=space-before-tab,trailing-space,indent-with-non-tab,tabwidth=4
*.dsl whitespace=space-before-tab,trailing-space,tab-in-indent
*.patch -whitespace
*.pl whitespace=space-before-tab,trailing-space,tabwidth=4
*.po whitespace=space-before-tab,trailing-space,tab-in-indent,-blank-at-eof
*.sgml whitespace=space-before-tab,trailing-space,tab-in-indent,-blank-at-eol
*.x[ms]l whitespace=space-before-tab,trailing-space,tab-in-indent
# Avoid confusing ASCII underlines with leftover merge conflict markers
README conflict-marker-size=32
README.* conflict-marker-size=32
# Certain data files that contain special whitespace, and other special cases
*.data -whitespace
# Test output files that contain extra whitespace
*.out -whitespace
src/test/regress/output/*.source -whitespace
# These files are maintained or generated elsewhere. We take them as is.
configure -whitespace
# all C files (implementation and header) use our style...
*.[ch] citus-style

View File

@ -58,3 +58,6 @@ installcheck: remove_cstore_files
remove_cstore_files: remove_cstore_files:
rm -f data/*.cstore data/*.cstore.footer rm -f data/*.cstore data/*.cstore.footer
reindent:
citus_indent .

View File

@ -43,6 +43,7 @@ ParseCompressionType(const char *compressionTypeString)
return compressionType; return compressionType;
} }
/* CreateDirectory creates a new directory with the given directory name. */ /* CreateDirectory creates a new directory with the given directory name. */
static void static void
CreateDirectory(StringInfo directoryName) CreateDirectory(StringInfo directoryName)
@ -56,6 +57,7 @@ CreateDirectory(StringInfo directoryName)
} }
} }
/* DirectoryExists checks if a directory exists for the given directory name. */ /* DirectoryExists checks if a directory exists for the given directory name. */
static bool static bool
DirectoryExists(StringInfo directoryName) DirectoryExists(StringInfo directoryName)
@ -91,6 +93,7 @@ DirectoryExists(StringInfo directoryName)
return directoryExists; return directoryExists;
} }
/* /*
* RemoveCStoreDatabaseDirectory removes CStore directory previously * RemoveCStoreDatabaseDirectory removes CStore directory previously
* created for this database. * created for this database.
@ -132,7 +135,8 @@ InitializeCStoreTableFile(Oid relationId, Relation relation, CStoreOptions *csto
* empty data file and a valid footer file for the table. * empty data file and a valid footer file for the table.
*/ */
writeState = CStoreBeginWrite(relationId, cstoreOptions->filename, writeState = CStoreBeginWrite(relationId, cstoreOptions->filename,
cstoreOptions->compressionType, cstoreOptions->stripeRowCount, cstoreOptions->compressionType,
cstoreOptions->stripeRowCount,
cstoreOptions->blockRowCount, tupleDescriptor); cstoreOptions->blockRowCount, tupleDescriptor);
CStoreEndWrite(writeState); CStoreEndWrite(writeState);
} }

View File

@ -60,7 +60,6 @@ typedef enum
COMPRESSION_PG_LZ = 1, COMPRESSION_PG_LZ = 1,
COMPRESSION_COUNT COMPRESSION_COUNT
} CompressionType; } CompressionType;
@ -75,7 +74,6 @@ typedef struct CStoreOptions
CompressionType compressionType; CompressionType compressionType;
uint64 stripeRowCount; uint64 stripeRowCount;
uint32 blockRowCount; uint32 blockRowCount;
} CStoreOptions; } CStoreOptions;
@ -90,7 +88,6 @@ typedef struct StripeMetadata
uint64 dataLength; uint64 dataLength;
uint64 footerLength; uint64 footerLength;
uint64 id; uint64 id;
} StripeMetadata; } StripeMetadata;
@ -99,7 +96,6 @@ typedef struct TableFooter
{ {
List *stripeMetadataList; List *stripeMetadataList;
uint64 blockRowCount; uint64 blockRowCount;
} TableFooter; } TableFooter;
@ -123,7 +119,6 @@ typedef struct ColumnBlockSkipNode
uint64 existsLength; uint64 existsLength;
CompressionType valueCompressionType; CompressionType valueCompressionType;
} ColumnBlockSkipNode; } ColumnBlockSkipNode;
@ -137,7 +132,6 @@ typedef struct StripeSkipList
ColumnBlockSkipNode **blockSkipNodeArray; ColumnBlockSkipNode **blockSkipNodeArray;
uint32 columnCount; uint32 columnCount;
uint32 blockCount; uint32 blockCount;
} StripeSkipList; } StripeSkipList;
@ -155,7 +149,6 @@ typedef struct ColumnBlockData
/* valueBuffer keeps actual data for type-by-reference datums from valueArray. */ /* valueBuffer keeps actual data for type-by-reference datums from valueArray. */
StringInfo valueBuffer; StringInfo valueBuffer;
} ColumnBlockData; } ColumnBlockData;
@ -171,7 +164,6 @@ typedef struct ColumnBlockBuffers
StringInfo existsBuffer; StringInfo existsBuffer;
StringInfo valueBuffer; StringInfo valueBuffer;
CompressionType valueCompressionType; CompressionType valueCompressionType;
} ColumnBlockBuffers; } ColumnBlockBuffers;
@ -182,7 +174,6 @@ typedef struct ColumnBlockBuffers
typedef struct ColumnBuffers typedef struct ColumnBuffers
{ {
ColumnBlockBuffers **blockBuffersArray; ColumnBlockBuffers **blockBuffersArray;
} ColumnBuffers; } ColumnBuffers;
@ -192,7 +183,6 @@ typedef struct StripeBuffers
uint32 columnCount; uint32 columnCount;
uint32 rowCount; uint32 rowCount;
ColumnBuffers **columnBuffersArray; ColumnBuffers **columnBuffersArray;
} StripeBuffers; } StripeBuffers;
@ -207,7 +197,6 @@ typedef struct StripeFooter
uint64 *skipListSizeArray; uint64 *skipListSizeArray;
uint64 *existsSizeArray; uint64 *existsSizeArray;
uint64 *valueSizeArray; uint64 *valueSizeArray;
} StripeFooter; } StripeFooter;
@ -234,7 +223,6 @@ typedef struct TableReadState
uint64 stripeReadRowCount; uint64 stripeReadRowCount;
ColumnBlockData **blockDataArray; ColumnBlockData **blockDataArray;
int32 deserializedBlockIndex; int32 deserializedBlockIndex;
} TableReadState; } TableReadState;
@ -257,6 +245,7 @@ typedef struct TableWriteState
StripeSkipList *stripeSkipList; StripeSkipList *stripeSkipList;
uint32 stripeMaxRowCount; uint32 stripeMaxRowCount;
ColumnBlockData **blockDataArray; ColumnBlockData **blockDataArray;
/* /*
* compressionBuffer buffer is used as temporary storage during * compressionBuffer buffer is used as temporary storage during
* data value compression operation. It is kept here to minimize * data value compression operation. It is kept here to minimize
@ -264,7 +253,6 @@ typedef struct TableWriteState
* deallocated when memory context is reset. * deallocated when memory context is reset.
*/ */
StringInfo compressionBuffer; StringInfo compressionBuffer;
} TableWriteState; } TableWriteState;
extern CompressionType ParseCompressionType(const char *compressionTypeString); extern CompressionType ParseCompressionType(const char *compressionTypeString);

View File

@ -22,8 +22,8 @@
#include "cstore.h" #include "cstore.h"
#if PG_VERSION_NUM >= 90500 #if PG_VERSION_NUM >= 90500
/* /*
* The information at the start of the compressed data. This decription is taken * The information at the start of the compressed data. This decription is taken
* from pg_lzcompress in pre-9.5 version of PostgreSQL. * from pg_lzcompress in pre-9.5 version of PostgreSQL.
@ -41,19 +41,20 @@ typedef struct CStoreCompressHeader
#define CSTORE_COMPRESS_HDRSZ ((int32) sizeof(CStoreCompressHeader)) #define CSTORE_COMPRESS_HDRSZ ((int32) sizeof(CStoreCompressHeader))
#define CSTORE_COMPRESS_RAWSIZE(ptr) (((CStoreCompressHeader *) (ptr))->rawsize) #define CSTORE_COMPRESS_RAWSIZE(ptr) (((CStoreCompressHeader *) (ptr))->rawsize)
#define CSTORE_COMPRESS_RAWDATA(ptr) (((char *) (ptr)) + CSTORE_COMPRESS_HDRSZ) #define CSTORE_COMPRESS_RAWDATA(ptr) (((char *) (ptr)) + CSTORE_COMPRESS_HDRSZ)
#define CSTORE_COMPRESS_SET_RAWSIZE(ptr, len) (((CStoreCompressHeader *) (ptr))->rawsize = (len)) #define CSTORE_COMPRESS_SET_RAWSIZE(ptr, len) (((CStoreCompressHeader *) (ptr))->rawsize = \
(len))
#else #else
#define CSTORE_COMPRESS_HDRSZ (0) #define CSTORE_COMPRESS_HDRSZ (0)
#define CSTORE_COMPRESS_RAWSIZE(ptr) (PGLZ_RAW_SIZE((PGLZ_Header *) buffer->data)) #define CSTORE_COMPRESS_RAWSIZE(ptr) (PGLZ_RAW_SIZE((PGLZ_Header *) buffer->data))
#define CSTORE_COMPRESS_RAWDATA(ptr) (((PGLZ_Header *) (ptr))) #define CSTORE_COMPRESS_RAWDATA(ptr) (((PGLZ_Header *) (ptr)))
#define CSTORE_COMPRESS_SET_RAWSIZE(ptr, len) (((CStoreCompressHeader *) (ptr))->rawsize = (len)) #define CSTORE_COMPRESS_SET_RAWSIZE(ptr, len) (((CStoreCompressHeader *) (ptr))->rawsize = \
(len))
#endif #endif
/* /*
* CompressBuffer compresses the given buffer with the given compression type * CompressBuffer compresses the given buffer with the given compression type
* outputBuffer enlarged to contain compressed data. The function returns true * outputBuffer enlarged to contain compressed data. The function returns true

View File

@ -85,7 +85,6 @@ typedef struct CStoreValidOption
{ {
const char *optionName; const char *optionName;
Oid optionContextId; Oid optionContextId;
} CStoreValidOption; } CStoreValidOption;
#define COMPRESSION_STRING_DELIMITED_LIST "none, pglz" #define COMPRESSION_STRING_DELIMITED_LIST "none, pglz"
@ -201,7 +200,8 @@ static ProcessUtility_hook_type PreviousProcessUtilityHook = NULL;
* previous utility hook, and then install our hook to pre-intercept calls to * previous utility hook, and then install our hook to pre-intercept calls to
* the copy command. * the copy command.
*/ */
void cstore_fdw_init() void
cstore_fdw_init()
{ {
PreviousProcessUtilityHook = ProcessUtility_hook; PreviousProcessUtilityHook = ProcessUtility_hook;
ProcessUtility_hook = CStoreProcessUtility; ProcessUtility_hook = CStoreProcessUtility;
@ -212,7 +212,8 @@ void cstore_fdw_init()
* Called when the module is unloaded. This function uninstalls the * Called when the module is unloaded. This function uninstalls the
* extension's hooks. * extension's hooks.
*/ */
void cstore_fdw_finish() void
cstore_fdw_finish()
{ {
ProcessUtility_hook = PreviousProcessUtilityHook; ProcessUtility_hook = PreviousProcessUtilityHook;
} }
@ -387,6 +388,7 @@ CStoreProcessUtility(Node * parseTree, const char *queryString,
CALL_PREVIOUS_UTILITY(parseTree, queryString, context, paramListInfo, CALL_PREVIOUS_UTILITY(parseTree, queryString, context, paramListInfo,
destReceiver, completionTag); destReceiver, completionTag);
/* restore the former relation list. Our /* restore the former relation list. Our
* replacement could be freed but still needed * replacement could be freed but still needed
* in a cached plan. A truncate can be cached * in a cached plan. A truncate can be cached
@ -682,6 +684,7 @@ CopyOutCStoreTable(CopyStmt* copyStatement, const char* queryString)
copyStatement->relation = NULL; copyStatement->relation = NULL;
#if (PG_VERSION_NUM >= 100000) #if (PG_VERSION_NUM >= 100000)
/* /*
* raw_parser returns list of RawStmt* in PG 10+ we need to * raw_parser returns list of RawStmt* in PG 10+ we need to
* extract actual query from it. * extract actual query from it.
@ -890,6 +893,7 @@ TruncateCStoreTables(List *cstoreRelationList)
} }
} }
/* /*
* CStoreTable checks if the given table name belongs to a foreign columnar store * CStoreTable checks if the given table name belongs to a foreign columnar store
* table. If it does, the function returns true. Otherwise, it returns false. * table. If it does, the function returns true. Otherwise, it returns false.
@ -1010,9 +1014,6 @@ DistributedWorkerCopy(CopyStmt *copyStatement)
} }
/* /*
* cstore_table_size returns the total on-disk size of a cstore table in bytes. * cstore_table_size returns the total on-disk size of a cstore table in bytes.
* The result includes the sizes of data file and footer file. * The result includes the sizes of data file and footer file.
@ -1428,7 +1429,6 @@ CStoreDefaultFilePath(Oid foreignTableId)
{ {
databaseOid = MyDatabaseId; databaseOid = MyDatabaseId;
relationFileOid = foreignTableId; relationFileOid = foreignTableId;
} }
cstoreFilePath = makeStringInfo(); cstoreFilePath = makeStringInfo();
@ -1447,7 +1447,8 @@ static void
CStoreGetForeignRelSize(PlannerInfo *root, RelOptInfo *baserel, Oid foreignTableId) CStoreGetForeignRelSize(PlannerInfo *root, RelOptInfo *baserel, Oid foreignTableId)
{ {
CStoreOptions *cstoreOptions = CStoreGetOptions(foreignTableId); CStoreOptions *cstoreOptions = CStoreGetOptions(foreignTableId);
double tupleCountEstimate = TupleCountEstimate(foreignTableId, baserel, cstoreOptions->filename); double tupleCountEstimate = TupleCountEstimate(foreignTableId, baserel,
cstoreOptions->filename);
double rowSelectivity = clauselist_selectivity(root, baserel->baserestrictinfo, double rowSelectivity = clauselist_selectivity(root, baserel->baserestrictinfo,
0, JOIN_INNER, NULL); 0, JOIN_INNER, NULL);
@ -1494,7 +1495,8 @@ CStoreGetForeignPaths(PlannerInfo *root, RelOptInfo *baserel, Oid foreignTableId
double queryPageCount = relationPageCount * queryColumnRatio; double queryPageCount = relationPageCount * queryColumnRatio;
double totalDiskAccessCost = seq_page_cost * queryPageCount; double totalDiskAccessCost = seq_page_cost * queryPageCount;
double tupleCountEstimate = TupleCountEstimate(foreignTableId, baserel, cstoreOptions->filename); double tupleCountEstimate = TupleCountEstimate(foreignTableId, baserel,
cstoreOptions->filename);
/* /*
* We estimate costs almost the same way as cost_seqscan(), thus assuming * We estimate costs almost the same way as cost_seqscan(), thus assuming
@ -1948,7 +1950,8 @@ CStoreAcquireSampleRows(Relation relation, int logLevel,
if (!attributeForm->attisdropped) if (!attributeForm->attisdropped)
{ {
Var *column = makeVar(tableId, columnIndex + 1, attributeForm->atttypid, Var *column = makeVar(tableId, columnIndex + 1, attributeForm->atttypid,
attributeForm->atttypmod, attributeForm->attcollation, 0); attributeForm->atttypmod, attributeForm->attcollation,
0);
columnList = lappend(columnList, column); columnList = lappend(columnList, column);
} }
} }
@ -2238,6 +2241,7 @@ CStoreEndForeignInsert(EState *executorState, ResultRelInfo *relationInfo)
#if PG_VERSION_NUM >= 90600 #if PG_VERSION_NUM >= 90600
/* /*
* CStoreIsForeignScanParallelSafe always returns true to indicate that * CStoreIsForeignScanParallelSafe always returns true to indicate that
* reading from a cstore_fdw table in a parallel worker is safe. This * reading from a cstore_fdw table in a parallel worker is safe. This
@ -2254,4 +2258,6 @@ CStoreIsForeignScanParallelSafe(PlannerInfo *root, RelOptInfo *rel,
{ {
return true; return true;
} }
#endif #endif

View File

@ -761,7 +761,8 @@ SelectedBlockMask(StripeSkipList *stripeSkipList, List *projectedColumnList,
constraintList = list_make1(baseConstraint); constraintList = list_make1(baseConstraint);
#if (PG_VERSION_NUM >= 100000) #if (PG_VERSION_NUM >= 100000)
predicateRefuted = predicate_refuted_by(constraintList, restrictInfoList, false); predicateRefuted = predicate_refuted_by(constraintList, restrictInfoList,
false);
#else #else
predicateRefuted = predicate_refuted_by(constraintList, restrictInfoList); predicateRefuted = predicate_refuted_by(constraintList, restrictInfoList);
#endif #endif
@ -1163,7 +1164,8 @@ DeserializeBlockData(StripeBuffers *stripeBuffers, uint64 blockIndex,
if (columnBuffers != NULL) if (columnBuffers != NULL)
{ {
ColumnBlockBuffers *blockBuffers = columnBuffers->blockBuffersArray[blockIndex]; ColumnBlockBuffers *blockBuffers =
columnBuffers->blockBuffersArray[blockIndex];
StringInfo valueBuffer = NULL; StringInfo valueBuffer = NULL;
/* free previous block's data buffers */ /* free previous block's data buffers */
@ -1214,7 +1216,6 @@ DeserializeBlockData(StripeBuffers *stripeBuffers, uint64 blockIndex,
{ {
memset(blockData->existsArray, false, rowCount); memset(blockData->existsArray, false, rowCount);
} }
} }
} }
} }
@ -1330,8 +1331,6 @@ ReadFromFile(FILE *file, uint64 offset, uint32 size)
} }
/* /*
* ResetUncompressedBlockData iterates over deserialized column block data * ResetUncompressedBlockData iterates over deserialized column block data
* and sets valueBuffer field to empty buffer. This field is allocated in stripe * and sets valueBuffer field to empty buffer. This field is allocated in stripe

View File

@ -22,7 +22,8 @@
#endif #endif
#if PG_VERSION_NUM < 110000 #if PG_VERSION_NUM < 110000
#define ALLOCSET_DEFAULT_SIZES ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE #define ALLOCSET_DEFAULT_SIZES ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, \
ALLOCSET_DEFAULT_MAXSIZE
#define ACLCHECK_OBJECT_TABLE ACL_KIND_CLASS #define ACLCHECK_OBJECT_TABLE ACL_KIND_CLASS
#else #else
#define ACLCHECK_OBJECT_TABLE OBJECT_TABLE #define ACLCHECK_OBJECT_TABLE OBJECT_TABLE

View File

@ -149,13 +149,15 @@ CStoreBeginWrite(Oid relationId,
for (columnIndex = 0; columnIndex < columnCount; columnIndex++) for (columnIndex = 0; columnIndex < columnCount; columnIndex++)
{ {
FmgrInfo *comparisonFunction = NULL; FmgrInfo *comparisonFunction = NULL;
FormData_pg_attribute *attributeForm = TupleDescAttr(tupleDescriptor, columnIndex); FormData_pg_attribute *attributeForm = TupleDescAttr(tupleDescriptor,
columnIndex);
if (!attributeForm->attisdropped) if (!attributeForm->attisdropped)
{ {
Oid typeId = attributeForm->atttypid; Oid typeId = attributeForm->atttypid;
comparisonFunction = GetFunctionInfoOrNull(typeId, BTREE_AM_OID, BTORDER_PROC); comparisonFunction = GetFunctionInfoOrNull(typeId, BTREE_AM_OID,
BTORDER_PROC);
} }
comparisonFunctionArray[columnIndex] = comparisonFunction; comparisonFunctionArray[columnIndex] = comparisonFunction;

7
mod.c
View File

@ -20,14 +20,15 @@
PG_MODULE_MAGIC; PG_MODULE_MAGIC;
void _PG_init(void) void
_PG_init(void)
{ {
cstore_fdw_init(); cstore_fdw_init();
} }
void _PG_fini(void) void
_PG_fini(void)
{ {
cstore_fdw_finish(); cstore_fdw_finish();
} }