Skip to content

Commit 8fd5438

Browse files
gongxun0928jiaqizho
authored andcommitted
PAX: The type of ptblockname is changed to int type
The type of ptblockname is changed to int type, because the naming of table block files is implemented through the self-incrementing id, and using int index for query is more efficient.
1 parent 24b6f63 commit 8fd5438

20 files changed

Lines changed: 367 additions & 382 deletions

contrib/pax_storage/expected/setup.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CREATE OR REPLACE FUNCTION "get_pax_aux_table"(table_name text)
2-
RETURNS TABLE("ptblockname" name,"pttupcount" integer,
2+
RETURNS TABLE("ptblockname" integer,"pttupcount" integer,
33
"ptstatistics" pg_ext_aux.paxauxstats,
44
"ptexistvisimap" bool, "ptexistexttoast" bool, "ptisclustered" bool) AS $BODY$
55
DECLARE

contrib/pax_storage/expected/statistics.out

Lines changed: 191 additions & 191 deletions
Large diffs are not rendered by default.

contrib/pax_storage/expected/zorder_cluster.out

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ insert into t_zorder_cluster select i,i from generate_series(1,100000) i;
1919
select ptblockname,ptstatistics,ptisclustered from get_pax_aux_table('t_zorder_cluster');
2020
ptblockname | ptstatistics | ptisclustered
2121
-------------+-------------------------------------------------------------------------------------------------+---------------
22-
0 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
23-
1 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
24-
2 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
25-
3 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
26-
4 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
27-
0 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
28-
1 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
29-
2 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
30-
3 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
31-
4 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
32-
0 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
33-
1 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
34-
2 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
35-
3 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
36-
4 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
22+
0 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
23+
1 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
24+
2 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
25+
3 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
26+
4 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
27+
0 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
28+
1 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
29+
2 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
30+
3 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
31+
4 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
32+
0 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
33+
1 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
34+
2 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
35+
3 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
36+
4 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
3737
(15 rows)
3838

3939
-- error, becuase no cluster index or cluster_columns is defined
@@ -54,12 +54,12 @@ cluster t_zorder_cluster;
5454
select ptblockname,ptstatistics,ptisclustered from get_pax_aux_table('t_zorder_cluster');
5555
ptblockname | ptstatistics | ptisclustered
5656
-------------+---------------------------------------------------------------------------------------------------------+---------------
57-
5 | [(false,false),(131072),(1,78633),(5126644321)],[(false,false),(131072),(1,78633),(5126644321)] | t
58-
6 | [(false,false),(35563),(78633,99996),(3178950384)],[(false,false),(35563),(78633,99996),(3178950384)] | t
59-
5 | [(false,false),(131072),(2,78230),(5147801190)],[(false,false),(131072),(2,78230),(5147801190)] | t
60-
6 | [(false,false),(36238),(78230,99999),(3226202455)],[(false,false),(36238),(78230,99999),(3226202455)] | t
61-
5 | [(false,false),(131072),(5,79072),(5187913809)],[(false,false),(131072),(5,79072),(5187913809)] | t
62-
6 | [(false,false),(34983),(79072,100000),(3132737841)],[(false,false),(34983),(79072,100000),(3132737841)] | t
57+
5 | [(false,false),(131072),(1,78633),(5126644321)],[(false,false),(131072),(1,78633),(5126644321)] | t
58+
6 | [(false,false),(35563),(78633,99996),(3178950384)],[(false,false),(35563),(78633,99996),(3178950384)] | t
59+
5 | [(false,false),(131072),(2,78230),(5147801190)],[(false,false),(131072),(2,78230),(5147801190)] | t
60+
6 | [(false,false),(36238),(78230,99999),(3226202455)],[(false,false),(36238),(78230,99999),(3226202455)] | t
61+
5 | [(false,false),(131072),(5,79072),(5187913809)],[(false,false),(131072),(5,79072),(5187913809)] | t
62+
6 | [(false,false),(34983),(79072,100000),(3132737841)],[(false,false),(34983),(79072,100000),(3132737841)] | t
6363
(6 rows)
6464

6565
drop table t_zorder_cluster;
@@ -85,21 +85,21 @@ insert into t_index_cluster select i,i from generate_series(1,100000) i;
8585
select ptblockname,ptstatistics,ptisclustered from get_pax_aux_table('t_index_cluster');
8686
ptblockname | ptstatistics | ptisclustered
8787
-------------+-------------------------------------------------------------------------------------------------+---------------
88-
0 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
89-
1 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
90-
2 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
91-
3 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
92-
4 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
93-
0 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
94-
1 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
95-
2 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
96-
3 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
97-
4 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
98-
0 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
99-
1 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
100-
2 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
101-
3 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
102-
4 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
88+
0 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
89+
1 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
90+
2 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
91+
3 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
92+
4 | [(false,false),(33327),(1,99996),(1661118941)],[(false,false),(33327),(1,99996),(1661118941)] | f
93+
0 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
94+
1 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
95+
2 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
96+
3 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
97+
4 | [(false,false),(33211),(5,100000),(1664130330)],[(false,false),(33211),(5,100000),(1664130330)] | f
98+
0 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
99+
1 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
100+
2 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
101+
3 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
102+
4 | [(false,false),(33462),(2,99999),(1674800729)],[(false,false),(33462),(2,99999),(1674800729)] | f
103103
(15 rows)
104104

105105
-- error, becuase no cluster index or cluster_columns is defined
@@ -122,12 +122,12 @@ cluster t_index_cluster using idx_t_index_cluster;
122122
select ptblockname,ptstatistics,ptisclustered from get_pax_aux_table('t_index_cluster');
123123
ptblockname | ptstatistics | ptisclustered
124124
-------------+---------------------------------------------------------------------------------------------------------+---------------
125-
0 | [(false,false),(131072),(2,78230),(5147801190)],[(false,false),(131072),(2,78230),(5147801190)] | t
126-
1 | [(false,false),(36238),(78230,99999),(3226202455)],[(false,false),(36238),(78230,99999),(3226202455)] | t
127-
0 | [(false,false),(131072),(1,78633),(5126644321)],[(false,false),(131072),(1,78633),(5126644321)] | t
128-
1 | [(false,false),(35563),(78633,99996),(3178950384)],[(false,false),(35563),(78633,99996),(3178950384)] | t
129-
0 | [(false,false),(131072),(5,79072),(5187913809)],[(false,false),(131072),(5,79072),(5187913809)] | t
130-
1 | [(false,false),(34983),(79072,100000),(3132737841)],[(false,false),(34983),(79072,100000),(3132737841)] | t
125+
0 | [(false,false),(131072),(2,78230),(5147801190)],[(false,false),(131072),(2,78230),(5147801190)] | t
126+
1 | [(false,false),(36238),(78230,99999),(3226202455)],[(false,false),(36238),(78230,99999),(3226202455)] | t
127+
0 | [(false,false),(131072),(1,78633),(5126644321)],[(false,false),(131072),(1,78633),(5126644321)] | t
128+
1 | [(false,false),(35563),(78633,99996),(3178950384)],[(false,false),(35563),(78633,99996),(3178950384)] | t
129+
0 | [(false,false),(131072),(5,79072),(5187913809)],[(false,false),(131072),(5,79072),(5187913809)] | t
130+
1 | [(false,false),(34983),(79072,100000),(3132737841)],[(false,false),(34983),(79072,100000),(3132737841)] | t
131131
(6 rows)
132132

133133
drop table t_index_cluster;
@@ -161,9 +161,9 @@ cluster t_both_zorder_and_index_cluster;
161161
create table t_zorder_unsupport_type(c1 int, c2 numeric(10,2),c3 varchar(128), c4 timestamp, c5 bpchar(64) ) using pax with(minmax_columns='c1,c2');
162162
-- error, because numeric is unsupport type
163163
alter table t_zorder_unsupport_type set(cluster_columns='c1,c2');
164-
ERROR: the type of column c2 does not support zorder cluster (paxc_rel_options.cc:307)
164+
ERROR: the type of column c2 does not support zorder cluster (paxc_rel_options.cc:312)
165165
alter table t_zorder_unsupport_type set(cluster_columns='c1,c3');
166166
-- error, because timestamp is unsupport type
167167
alter table t_zorder_unsupport_type set(cluster_columns='c1,c4');
168-
ERROR: the type of column c4 does not support zorder cluster (paxc_rel_options.cc:307)
168+
ERROR: the type of column c4 does not support zorder cluster (paxc_rel_options.cc:312)
169169
alter table t_zorder_unsupport_type set(cluster_columns='c1,c5');

contrib/pax_storage/init_file

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,7 @@ s/.//gs
157157
-- start_matchsubs
158158
m/\(pax_access_handle.cc:\d+\)/
159159
s/\(pax_access_handle.cc:\d+\)/\(pax_access_handle.cc:###\)/
160+
161+
m/\(paxc_rel_options.cc:\d+\)/
162+
s/\(paxc_rel_options.cc:\d+\)/\(paxc_rel_options.cc:###\)/
160163
-- end_matchsubs

contrib/pax_storage/sql/setup.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CREATE EXTENSION gp_inject_fault;
44
-- end_ignore
55

66
CREATE OR REPLACE FUNCTION "get_pax_aux_table"(table_name text)
7-
RETURNS TABLE("ptblockname" name,"pttupcount" integer,
7+
RETURNS TABLE("ptblockname" integer,"pttupcount" integer,
88
"ptstatistics" pg_ext_aux.paxauxstats,
99
"ptexistvisimap" bool, "ptexistexttoast" bool, "ptisclustered" bool) AS $BODY$
1010
DECLARE

contrib/pax_storage/src/cpp/access/pax_deleter.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ TM_Result CPaxDeleter::DeleteTuple(Relation relation, ItemPointer tid,
3636
TM_Result CPaxDeleter::MarkDelete(ItemPointer tid) {
3737
uint32 tuple_offset = pax::GetTupleOffset(*tid);
3838

39-
std::string block_id = MapToBlockNumber(rel_, *tid);
39+
int block_id = MapToBlockNumber(rel_, *tid);
4040

4141
if (block_bitmap_map_.find(block_id) == block_bitmap_map_.end()) {
4242
block_bitmap_map_[block_id] =
@@ -55,7 +55,7 @@ TM_Result CPaxDeleter::MarkDelete(ItemPointer tid) {
5555
}
5656

5757
bool CPaxDeleter::IsMarked(ItemPointerData tid) const {
58-
std::string block_id = MapToBlockNumber(rel_, tid);
58+
int block_id = MapToBlockNumber(rel_, tid);
5959
auto it = block_bitmap_map_.find(block_id);
6060

6161
if (it == block_bitmap_map_.end()) return false;
@@ -67,7 +67,7 @@ bool CPaxDeleter::IsMarked(ItemPointerData tid) const {
6767

6868
// used for merge remaining partition files, no tuple needs to delete
6969
void CPaxDeleter::MarkDelete(BlockNumber pax_block_id) {
70-
std::string block_id = std::to_string(pax_block_id);
70+
int block_id = int(pax_block_id);
7171

7272
if (block_bitmap_map_.find(block_id) == block_bitmap_map_.end()) {
7373
block_bitmap_map_[block_id] = pax_shared_ptr<Bitmap8>(PAX_NEW<Bitmap8>());
@@ -95,12 +95,12 @@ CPaxDeleter::BuildDeleteIterator() {
9595
rel_->rd_node, rel_->rd_backend,
9696
cbdb::IsDfsTablespaceById(rel_->rd_rel->reltablespace));
9797
for (auto &it : block_bitmap_map_) {
98-
std::string block_id = it.first;
98+
std::string block_id = std::to_string(it.first);
9999
{
100100
pax::MicroPartitionMetadata meta_info;
101101

102102
meta_info.SetFileName(cbdb::BuildPaxFilePath(rel_path, block_id));
103-
meta_info.SetMicroPartitionId(std::move(block_id));
103+
meta_info.SetMicroPartitionId(it.first);
104104
micro_partitions.push_back(std::move(meta_info));
105105
}
106106
}

contrib/pax_storage/src/cpp/access/pax_deleter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CPaxDeleter {
2626

2727
private:
2828
std::unique_ptr<IteratorBase<MicroPartitionMetadata>> BuildDeleteIterator();
29-
std::map<std::string, std::shared_ptr<Bitmap8>> block_bitmap_map_;
29+
std::map<int, std::shared_ptr<Bitmap8>> block_bitmap_map_;
3030
Relation rel_;
3131
Snapshot snapshot_;
3232
TransactionId delete_xid_;

contrib/pax_storage/src/cpp/access/pax_scanner.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "access/pax_dml_state.h"
55
#include "access/pax_visimap.h"
66
#include "catalog/pax_aux_table.h"
7+
#include "catalog/pax_fastsequence.h"
78
#include "catalog/pg_pax_tables.h"
89
#include "comm/guc.h"
910
#include "comm/pax_memory.h"
@@ -36,14 +37,14 @@ bool IndexUniqueCheck(Relation rel, ItemPointer tid, Snapshot snapshot,
3637
bool * /*all_dead*/) {
3738
paxc::ScanAuxContext context;
3839
HeapTuple tuple;
39-
char block_name[NAMEDATALEN];
4040
Oid aux_relid;
4141
bool exists;
42+
int block_id;
4243

4344
aux_relid = ::paxc::GetPaxAuxRelid(RelationGetRelid(rel));
44-
snprintf(block_name, sizeof(block_name), "%u", pax::GetBlockNumber(*tid));
45+
block_id = pax::GetBlockNumber(*tid);
4546
context.BeginSearchMicroPartition(aux_relid, InvalidOid, snapshot,
46-
AccessShareLock, block_name);
47+
AccessShareLock, block_id);
4748
tuple = context.SearchMicroPartitionEntry();
4849
exists = HeapTupleIsValid(tuple);
4950
if (exists) {
@@ -132,7 +133,6 @@ bool PaxIndexScanDesc::OpenMicroPartition(BlockNumber block,
132133

133134
auto block_name = std::to_string(block);
134135
auto file_name = cbdb::BuildPaxFilePath(rel_path_, block_name);
135-
options.block_id = block_name;
136136
auto file = Singleton<LocalFileSystem>::GetInstance()->Open(file_name,
137137
fs::kReadMode);
138138
auto reader = PAX_NEW<OrcReader>(file);

0 commit comments

Comments
 (0)