SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
implement rocksdb changes
Chris Lu34a846009db2
diff --git a/weed/filer/rocksdb/rocksdb_store.go b/weed/filer/rocksdb/rocksdb_store.goindex 0793f547c7..fd0c966639 100644--- a/weed/filer/rocksdb/rocksdb_store.go+++ b/weed/filer/rocksdb/rocksdb_store.go@@ -158,7 +158,7 @@ func (store *RocksDBStore) DeleteFolderChildren(ctx context.Context, fullpath weiter := store.db.NewIterator(ro)defer iter.Close()- err = enumerate(iter, directoryPrefix, nil, false, -1, func(key, value []byte) bool {+ _, err = enumerate(iter, directoryPrefix, nil, false, -1, func(key, value []byte) bool {batch.Delete(key)return true})@@ -175,7 +175,7 @@ func (store *RocksDBStore) DeleteFolderChildren(ctx context.Context, fullpath wereturn nil}-func enumerate(iter *gorocksdb.Iterator, prefix, lastKey []byte, includeLastKey bool, limit int, fn func(key, value []byte) bool) error {+func enumerate(iter *gorocksdb.Iterator, prefix, lastKey []byte, includeLastKey bool, limit int, fn func(key, value []byte) bool) (hasMore bool, err error) {if len(lastKey) == 0 {iter.Seek(prefix)@@ -196,6 +196,7 @@ func enumerate(iter *gorocksdb.Iterator, prefix, lastKey []byte, includeLastKeyif limit > 0 {i++if i > limit {+ hasMore = truebreak}}@@ -215,22 +216,21 @@ func enumerate(iter *gorocksdb.Iterator, prefix, lastKey []byte, includeLastKey}if err := iter.Err(); err != nil {- return fmt.Errorf("prefix scan iterator: %v", err)+ return hasMore, fmt.Errorf("prefix scan iterator: %v", err)}- return nil+ return hasMore, nil}-func (store *RocksDBStore) ListDirectoryEntries(ctx context.Context, fullpath weed_util.FullPath, startFileName string, inclusive bool,- limit int) (entries []*filer.Entry, err error) {- return store.ListDirectoryPrefixedEntries(ctx, fullpath, startFileName, inclusive, limit, "")+func (store *RocksDBStore) ListDirectoryEntries(ctx context.Context, dirPath weed_util.FullPath, startFileName string, includeStartFile bool, limit int) (entries []*filer.Entry, hasMore bool, err error) {+ return store.ListDirectoryPrefixedEntries(ctx, dirPath, startFileName, includeStartFile, limit, "")}-func (store *RocksDBStore) ListDirectoryPrefixedEntries(ctx context.Context, fullpath weed_util.FullPath, startFileName string, inclusive bool, limit int, prefix string) (entries []*filer.Entry, err error) {+func (store *RocksDBStore) ListDirectoryPrefixedEntries(ctx context.Context, dirPath weed_util.FullPath, startFileName string, includeStartFile bool, limit int, prefix string) (entries []*filer.Entry, hasMore bool, err error) {- directoryPrefix := genDirectoryKeyPrefix(fullpath, prefix)+ directoryPrefix := genDirectoryKeyPrefix(dirPath, prefix)lastFileStart := directoryPrefixif startFileName != "" {- lastFileStart = genDirectoryKeyPrefix(fullpath, startFileName)+ lastFileStart = genDirectoryKeyPrefix(dirPath, startFileName)}ro := gorocksdb.NewDefaultReadOptions()@@ -239,13 +239,13 @@ func (store *RocksDBStore) ListDirectoryPrefixedEntries(ctx context.Context, fuliter := store.db.NewIterator(ro)defer iter.Close()- err = enumerate(iter, directoryPrefix, lastFileStart, inclusive, limit, func(key, value []byte) bool {+ hasMore, err = enumerate(iter, directoryPrefix, lastFileStart, includeStartFile, limit, func(key, value []byte) bool {fileName := getNameFromKey(key)if fileName == "" {return true}entry := &filer.Entry{- FullPath: weed_util.NewFullPath(string(fullpath), fileName),+ FullPath: weed_util.NewFullPath(string(dirPath), fileName),}// println("list", entry.FullPath, "chunks", len(entry.Chunks))@@ -258,10 +258,10 @@ func (store *RocksDBStore) ListDirectoryPrefixedEntries(ctx context.Context, fulreturn true})if err != nil {- return entries, fmt.Errorf("prefix list %s : %v", fullpath, err)+ return entries, false, fmt.Errorf("prefix list %s : %v", dirPath, err)}- return entries, err+ return entries, false, err}func genKey(dirPath, fileName string) (key []byte) {