Skip to content

Commit

Permalink
Support ribbon filter, optimistic db write (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
linxGnu authored Nov 12, 2021
1 parent f27f40c commit 37398ca
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,4 @@ Almost C API, excepts:
- [ ] putv/mergev/deletev/delete_rangev
- [ ] compaction_filter/compaction_filter_factory/compaction_filter_context
- [ ] transactiondb_property_value/transactiondb_property_int
- [ ] optimistictransactiondb_write/optimistictransactiondb_checkpoint_object_create/optimistictransactiondb_property_value/optimistictransactiondb_property_int

- [ ] optimistictransactiondb_property_value/optimistictransactiondb_property_int
4 changes: 2 additions & 2 deletions filter_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ func NewBloomFilterFull(bitsPerKey float64) FilterPolicy {
//
// Also consider using optimize_filters_for_memory to save filter
// memory.
func NewRibbonFilterPolicy(bitsPerKey float64) FilterPolicy {
return NewNativeFilterPolicy(C.rocksdb_filterpolicy_create_ribbon(C.double(bitsPerKey)))
func NewRibbonFilterPolicy(bitsPerKey float64, bloomBeforeLevel int) FilterPolicy {
return NewNativeFilterPolicy(C.rocksdb_filterpolicy_create_ribbon_hybrid(C.double(bitsPerKey), C.int(bloomBeforeLevel)))
}

// Hold references to filter policies.
Expand Down
15 changes: 15 additions & 0 deletions optimistic_transaction_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,21 @@ func (db *OptimisticTransactionDB) TransactionBegin(
db.c, opts.c, transactionOpts.c, nil))
}

// NewCheckpoint creates a new Checkpoint for this db.
func (db *OptimisticTransactionDB) NewCheckpoint() (cp *Checkpoint, err error) {
var cErr *C.char

cCheckpoint := C.rocksdb_optimistictransactiondb_checkpoint_object_create(
db.c, &cErr,
)
if err = fromCError(cErr); err == nil {
cp = NewNativeCheckpoint(cCheckpoint)
}

return
}

// Write batch.
func (db *OptimisticTransactionDB) Write(opts *WriteOptions, batch *WriteBatch) (err error) {
var cErr *C.char

Expand Down

0 comments on commit 37398ca

Please sign in to comment.