-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(v1.x.x): async pruning of orphan nodes (#876)
Co-authored-by: Dev Ojha <dojha@berkeley.edu> Co-authored-by: cool-developer <51834436+cool-develope@users.noreply.github.com>
- Loading branch information
1 parent
b0d383c
commit e1fa67e
Showing
10 changed files
with
275 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package keyformat | ||
|
||
import "encoding/binary" | ||
|
||
// This file builds some dedicated key formatters for what appears in benchmarks. | ||
|
||
// Prefixes a single byte before a 32 byte hash. | ||
type FastPrefixFormatter struct { | ||
prefix byte | ||
length int | ||
prefixSlice []byte | ||
} | ||
|
||
func NewFastPrefixFormatter(prefix byte, length int) *FastPrefixFormatter { | ||
return &FastPrefixFormatter{prefix: prefix, length: length, prefixSlice: []byte{prefix}} | ||
} | ||
|
||
func (f *FastPrefixFormatter) Key(bz []byte) []byte { | ||
key := make([]byte, 1+f.length) | ||
key[0] = f.prefix | ||
copy(key[1:], bz) | ||
return key | ||
} | ||
|
||
func (f *FastPrefixFormatter) Scan(key []byte, a interface{}) { | ||
scan(a, key[1:]) | ||
} | ||
|
||
func (f *FastPrefixFormatter) KeyInt64(bz int64) []byte { | ||
key := make([]byte, 1+f.length) | ||
key[0] = f.prefix | ||
binary.BigEndian.PutUint64(key[1:], uint64(bz)) | ||
return key | ||
} | ||
|
||
func (f *FastPrefixFormatter) Prefix() []byte { | ||
return f.prefixSlice | ||
} | ||
|
||
func (f *FastPrefixFormatter) Length() int { | ||
return 1 + f.length | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.