Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ad90365

Browse files
committed
Add lsm3_top_index_size function
1 parent b4c56f5 commit ad90365

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lsm3--1.0.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,3 +797,7 @@ AS 'MODULE_PATHNAME' LANGUAGE C STRICT PARALLEL RESTRICTED;
797797
-- Wait merge completion
798798
CREATE FUNCTION lsm3_wait_merge_completion(index regclass) returns void
799799
AS 'MODULE_PATHNAME' LANGUAGE C STRICT PARALLEL RESTRICTED;
800+
801+
-- Get active top index size (number of blocks)
802+
CREATE FUNCTION lsm3_top_index_size(index regclass) returns void
803+
AS 'MODULE_PATHNAME' LANGUAGE C STRICT PARALLEL RESTRICTED;

lsm3.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ PG_FUNCTION_INFO_V1(lsm3_btree_wrapper);
3939
PG_FUNCTION_INFO_V1(lsm3_get_merge_count);
4040
PG_FUNCTION_INFO_V1(lsm3_start_merge);
4141
PG_FUNCTION_INFO_V1(lsm3_wait_merge_completion);
42+
PG_FUNCTION_INFO_V1(lsm3_top_index_size);
4243

4344
extern void _PG_init(void);
4445
extern void _PG_fini(void);
@@ -1007,3 +1008,13 @@ lsm3_wait_merge_completion(PG_FUNCTION_ARGS)
10071008
}
10081009
PG_RETURN_NULL();
10091010
}
1011+
1012+
Datum
1013+
lsm3_top_index_size(PG_FUNCTION_ARGS)
1014+
{
1015+
Oid relid = PG_GETARG_OID(0);
1016+
Relation index = index_open(relid, AccessShareLock);
1017+
Lsm3DictEntry* entry = lsm3_get_entry(index);
1018+
index_close(index, AccessShareLock);
1019+
PG_RETURN_INT32(lsm3_get_index_size(lsm3_get_index_size(entry->top[entry->active_index])));
1020+
}

0 commit comments

Comments
 (0)