Skip to content

Commit

Permalink
Adds columnar.vacuum() and columnar.stats()
Browse files Browse the repository at this point in the history
  • Loading branch information
JerrySievert committed May 3, 2023
1 parent 6784a24 commit 172bf3f
Show file tree
Hide file tree
Showing 13 changed files with 1,036 additions and 6 deletions.
2 changes: 1 addition & 1 deletion columnar/src/backend/columnar/columnar.control
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
comment = 'Hydra Columnar extension'
default_version = '11.1-5'
default_version = '11.1-6'
module_pathname = '$libdir/columnar'
relocatable = false
30 changes: 30 additions & 0 deletions columnar/src/backend/columnar/columnar_metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "citus_version.h"
#include "columnar/columnar.h"
#include "columnar/columnar_metadata.h"
#include "columnar/columnar_storage.h"
#include "columnar/columnar_version_compat.h"
#include "columnar/utils/listutils.h"
Expand Down Expand Up @@ -2520,3 +2521,32 @@ GetHighestUsedRowNumber(uint64 storageId)

return highestRowNumber;
}

/*
* RewriteMetadataRowWithNewValues rewrites a given metadata entry
* for a storageId and a stripeId in place with a new offset,
* rowCount, sizeBytes, and chunkCount.
*
* This is used in the vacuum UDF to fill any existing holes
* if possible.
*/
StripeMetadata *
RewriteStripeMetadataRowWithNewValues(Relation rel, uint64 stripeId,
uint64 sizeBytes, uint64 fileOffset, uint64 rowCount, uint64 chunkCount)
{
uint64 storageId = ColumnarStorageGetStorageId(rel, false);

bool update[Natts_columnar_stripe] = { false };
update[Anum_columnar_stripe_file_offset - 1] = true;
update[Anum_columnar_stripe_data_length - 1] = true;
update[Anum_columnar_stripe_row_count - 1] = true;
update[Anum_columnar_stripe_chunk_count - 1] = true;

Datum newValues[Natts_columnar_stripe] = { 0 };
newValues[Anum_columnar_stripe_file_offset - 1] = Int64GetDatum(fileOffset);
newValues[Anum_columnar_stripe_data_length - 1] = Int64GetDatum(sizeBytes);
newValues[Anum_columnar_stripe_row_count - 1] = UInt64GetDatum(rowCount);
newValues[Anum_columnar_stripe_chunk_count - 1] = Int32GetDatum(chunkCount);

return UpdateStripeMetadataRow(storageId, stripeId, update, newValues);
}
4 changes: 3 additions & 1 deletion columnar/src/backend/columnar/columnar_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,9 @@ ColumnarEndRead(ColumnarReadState *readState)
pfree(readState->currentStripeMetadata);
}

pfree(readState);
if (readState) {
pfree(readState);
}
}


Expand Down
Loading

0 comments on commit 172bf3f

Please sign in to comment.