Implement an helper to create memory cxt for stripe read (#4965)

pull/4964/head^2
Onur Tirtir 2021-05-10 19:55:47 +03:00 committed by GitHub
parent 5a941814fd
commit 59fea712e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 3 deletions

View File

@ -83,6 +83,7 @@ struct ColumnarReadState
}; };
/* static function declarations */ /* static function declarations */
static MemoryContext CreateStripeReadMemoryContext(void);
static bool StripeReadInProgress(ColumnarReadState *readState); static bool StripeReadInProgress(ColumnarReadState *readState);
static bool HasUnreadStripe(ColumnarReadState *readState); static bool HasUnreadStripe(ColumnarReadState *readState);
static StripeReadState * BeginStripeRead(StripeMetadata *stripeMetadata, Relation rel, static StripeReadState * BeginStripeRead(StripeMetadata *stripeMetadata, Relation rel,
@ -162,9 +163,7 @@ ColumnarBeginRead(Relation relation, TupleDesc tupleDescriptor,
* this memory context before loading a new stripe. This is to avoid memory * this memory context before loading a new stripe. This is to avoid memory
* leaks. * leaks.
*/ */
MemoryContext stripeReadContext = AllocSetContextCreate(CurrentMemoryContext, MemoryContext stripeReadContext = CreateStripeReadMemoryContext();
"Stripe Read Memory Context",
ALLOCSET_DEFAULT_SIZES);
ColumnarReadState *readState = palloc0(sizeof(ColumnarReadState)); ColumnarReadState *readState = palloc0(sizeof(ColumnarReadState));
readState->relation = relation; readState->relation = relation;
@ -181,6 +180,18 @@ ColumnarBeginRead(Relation relation, TupleDesc tupleDescriptor,
} }
/*
* CreateStripeReadMemoryContext creates a memory context to be used when
* reading a stripe.
*/
static MemoryContext
CreateStripeReadMemoryContext()
{
return AllocSetContextCreate(CurrentMemoryContext, "Stripe Read Memory Context",
ALLOCSET_DEFAULT_SIZES);
}
/* /*
* ColumnarReadNextRow tries to read a row from the columnar table. 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, * column values and nulls, and returns true. If there are no more rows to read,