mirror of https://github.com/citusdata/citus.git
Refactor binary header and footer functions
parent
54d13a8325
commit
3eaab16980
|
@ -70,7 +70,9 @@ static void ClearRowOutputState(OutputCopyState copyState);
|
||||||
static void OutputRow(Datum *valueArray, bool *isNullArray, TupleDesc rowDescriptor,
|
static void OutputRow(Datum *valueArray, bool *isNullArray, TupleDesc rowDescriptor,
|
||||||
OutputCopyState rowOutputState, FmgrInfo *columnOutputFunctions);
|
OutputCopyState rowOutputState, FmgrInfo *columnOutputFunctions);
|
||||||
static void OutputBinaryHeaders(FileOutputStream *partitionFileArray, uint32 fileCount);
|
static void OutputBinaryHeaders(FileOutputStream *partitionFileArray, uint32 fileCount);
|
||||||
|
static void CopySendBinaryHeaders(OutputCopyState headerOutputState);
|
||||||
static void OutputBinaryFooters(FileOutputStream *partitionFileArray, uint32 fileCount);
|
static void OutputBinaryFooters(FileOutputStream *partitionFileArray, uint32 fileCount);
|
||||||
|
static void CopySendBinaryFooters(OutputCopyState footerOutputState);
|
||||||
static void CopySendData(OutputCopyState outputState, const void *databuf, int datasize);
|
static void CopySendData(OutputCopyState outputState, const void *databuf, int datasize);
|
||||||
static void CopySendString(OutputCopyState outputState, const char *str);
|
static void CopySendString(OutputCopyState outputState, const char *str);
|
||||||
static void CopySendChar(OutputCopyState outputState, char c);
|
static void CopySendChar(OutputCopyState outputState, char c);
|
||||||
|
@ -1097,7 +1099,6 @@ OutputBinaryHeaders(FileOutputStream *partitionFileArray, uint32 fileCount)
|
||||||
for (fileIndex = 0; fileIndex < fileCount; fileIndex++)
|
for (fileIndex = 0; fileIndex < fileCount; fileIndex++)
|
||||||
{
|
{
|
||||||
/* Generate header for a binary copy */
|
/* Generate header for a binary copy */
|
||||||
const int32 zero = 0;
|
|
||||||
FileOutputStream partitionFile = { 0, 0, 0 };
|
FileOutputStream partitionFile = { 0, 0, 0 };
|
||||||
OutputCopyStateData headerOutputStateData;
|
OutputCopyStateData headerOutputStateData;
|
||||||
OutputCopyState headerOutputState = (OutputCopyState) & headerOutputStateData;
|
OutputCopyState headerOutputState = (OutputCopyState) & headerOutputStateData;
|
||||||
|
@ -1105,6 +1106,20 @@ OutputBinaryHeaders(FileOutputStream *partitionFileArray, uint32 fileCount)
|
||||||
memset(headerOutputState, 0, sizeof(OutputCopyStateData));
|
memset(headerOutputState, 0, sizeof(OutputCopyStateData));
|
||||||
headerOutputState->fe_msgbuf = makeStringInfo();
|
headerOutputState->fe_msgbuf = makeStringInfo();
|
||||||
|
|
||||||
|
CopySendBinaryHeaders(headerOutputState);
|
||||||
|
|
||||||
|
partitionFile = partitionFileArray[fileIndex];
|
||||||
|
FileOutputStreamWrite(partitionFile, headerOutputState->fe_msgbuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Append binary headers to the copy buffer in headerOutputState. */
|
||||||
|
static void
|
||||||
|
CopySendBinaryHeaders(OutputCopyState headerOutputState)
|
||||||
|
{
|
||||||
|
const int32 zero = 0;
|
||||||
|
|
||||||
/* Signature */
|
/* Signature */
|
||||||
CopySendData(headerOutputState, BinarySignature, 11);
|
CopySendData(headerOutputState, BinarySignature, 11);
|
||||||
|
|
||||||
|
@ -1113,10 +1128,6 @@ OutputBinaryHeaders(FileOutputStream *partitionFileArray, uint32 fileCount)
|
||||||
|
|
||||||
/* No header extension */
|
/* No header extension */
|
||||||
CopySendInt32(headerOutputState, zero);
|
CopySendInt32(headerOutputState, zero);
|
||||||
|
|
||||||
partitionFile = partitionFileArray[fileIndex];
|
|
||||||
FileOutputStreamWrite(partitionFile, headerOutputState->fe_msgbuf);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1131,7 +1142,6 @@ OutputBinaryFooters(FileOutputStream *partitionFileArray, uint32 fileCount)
|
||||||
for (fileIndex = 0; fileIndex < fileCount; fileIndex++)
|
for (fileIndex = 0; fileIndex < fileCount; fileIndex++)
|
||||||
{
|
{
|
||||||
/* Generate footer for a binary copy */
|
/* Generate footer for a binary copy */
|
||||||
int16 negative = -1;
|
|
||||||
FileOutputStream partitionFile = { 0, 0, 0 };
|
FileOutputStream partitionFile = { 0, 0, 0 };
|
||||||
OutputCopyStateData footerOutputStateData;
|
OutputCopyStateData footerOutputStateData;
|
||||||
OutputCopyState footerOutputState = (OutputCopyState) & footerOutputStateData;
|
OutputCopyState footerOutputState = (OutputCopyState) & footerOutputStateData;
|
||||||
|
@ -1139,7 +1149,7 @@ OutputBinaryFooters(FileOutputStream *partitionFileArray, uint32 fileCount)
|
||||||
memset(footerOutputState, 0, sizeof(OutputCopyStateData));
|
memset(footerOutputState, 0, sizeof(OutputCopyStateData));
|
||||||
footerOutputState->fe_msgbuf = makeStringInfo();
|
footerOutputState->fe_msgbuf = makeStringInfo();
|
||||||
|
|
||||||
CopySendInt16(footerOutputState, negative);
|
CopySendBinaryFooters(footerOutputState);
|
||||||
|
|
||||||
partitionFile = partitionFileArray[fileIndex];
|
partitionFile = partitionFileArray[fileIndex];
|
||||||
FileOutputStreamWrite(partitionFile, footerOutputState->fe_msgbuf);
|
FileOutputStreamWrite(partitionFile, footerOutputState->fe_msgbuf);
|
||||||
|
@ -1147,6 +1157,16 @@ OutputBinaryFooters(FileOutputStream *partitionFileArray, uint32 fileCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Append binary footers to the copy buffer in footerOutputState. */
|
||||||
|
static void
|
||||||
|
CopySendBinaryFooters(OutputCopyState footerOutputState)
|
||||||
|
{
|
||||||
|
int16 negative = -1;
|
||||||
|
|
||||||
|
CopySendInt16(footerOutputState, negative);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
/* Append data to the copy buffer in outputState */
|
/* Append data to the copy buffer in outputState */
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue