From 098f9578d64368aca77f2c1e7af2c3dacb30fe1f Mon Sep 17 00:00:00 2001 From: hofmockel Date: Tue, 1 Apr 2014 21:24:18 +0200 Subject: [PATCH] Change prefix_extractor to smart-pointer instead of raw --- docs/changelog.rst | 8 ++++++++ docs/installation.rst | 4 +--- rocksdb/_rocksdb.pyx | 29 ++++++++++++++--------------- rocksdb/options.pxd | 2 +- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 4eb97f7..f0d101f 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,14 @@ Changelog ********* +Upcoming Version +---------------- + +Target is to work with the next version of rocksdb. + +* Fixed `issue 3 `_. + Which fixed the change of prefix_extractor from raw-pointer to smart-pointer + Version 0.1 ----------- diff --git a/docs/installation.rst b/docs/installation.rst index 1d9ae6f..443d793 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -13,8 +13,6 @@ For more details consider https://github.com/facebook/rocksdb/blob/master/INSTAL $ apt-get install libsnappy-dev zlib1g-dev libbz2-dev libgflags-dev $ git clone https://github.com/facebook/rocksdb.git $ cd rocksdb - $ # It is tested with this version - $ git checkout 2.7.fb $ make librocksdb.so If you do not want to call ``make install`` export the following enviroment @@ -34,4 +32,4 @@ Building pyrocksdb $ cd pyrocks_test $ . bin/active $ pip install "Cython>=0.20" - $ pip install git+git://github.com/stephan-hof/pyrocksdb.git@v0.1 + $ pip install git+git://github.com/stephan-hof/pyrocksdb.git diff --git a/rocksdb/_rocksdb.pyx b/rocksdb/_rocksdb.pyx index e8b79c0..41aafc4 100644 --- a/rocksdb/_rocksdb.pyx +++ b/rocksdb/_rocksdb.pyx @@ -462,34 +462,33 @@ LRUCache = PyLRUCache ### Here comes the stuff for SliceTransform @cython.internal cdef class PySliceTransform(object): - cdef slice_transform.SliceTransformWrapper* transfomer + cdef shared_ptr[slice_transform.SliceTransform] transfomer cdef object ob def __cinit__(self, object ob): - self.transfomer = NULL if not isinstance(ob, ISliceTransform): raise TypeError("%s is not of type %s" % (ob, ISliceTransform)) self.ob = ob - self.transfomer = new slice_transform.SliceTransformWrapper( - bytes_to_string(ob.name()), - ob, - slice_transform_callback, - slice_in_domain_callback, - slice_in_range_callback) - - def __dealloc__(self): - if not self.transfomer == NULL: - del self.transfomer + self.transfomer.reset( + + new slice_transform.SliceTransformWrapper( + bytes_to_string(ob.name()), + ob, + slice_transform_callback, + slice_in_domain_callback, + slice_in_range_callback)) cdef object get_ob(self): return self.ob - cdef slice_transform.SliceTransform* get_transformer(self): - return self.transfomer + cdef shared_ptr[slice_transform.SliceTransform] get_transformer(self): + return self.transfomer cdef set_info_log(self, shared_ptr[logger.Logger] info_log): - self.transfomer.set_info_log(info_log) + cdef slice_transform.SliceTransformWrapper* ptr + ptr = self.transfomer.get() + ptr.set_info_log(info_log) cdef Slice slice_transform_callback( diff --git a/rocksdb/options.pxd b/rocksdb/options.pxd index 71f3a4c..92eae21 100644 --- a/rocksdb/options.pxd +++ b/rocksdb/options.pxd @@ -45,7 +45,7 @@ cdef extern from "rocksdb/options.h" namespace "rocksdb": CompressionType compression # TODO: compression_per_level # TODO: compression_opts - SliceTransform* prefix_extractor + shared_ptr[SliceTransform] prefix_extractor cpp_bool whole_key_filtering int num_levels int level0_file_num_compaction_trigger