stephan-hof / pyrocksdb

Python bindings for RocksDB
BSD 3-Clause "New" or "Revised" License
150 stars 169 forks source link

TypeError: Can't instantiate abstract class StaticPrefix #30

Closed plagtag closed 9 years ago

plagtag commented 9 years ago

Hey Stephan,

i tried out pyrocksdb and i appreciate very much your work!

I have an issue with the prefix scan:

In [1]: import rocksdb

In [2]: class StaticPrefix(rocksdb.interfaces.SliceTransform):
   ...:         def name(self):
   ...:                 return b'static'
   ...:     

In [3]:     def transform(self, src):
   ...:             return (0, 5)
   ...: 

In [4]:     def in_domain(self, src):
   ...:             return len(src) >= 5
   ...: 

In [5]:     def in_range(self, dst):
   ...:             return len(dst) == 5
   ...: 

In [6]: 

In [6]: opts = rocksdb.Options()

In [7]: opts.create_if_missing=True

In [8]: opts.prefix_extractor = StaticPrefix()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-8-9fbe2376d9cd> in <module>()
----> 1 opts.prefix_extractor = StaticPrefix()

TypeError: Can't instantiate abstract class StaticPrefix with abstract methods in_domain, in_range, transform```

am i doing something wrong?
plagtag commented 9 years ago

Ah, found the issue. Sorry for opening an issue: """The abstractmethod() only affects subclasses derived using regular inheritance; “virtual subclasses” registered with the ABC’s register() method are not affected.""" Its not working with ipython ...

https://stackoverflow.com/questions/8086826/cant-instantiate-abstract-class-with-abstract-methods-on-class-that-shouldn#