commit 3c2e8b728fe74b058b85d7e036f7a3bd451eea14
parent 8269ca59cdbdf3cf2629323c2e78381e2d58c454
Author: William Casarin <jb55@jb55.com>
Date: Thu, 23 Nov 2023 13:20:20 -0800
nostrdb/index: create kind+timestamp index database
We don't build the index yet, but create the database like the others.
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/nostrdb/nostrdb.c b/nostrdb/nostrdb.c
@@ -2208,6 +2208,11 @@ static int ndb_init_lmdb(const char *filename, struct ndb_lmdb *lmdb, size_t map
}
mdb_set_compare(txn, lmdb->dbs[NDB_DB_PROFILE_PK], ndb_tsid_compare);
+ if ((rc = mdb_dbi_open(txn, "note_kind", tsid_flags, &lmdb->dbs[NDB_DB_NOTE_KIND]))) {
+ fprintf(stderr, "mdb_dbi_open id failed: %s\n", mdb_strerror(rc));
+ return 0;
+ }
+ mdb_set_compare(txn, lmdb->dbs[NDB_DB_NOTE_KIND], ndb_u64_tsid_compare);
// Commit the transaction
if ((rc = mdb_txn_commit(txn))) {
diff --git a/nostrdb/nostrdb.h b/nostrdb/nostrdb.h
@@ -37,10 +37,11 @@ enum ndb_dbs {
NDB_DB_META,
NDB_DB_PROFILE,
NDB_DB_NOTE_ID,
- NDB_DB_PROFILE_PK,
+ NDB_DB_PROFILE_PK, // profile pk index
NDB_DB_NDB_META,
NDB_DB_PROFILE_SEARCH,
NDB_DB_PROFILE_LAST_FETCH,
+ NDB_DB_NOTE_KIND, // note kind index
NDB_DBS,
};
@@ -525,6 +526,8 @@ ndb_db_name(enum ndb_dbs db)
return "profile_search";
case NDB_DB_PROFILE_LAST_FETCH:
return "profile_last_fetch";
+ case NDB_DB_NOTE_KIND:
+ return "note_kind_index";
case NDB_DBS:
return "count";
}