Skip to content

Commit 85c1359

Browse files
committed
[unitdb] add query, ingestion and pubsub plugins for other clients to interact with Unitdb using rpc/grpc/grpc-web generic plugins
1 parent 24233a4 commit 85c1359

File tree

24 files changed

+5378
-654
lines changed

24 files changed

+5378
-654
lines changed

db_internal.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,10 @@ func (db *DB) close() error {
164164
return err
165165
}
166166

167-
// loadTopicHash loads topic and offset from window file.
167+
// loadTopicHash loads topic and offset from window blocks on stored on disk.
168168
func (db *DB) loadTrie() error {
169169
r := newWindowReader(db.fs)
170-
err := r.foreachWindowBlock(func(startSeq, topicHash uint64, off int64) (bool, error) {
170+
err := r.blockIterator(func(startSeq, topicHash uint64, off int64) (bool, error) {
171171
e, err := db.internal.reader.readEntry(startSeq)
172172
if err != nil {
173173
return true, err

db_sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ func (db *_SyncHandle) Sync() error {
214214
// defer profile.Start().Stop()
215215
var err1 error
216216
timeRelease := db.internal.timeWindow.release()
217-
err := db.internal.mem.ForEachBlock(func(timeID int64, seqs []uint64) (bool, error) {
217+
err := db.internal.mem.BlockIterator(func(timeID int64, seqs []uint64) (bool, error) {
218218
winEntries := make(map[uint64]_WindowEntries)
219219
sort.Slice(seqs[:], func(i, j int) bool {
220220
return seqs[i] < seqs[j]

db_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func TestBatch(t *testing.T) {
158158
}
159159
}
160160
var v, vals [][]byte
161-
v, err = db.Get(NewQuery(append(topic, []byte("?last=1h")...)).WithContract(contract))
161+
v, err = db.Get(NewQuery(append(topic, []byte("?last=1h")...)).WithContract(contract).WithLimit(int(n)))
162162
if err != nil {
163163
t.Fatal(err)
164164
}

examples/db/adapter.go

Lines changed: 0 additions & 65 deletions
This file was deleted.

examples/db/unitdb/adapter.go

Lines changed: 0 additions & 186 deletions
This file was deleted.

examples/memdb/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010

1111
func main() {
1212
// Opening a database.
13-
db, err := memdb.Open(memdb.WithLogFilePath("unitdb"))
13+
db, err := memdb.Open(memdb.WithLogFilePath("example"))
1414
if err != nil {
1515
log.Fatal(err)
1616
return

0 commit comments

Comments
 (0)