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:
rm -f data/*.cstore data/*.cstore.footer
reindent:
citus_indent .

View File

@ -43,6 +43,7 @@ ParseCompressionType(const char *compressionTypeString)
return compressionType;
}
/* CreateDirectory creates a new directory with the given directory name. */
static void
CreateDirectory(StringInfo directoryName)
@ -56,6 +57,7 @@ CreateDirectory(StringInfo directoryName)
}
}
/* DirectoryExists checks if a directory exists for the given directory name. */
static bool
DirectoryExists(StringInfo directoryName)
@ -91,6 +93,7 @@ DirectoryExists(StringInfo directoryName)
return directoryExists;
}
/*
* RemoveCStoreDatabaseDirectory removes CStore directory previously
* 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.
*/
writeState = CStoreBeginWrite(relationId, cstoreOptions->filename,
cstoreOptions->compressionType, cstoreOptions->stripeRowCount,
cstoreOptions->compressionType,
cstoreOptions->stripeRowCount,
cstoreOptions->blockRowCount, tupleDescriptor);
CStoreEndWrite(writeState);
}

View File

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

View File

@ -22,8 +22,8 @@
#include "cstore.h"
#if PG_VERSION_NUM >= 90500
/*
* The information at the start of the compressed data. This decription is taken
* 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_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 CSTORE_COMPRESS_SET_RAWSIZE(ptr, len) (((CStoreCompressHeader *) (ptr))->rawsize = \
(len))
#else
#define CSTORE_COMPRESS_HDRSZ (0)
#define CSTORE_COMPRESS_RAWSIZE(ptr) (PGLZ_RAW_SIZE((PGLZ_Header *) buffer->data))
#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
/*
* CompressBuffer compresses the given buffer with the given compression type
* outputBuffer enlarged to contain compressed data. The function returns true

View File

@ -85,7 +85,6 @@ typedef struct CStoreValidOption
{
const char *optionName;
Oid optionContextId;
} CStoreValidOption;
#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
* the copy command.
*/
void cstore_fdw_init()
void
cstore_fdw_init()
{
PreviousProcessUtilityHook = ProcessUtility_hook;
ProcessUtility_hook = CStoreProcessUtility;
@ -212,7 +212,8 @@ void cstore_fdw_init()
* Called when the module is unloaded. This function uninstalls the
* extension's hooks.
*/
void cstore_fdw_finish()
void
cstore_fdw_finish()
{
ProcessUtility_hook = PreviousProcessUtilityHook;
}
@ -387,6 +388,7 @@ CStoreProcessUtility(Node * parseTree, const char *queryString,
CALL_PREVIOUS_UTILITY(parseTree, queryString, context, paramListInfo,
destReceiver, completionTag);
/* restore the former relation list. Our
* replacement could be freed but still needed
* in a cached plan. A truncate can be cached
@ -682,6 +684,7 @@ CopyOutCStoreTable(CopyStmt* copyStatement, const char* queryString)
copyStatement->relation = NULL;
#if (PG_VERSION_NUM >= 100000)
/*
* raw_parser returns list of RawStmt* in PG 10+ we need to
* 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
* 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.
* The result includes the sizes of data file and footer file.
@ -1428,7 +1429,6 @@ CStoreDefaultFilePath(Oid foreignTableId)
{
databaseOid = MyDatabaseId;
relationFileOid = foreignTableId;
}
cstoreFilePath = makeStringInfo();
@ -1447,7 +1447,8 @@ static void
CStoreGetForeignRelSize(PlannerInfo *root, RelOptInfo *baserel, Oid 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,
0, JOIN_INNER, NULL);
@ -1494,7 +1495,8 @@ CStoreGetForeignPaths(PlannerInfo *root, RelOptInfo *baserel, Oid foreignTableId
double queryPageCount = relationPageCount * queryColumnRatio;
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
@ -1948,7 +1950,8 @@ CStoreAcquireSampleRows(Relation relation, int logLevel,
if (!attributeForm->attisdropped)
{
Var *column = makeVar(tableId, columnIndex + 1, attributeForm->atttypid,
attributeForm->atttypmod, attributeForm->attcollation, 0);
attributeForm->atttypmod, attributeForm->attcollation,
0);
columnList = lappend(columnList, column);
}
}
@ -2238,6 +2241,7 @@ CStoreEndForeignInsert(EState *executorState, ResultRelInfo *relationInfo)
#if PG_VERSION_NUM >= 90600
/*
* CStoreIsForeignScanParallelSafe always returns true to indicate that
* reading from a cstore_fdw table in a parallel worker is safe. This
@ -2254,4 +2258,6 @@ CStoreIsForeignScanParallelSafe(PlannerInfo *root, RelOptInfo *rel,
{
return true;
}
#endif

View File

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

View File

@ -22,7 +22,8 @@
#endif
#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
#else
#define ACLCHECK_OBJECT_TABLE OBJECT_TABLE

View File

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

7
mod.c
View File

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