In case somebody was interested in this or even possibly helping out
(any python pros here?),
I'm creating python bindings to the Hypertable using Boost.Python.
It's far from perfect and stable/ready yet but the sneak-peek preview is
at : http://github.com/mateuszb/hypertable/tree/master/contrib/cc/PythonBinding/test.py
It supports read operations only at this stage.
Note well that after compilation (you need Python development
packages) you need to
rename libht.so to ht.so (sorry, no automation at this stage)
Later on, the example is self-explanatory
import ht
# create client
client = ht.Client("ht", "/opt/hypertable/0.9.0.7/conf/hypertable.cfg")
# open the table
table = client.open_table("METADATA")
# create scan specification
scan_spec = ht.ScanSpec()
scan_spec.start_row = "\x00"
scan_spec.end_row = "\xff\xff"
scan_spec.start_row_inclusive = True
scan_spec.end_row_inclusive = True
scan_spec.max_versions = 1
# initialize the scanner with it
scanner = table.create_scanner(scan_spec)
# create cell holding consecutive values from the scanner
cell = ht.Cell()
# scan it!
while scanner.next(cell):
# note that instead of cell.value and cell.value_len fields
# you get single cell.value() function returning the value from the cell
print "%s:%s %s" % (cell.row_key, cell.column_family, cell.value())
Mateusz
I had no time to try your code, but python bindings are definitely
something that I will need soon. It would be interesting to know if
something is being done for the Thrift implementation previuosly
discussed on the user list [1] [2].
Paolo
.. [1] http://groups.google.com/group/hypertable-user/browse_thread/thread/b3425327092568a6
.. [2] http://groups.google.com/group/hypertable-user/browse_thread/thread/431f541b146f31e5/fec70741c9b27f9d
You'd have to run cmake with -DBUILD_SHARED_LIBS=ON
and then rename libht.so to ht.so . Sorry that this is not yet automated.
Also, I'm going to push a write support in the next 12 hours,
so you will be able to insert data to hypertable from python.
Mateusz
> Configure claims to detect Boost just fine, and Hypertable without the
> Python bindings compiles and links without problems:
>
> -- Looking for required boost libraries...
> -- Boost include dir: /usr/local/include/boost-1_35
> -- Boost thread lib: /usr/local/lib/libboost_thread-gcc41-mt.so
> -- Boost program options lib: /usr/local/lib/libboost_program_options-
> gcc41-mt.so
> -- Boost iostreams lib: /usr/local/lib/libboost_iostreams-gcc41-mt.so
> -- Boost lib dir: /usr/local/lib
> -- Boost version: 1_35
>
> The relevant libraries are located like this:
>
> /usr/local/lib/libboost_python-gcc41-mt-1_35.so
> /usr/local/lib/libboost_python-gcc41-mt-1_35.so.1.35.0
> /usr/local/lib/libboost_python-gcc41-mt.so
>
Could you please rename the library inside the
contrib/cc/PythonBindings/CMakeLists.txt
to the appropriate name of your boost python library?
I didn't have time to focus on it yet.
>> Also, I'm going to push a write support in the next 12 hours,
>> so you will be able to insert data to hypertable from python.
>>
it's live now under
git://github.com/mateuszb/hypertable.git
Mateusz
Thanks a lot for the patch !
> Next, I have yet another compile need that I'm not sure how to do... I
> want to compile the bindings against a custom python (2.5.x) at a
> custom /opt location, and not the default CentOS python (2.4.3). What
> is the best way to work around this? Modify some compile library path
> setting? I tried some of the swtiches I found in cmake files (-
> DPYTHON_LIBS_FOUND and -DPYTHON_INCLUDE_PATH), but they don't seem to
> make much difference. The main locator seems to be main CMakeLists.txt
> line 86: find_package(PythonLibs)
I think there's also find_package for python interpreter or something like this,
but I am not a CMake expert...
>
> Is there some general library path search path variable that can be
> set for the location mechanisms?
There certainly is one but I don't know the name and how to set
it with CMake. As I said, I don't know CMake good enough yet
as I just started using it.
Mateusz