Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4d94911

Browse filesBrowse files
committed
finish refactoring, now indexes uses new interface. Get rid of JsQueryValue
1 parent 90a853d commit 4d94911
Copy full SHA for 4d94911

File tree

3 files changed

+92
-137
lines changed
Filter options

3 files changed

+92
-137
lines changed

‎jsonb_gin_ops.c

Copy file name to clipboardExpand all lines: jsonb_gin_ops.c
+13-13Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ typedef struct
5959
static uint32 get_bloom_value(uint32 hash);
6060
static uint32 get_path_bloom(PathHashStack *stack);
6161
static GINKey *make_gin_key(JsonbValue *v, uint32 hash);
62-
static GINKey *make_gin_query_key(JsQueryValue *value, uint32 hash);
62+
static GINKey *make_gin_query_key(JsQueryItemR *value, uint32 hash);
6363
static GINKey *make_gin_query_key_minus_inf(uint32 hash);
6464
static int32 compare_gin_key_value(GINKey *arg1, GINKey *arg2);
6565
static int add_entry(Entries *e, Datum key, Pointer extra, bool pmatch);
@@ -281,11 +281,11 @@ make_gin_key(JsonbValue *v, uint32 hash)
281281
}
282282

283283
static GINKey *
284-
make_gin_query_key(JsQueryValue *value, uint32 hash)
284+
make_gin_query_key(JsQueryItemR *value, uint32 hash)
285285
{
286286
GINKey *key;
287-
char *jqBase = value->jqBase;
288-
int len, jqPos = value->jqPos;
287+
int32 len;
288+
char *s;
289289
Numeric numeric;
290290

291291
switch(value->type)
@@ -296,21 +296,19 @@ make_gin_query_key(JsQueryValue *value, uint32 hash)
296296
SET_VARSIZE(key, GINKEYLEN);
297297
break;
298298
case jqiString:
299-
read_int32(len, jqBase, jqPos);
300299
key = (GINKey *)palloc(GINKeyLenString);
301300
key->type = jbvString;
302-
GINKeyDataString(key) = hash_any((unsigned char *)jqBase + jqPos,
303-
len);
301+
s = jsqGetString(value, &len);
302+
GINKeyDataString(key) = hash_any((unsigned char *)s, len);
304303
SET_VARSIZE(key, GINKeyLenString);
305304
break;
306305
case jqiBool:
307-
read_byte(len, jqBase, jqPos);
308306
key = (GINKey *)palloc(GINKEYLEN);
309-
key->type = jbvBool | (len ? GINKeyTrue : 0);
307+
key->type = jbvBool | (jsqGetBool(value) ? GINKeyTrue : 0);
310308
SET_VARSIZE(key, GINKEYLEN);
311309
break;
312310
case jqiNumeric:
313-
numeric = (Numeric)(jqBase + jqPos);
311+
numeric = jsqGetNumeric(value);
314312
key = (GINKey *)palloc(GINKeyLenNumeric(VARSIZE_ANY(numeric)));
315313
key->type = jbvNumeric;
316314
memcpy(GINKeyDataNumeric(key), numeric, VARSIZE_ANY(numeric));
@@ -319,6 +317,7 @@ make_gin_query_key(JsQueryValue *value, uint32 hash)
319317
default:
320318
elog(ERROR,"Wrong state");
321319
}
320+
322321
key->hash = hash;
323322
return key;
324323
}
@@ -852,10 +851,11 @@ make_hash_entry_handler(ExtractedNode *node, Pointer extra)
852851
{
853852
if (node->bounds.exact->type == jqiAny)
854853
{
855-
JsQueryValue value;
856-
value.jqBase = NULL;
857-
value.jqPos = 0;
854+
JsQueryItemR value;
855+
858856
value.type = jqiNull;
857+
value.nextPos = 0;
858+
value.base = NULL;
859859
key = make_gin_query_key(&value, hash);
860860
partialMatch = true;
861861
keyExtra->lossy = true;

‎jsquery.h

Copy file name to clipboardExpand all lines: jsquery.h
+4-11Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ typedef enum
154154
typedef struct PathItem PathItem;
155155
struct PathItem
156156
{
157-
char *s;
158157
PathItemType type;
159158
int len;
159+
char *s;
160160
PathItem *parent;
161161
};
162162

@@ -168,13 +168,6 @@ typedef enum
168168
eNot
169169
} ExtractedNodeType;
170170

171-
typedef struct
172-
{
173-
char *jqBase;
174-
int32 jqPos;
175-
int32 type;
176-
} JsQueryValue;
177-
178171
typedef struct ExtractedNode ExtractedNode;
179172
struct ExtractedNode
180173
{
@@ -193,9 +186,9 @@ struct ExtractedNode
193186
bool inequality;
194187
bool leftInclusive;
195188
bool rightInclusive;
196-
JsQueryValue *exact;
197-
JsQueryValue *leftBound;
198-
JsQueryValue *rightBound;
189+
JsQueryItemR *exact;
190+
JsQueryItemR *leftBound;
191+
JsQueryItemR *rightBound;
199192
} bounds;
200193
int entryNum;
201194
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.