File tree Expand file tree Collapse file tree 2 files changed +26
-14
lines changed Expand file tree Collapse file tree 2 files changed +26
-14
lines changed Original file line number Diff line number Diff line change 11# jsonbc
22
3- JSONB compression method for PostgreSQL
3+ JSONB compression method for PostgreSQL.
44
5- ## Using
5+ ## Usage
66
7- To use it the following patch should be applied to postgresql (git: master ):
7+ To use it the following patch should be applied to PostgreSQL code (git: master ):
88
99https://commitfest.postgresql.org/15/1294/
1010
@@ -16,3 +16,5 @@ CREATE COMPRESSION METHOD cm1 HANDLER jsonbc_compression_handler;
1616CREATE TABLE t(a JSONB);
1717ALTER TABLE t ALTER COLUMN a SET COMPRESSED cm1;
1818```
19+
20+ This is very early version and should not be used in any real systems.
Original file line number Diff line number Diff line change @@ -207,21 +207,31 @@ jsonbc_compress(AttributeCompression *ac, const struct varlena *data)
207207 it = JsonbIteratorInit (& ((Jsonb * ) data )-> root );
208208 while ((r = JsonbIteratorNext (& it , & v , false)) != 0 )
209209 {
210- if (r == WJB_KEY )
210+ switch (r )
211211 {
212- int len ;
213- int32 key_id ;
214- unsigned char * ptr = palloc0 (6 );
212+ case WJB_BEGIN_OBJECT :
213+ break ;
214+ case WJB_KEY :
215+ {
216+ int len ;
217+ int32 key_id ;
218+ unsigned char * ptr = palloc0 (6 );
215219
216- Assert (v .type == jbvString );
217- key_id = get_key_id (ac -> cmoptoid , v .val .string .val , v .val .string .len );
220+ Assert (v .type == jbvString );
221+ key_id = get_key_id (ac -> cmoptoid , v .val .string .val , v .val .string .len );
218222
219- encode_varbyte (key_id , ptr , & len );
220- Assert (len <= 5 );
223+ encode_varbyte (key_id , ptr , & len );
224+ Assert (len <= 5 );
221225
222- v .type = jbvString ;
223- v .val .string .val = (char * ) ptr ;
224- v .val .string .len = len ;
226+ v .type = jbvString ;
227+ v .val .string .val = (char * ) ptr ;
228+ v .val .string .len = len ;
229+ break ;
230+ }
231+ case WJB_END_OBJECT :
232+ break ;
233+ default :
234+ break ;
225235 }
226236 jbv = pushJsonbValue (& state , r , r < WJB_BEGIN_ARRAY ? & v : NULL );
227237 }
You can’t perform that action at this time.
0 commit comments