Migrate package imports from next.orly.dev to new orly domain structure; add new varint and binary encoders with comprehensive tests; enhance existing tag and envelope implementations with additional methods, validations, and test coverage; introduce shared test.sh script for streamlined testing across modules.

This commit is contained in:
2025-08-31 16:52:24 +01:00
parent 94383f29e9
commit 91d95c6f1a
202 changed files with 12803 additions and 420 deletions

View File

@@ -0,0 +1,51 @@
package database
import (
"bytes"
"sort"
"database.orly/indexes/types"
"github.com/dgraph-io/badger/v4"
"lol.mleku.dev/chk"
)
func (d *D) GetSerialsByRange(idx Range) (
sers types.Uint40s, err error,
) {
if err = d.View(
func(txn *badger.Txn) (err error) {
it := txn.NewIterator(
badger.IteratorOptions{
Reverse: true,
},
)
defer it.Close()
for it.Seek(idx.End); it.Valid(); it.Next() {
item := it.Item()
var key []byte
key = item.Key()
if bytes.Compare(
key[:len(key)-5], idx.Start,
) < 0 {
// didn't find it within the timestamp range
return
}
ser := new(types.Uint40)
buf := bytes.NewBuffer(key[len(key)-5:])
if err = ser.UnmarshalRead(buf); chk.E(err) {
return
}
sers = append(sers, ser)
}
return
},
); chk.E(err) {
return
}
sort.Slice(
sers, func(i, j int) bool {
return sers[i].Get() < sers[j].Get()
},
)
return
}