Code Monkey home page Code Monkey logo

rust-rocks's People

Contributors

bh1xuw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rust-rocks's Issues

Segfault using column families

The following code segfaults:

use rocks::rocksdb::*;
fn main() {
    let database = DB::open_with_column_families(
        &Options::default_instance(),
        "foobar",
        vec![
            ColumnFamilyDescriptor::new(
                "default",
                ColumnFamilyOptions::new()
            ),
        ]
    ).unwrap();
}

The problem is that the database gets dropped before the column factory handles.

Issue with iterator and lifetimes

Consider the implementation of next() for Iterator

fn next(&mut self) -> Option<Self::Item> {
        if self.is_valid() {
            let k = self.key();
            let v = self.value();
            self.next();
            Some((k, v))
        } else {
            None
        }
    }

The self.next() line invalidates the returned references from self.key() and self.value(). Thus this iterator is always returning bad references.

But why didn't Rust catch this?

pub fn key(&self) -> &'a [u8] {

key (and value) claims to return a reference with lifetime 'a. But this isn't really accurate, as it should only be valid until the next &mut call on self (probably on .next()). Rust doesn't catch the problem because of the unsafe code used to implement the function (obviously unavoidable.)

Cache needs to be shareable

Hello, Cache can be used in multiple column families or databases at the same time.

Currently the functions that receive a Cache receive it as Option<Cache> as parameter, moving the cache as consequence.

I propose that we change it to Option<&Cache> so we send it by reference and allow using the same cache in multiple locations.

I have a commit in my fork with this change: sezaru@ae1eb65

It seems to work great, but maybe there is a better solution or some problem with it, so I'm first creating this issue to ask your opnion, and if it is ok, I will create a PR then.

TODOs / Feature set compared with C++ RocksDB

  • rocksdb/advanced_options.h
  • rocksdb/c.h
    • use c++ API to impl
  • rocksdb/cache.h
  • rocksdb/cleanable.h
    • a base class, used fore mixin?
  • rocksdb/compaction_filter.h
  • rocksdb/compaction_job_stats.h
  • rocksdb/comparator.h
  • rocksdb/convenience.h
    • get_compression_types
    • options stringify
    • options from map is needless for Rust
  • rocksdb/db.h
  • rocksdb/db_bench_tool.h
    • A main(), needless
  • rocksdb/db_dump_tool.h
  • rocksdb/env.h
    • will not support customized Env
  • rocksdb/env_encryption.h
    • won't support
  • rocksdb/experimental.h
  • rocksdb/filter_policy.h
    • NewBloomFilterPolicy
    • won't support customized FilterPolicy
  • rocksdb/flush_block_policy.h
    • customized FilterPolicy object
  • rocksdb/iostats_context.h
  • rocksdb/iterator.h
  • rocksdb/ldb_tool.h
    • something like a main()
  • rocksdb/listener.h
  • rocksdb/memtablerep.h
    • implemented via c, use different options
  • rocksdb/merge_operator.h
  • rocksdb/metadata.h
  • rocksdb/options.h
  • rocksdb/perf_context.h
  • rocksdb/perf_level.h
  • rocksdb/persistent_cache.h
    • NewPersistentCache
    • won't support customized PersistentCache
  • rocksdb/rate_limiter.h
  • rocksdb/slice.h
  • rocksdb/slice_transform.h
  • rocksdb/snapshot.h
  • rocksdb/sst_dump_tool.h
    • A main(), needless
  • rocksdb/sst_file_manager.h
    • NewSstFileManager
  • rocksdb/sst_file_writer.h
  • rocksdb/statistics.h
  • rocksdb/status.h
  • rocksdb/table.h
  • rocksdb/table_properties.h
  • rocksdb/thread_status.h
    • Api is not finalized
  • rocksdb/threadpool.h
    • seems no need to export in Rust
  • rocksdb/transaction_log.h
  • rocksdb/types.h
  • rocksdb/version.h
  • rocksdb/wal_filter.h
    • used in DBOptions
    • depends on WriteBatch iterator
  • rocksdb/write_batch.h
  • rocksdb/write_batch_base.h
    • base class no need to implemented
    • if WriteBatchWithIndex to be supported, then this is a must
  • rocksdb/write_buffer_manager.h
  • rocksdb/universal_compaction.h
  • rocksdb/utilities/backupable_db.h
  • rocksdb/utilities/checkpoint.h
    • can be impled with Builder pattern
  • rocksdb/utilities/convenience.h
    • deprecated
  • rocksdb/utilities/date_tiered_db.h
  • rocksdb/utilities/db_ttl.h
  • rocksdb/utilities/debug.h
  • rocksdb/utilities/document_db.h
  • rocksdb/utilities/env_librados.h
    • for Ceph
  • rocksdb/utilities/env_mirror.h
    • A tool for verify customized Env implementation
  • rocksdb/utilities/geo_db.h
  • rocksdb/utilities/info_log_finder.h
  • rocksdb/utilities/json_document.h
  • rocksdb/utilities/ldb_cmd.h
    • main() like
  • rocksdb/utilities/ldb_cmd_execute_result.h
  • rocksdb/utilities/leveldb_options.h
    • won't support
  • rocksdb/utilities/lua/rocks_lua_compaction_filter.h
    • won't support
  • rocksdb/utilities/lua/rocks_lua_custom_library.h
    • won't support
  • rocksdb/utilities/lua/rocks_lua_util.h
    • won't support
  • rocksdb/utilities/memory_util.h
    • MemoryUtil
  • rocksdb/utilities/object_registry.h
  • rocksdb/utilities/optimistic_transaction_db.h
  • rocksdb/utilities/option_change_migration.h
  • rocksdb/utilities/options_util.h
    • load options from file
    • CheckOptionsCompatibility
  • rocksdb/utilities/sim_cache.h
  • rocksdb/utilities/spatial_db.h
  • rocksdb/utilities/stackable_db.h
    • no need for Rust
  • rocksdb/utilities/table_properties_collectors.h
    • NewCompactOnDeletionCollectorFactory
  • rocksdb/utilities/transaction.h
    • requires transaction_db
  • rocksdb/utilities/transaction_db.h
  • rocksdb/utilities/transaction_db_mutex.h
  • rocksdb/utilities/utility_db.h
    • deprecated
  • rocksdb/utilities/write_batch_with_index.h
    • requires write_batch_batch to be implemented

Working with RocksDB on Win10

Hi everyone. I started to examine Rocksdb but recieving an error compiling hw project, having rocks="0.1" in [dependencies] of Cargo.toml.
I asked about this at the official forum, and was told that Rocksdb might not work on Windows10 .
Is there a way to use Rocksdb on Windows10, or im doing something else wrong?

Link with circular reference among 2 crates under Linux in Rust?

This issue is to track how to solve circular reference link error under Linux.

MacOS(llvm-lld) is OK to handle the circular references while linking.

GCC reuqire that you put the object files and libraries in the order that they depend on each other.

ld accepts the following options:

-( archives -)
--start-group archives --end-group

The specified archives are searched repeatedly until no new undefined references are created.

Yet, rust won't wrap user-defined in repeated search group.

Option 1

Use lld under Linux:

RUSTFLAGS="-C link-arg=-fuse-ld=lld" cargo test

Option 2

Use shell wrapper: #12

Memory Leaks

NOTE:

NO leaks if you don't use customized comparator or compaction filter.

rocks-sys/rocks/options.cc:

rocks_cfoptions_set_comparator_by_trait
rocks_cfoptions_set_compaction_filter_by_trait

Both leak 16 bytes when used in Option.set_xxx. (== sizeof A Rust Trait Object)

Reason:

In C++, these 2 options are static pointers, instead of std::shared_ptr. (They are to be used across many CFs.)

In Rust, use Box<Box<T>> as *mut Box<T> (1 pointer size = sizeof void*). Box::into_raw used without Box::from_raw.

Possible Solution:

Attach Comparator & CompactionFilter lifetime to DB or sth.

Questions about the project

First of all, thanks for the library!

I'm developing a rocksdb wrapper for Elixir language.

Currently, I'm using rust-rocksdb library instead of directly wrapping into C/C++ (for safety reasons). I recently found out about your library and became interested in maybe replace rust-rocksdb with it for my wrapper.

I just have some questions that I hope you can answer if you don't mind.

  1. Is this library a long-term project? I saw that you already have more functionality implemented compared to rust-rocksdb and also I find your organization way better (ex. You separate database options from column family options) but I was wondering if you pretend to continue develop this project in the future;

  2. One issue that I have with rust-rocksdb and I would probably have with your library too is lifetime objects.

For example, you need to define a lifetime to a Iterator struct, but if I want to return that iterator pointer via my wrapper (so I can use the iterator in Elixir code) it is not possible because of the lifetime.

As far as I understand, the only reason for the lifetime in Iterator is because of the PhantomData field:
_marker: PhantomData<&'a ()>.

Is it possible to provide an alternative to this without this field so Rust will not complain when I try to return it? Or maybe you know some other way around it that I'm not aware.

Thanks you for your time!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.