finish index feature
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
{"id":1,"status":"processed","tenant":"A","ts":1773305152,"type":"signup"}
|
||||
{"id":2,"status":"processed","tenant":"A","ts":1773305152,"type":"purchase"}
|
||||
{"id":1,"status":"new","tenant":"A","ts":1773311342,"type":"signup"}
|
||||
{"id":2,"status":"new","tenant":"A","ts":1773311342,"type":"purchase"}
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"id":3,"status":"new","tenant":"B","ts":1773305152,"type":"signup"}
|
||||
{"id":3,"status":"new","tenant":"B","ts":1773311342,"type":"signup"}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
{"createdAt":"2026-03-12T14:45:52.66645719+06:00","email":"a@example.com","id":1,"name":"Alice"}
|
||||
{"createdAt":"2026-03-12T14:45:52.666505533+06:00","email":"b@example.com","id":2,"name":"Bob"}
|
||||
{"createdAt":"2026-03-12T16:29:02.588642365+06:00","email":"a@example.com","id":1,"name":"Alice"}
|
||||
{"createdAt":"2026-03-12T16:29:02.58871104+06:00","email":"b@example.com","id":2,"name":"Bob"}
|
||||
|
||||
@@ -13,12 +13,13 @@ import (
|
||||
// Пример работы с партициями + индексируемой коллекцией.
|
||||
//
|
||||
// Запуск:
|
||||
// go run ./examples/partitions/main.go
|
||||
//
|
||||
// go run ./examples/partitions/main.go
|
||||
//
|
||||
// Важно:
|
||||
// - В текущей реализации индексы строятся для "обычных" коллекций.
|
||||
// - Партиционированные коллекции (партиции) создаются динамически и сейчас не индексируются
|
||||
// (см. getPartitionAdapter: JSONLFileOptions{CollectionName: partitionName} без IndexedFields).
|
||||
// - В текущей реализации индексы строятся для "обычных" коллекций.
|
||||
// - Партиционированные коллекции (партиции) создаются динамически и сейчас не индексируются
|
||||
// (см. getPartitionAdapter: JSONLFileOptions{CollectionName: partitionName} без IndexedFields).
|
||||
func main() {
|
||||
dbDir := filepath.Join(".", "examples", "partitions", "data")
|
||||
_ = os.RemoveAll(dbDir)
|
||||
@@ -41,6 +42,7 @@ func main() {
|
||||
{
|
||||
CollectionName: "events",
|
||||
AllocSize: 512,
|
||||
IndexedFields: []string{"id", "type"},
|
||||
},
|
||||
},
|
||||
Partitions: []linedb.PartitionCollection{
|
||||
@@ -103,13 +105,13 @@ func main() {
|
||||
log.Fatalf("Insert events failed: %v", err)
|
||||
}
|
||||
|
||||
tenantA, err := db.ReadByFilter(map[string]any{"tenant": "A"}, "events", linedb.LineDbAdapterOptions{})
|
||||
tenantA, err := db.ReadByFilter(map[string]any{"type": "signup", "tenant": "A"}, "events", linedb.LineDbAdapterOptions{})
|
||||
if err != nil {
|
||||
log.Fatalf("ReadByFilter events tenant A failed: %v", err)
|
||||
}
|
||||
mustLen("events tenant A after insert", tenantA, 2)
|
||||
|
||||
tenantB, err := db.ReadByFilter(map[string]any{"tenant": "B"}, "events", linedb.LineDbAdapterOptions{})
|
||||
tenantB, err := db.ReadByFilter(map[string]any{"type": "signup", "tenant": "B"}, "events", linedb.LineDbAdapterOptions{})
|
||||
if err != nil {
|
||||
log.Fatalf("ReadByFilter events tenant B failed: %v", err)
|
||||
}
|
||||
@@ -158,4 +160,3 @@ func mustLen(label string, got []any, want int) {
|
||||
log.Fatalf("%s: expected %d, got %d (%v)", label, want, len(got), got)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user