Skip to content

Commit

Permalink
query: add tag index and tag queries
Browse files Browse the repository at this point in the history
  • Loading branch information
jb55 committed Jan 9, 2024
1 parent 33c4740 commit 591499c
Show file tree
Hide file tree
Showing 5 changed files with 320 additions and 20 deletions.
1 change: 1 addition & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ execution plan for tags query
execution plan for created_at query
note kind index rebuild migration
(A) filter from json
tags index migration
17 changes: 16 additions & 1 deletion ndb.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ static void print_stats(struct ndb_stat *stat)

int ndb_print_search_keys(struct ndb_txn *txn);
int ndb_print_kind_keys(struct ndb_txn *txn);
int ndb_print_tag_keys(struct ndb_txn *txn);

static void print_note(struct ndb_note *note)
{
Expand Down Expand Up @@ -188,7 +189,7 @@ int main(int argc, char *argv[])
argc -= 2;
current_field = 0;

for (i = 0; argc && i < 3; i++) {
for (i = 0; argc && i < 100; i++) {
if (!strcmp(argv[0], "-k")) {
if (current_field != NDB_FILTER_KINDS)
ndb_filter_start_field(f, NDB_FILTER_KINDS);
Expand Down Expand Up @@ -218,6 +219,16 @@ int main(int argc, char *argv[])
ndb_filter_end_field(f);
argv += 2;
argc -= 2;
} else if (!strcmp(argv[0], "-t")) {
if (current_field) {
ndb_filter_end_field(f);
current_field = 0;
}
ndb_filter_start_tag_field(f, 't');
ndb_filter_add_str_element(f, argv[1]);
ndb_filter_end_field(f);
argv += 2;
argc -= 2;
}
}

Expand Down Expand Up @@ -258,6 +269,10 @@ int main(int argc, char *argv[])
ndb_begin_query(ndb, &txn);
ndb_print_kind_keys(&txn);
ndb_end_query(&txn);
} else if (argc == 2 && !strcmp(argv[1], "print-tag-keys")) {
ndb_begin_query(ndb, &txn);
ndb_print_tag_keys(&txn);
ndb_end_query(&txn);
} else {
return usage();
}
Expand Down
Loading

0 comments on commit 591499c

Please sign in to comment.