Skip to content

Commit

Permalink
Change prefix_extractor to smart-pointer instead of raw
Browse files Browse the repository at this point in the history
  • Loading branch information
stephan-hof committed Apr 1, 2014
1 parent 82b88db commit 098f957
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
8 changes: 8 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Changelog
*********

Upcoming Version
----------------

Target is to work with the next version of rocksdb.

* Fixed `issue 3 <https://github.com/stephan-hof/pyrocksdb/pull/3>`_.
Which fixed the change of prefix_extractor from raw-pointer to smart-pointer

Version 0.1
-----------

Expand Down
4 changes: 1 addition & 3 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
29 changes: 14 additions & 15 deletions rocksdb/_rocksdb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
<void*>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(
<slice_transform.SliceTransform*>
new slice_transform.SliceTransformWrapper(
bytes_to_string(ob.name()),
<void*>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 <slice_transform.SliceTransform*> 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 = <slice_transform.SliceTransformWrapper*> self.transfomer.get()
ptr.set_info_log(info_log)


cdef Slice slice_transform_callback(
Expand Down
2 changes: 1 addition & 1 deletion rocksdb/options.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 098f957

Please sign in to comment.