0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
SerializedCells.cc
Go to the documentation of this file.
1 
19 #include "Common/Compat.h"
20 
21 #include "../ThriftBroker/SerializedCellsReader.h"
22 #include "../ThriftBroker/SerializedCellsWriter.h"
23 
24 #include <boost/python.hpp>
25 
26 using namespace Hypertable;
27 using namespace boost::python;
28 
29 typedef bool (SerializedCellsWriter::*addfn)(const char *row,
30  const char *column_family, const char *column_qualifier,
31  int64_t timestamp, const char *value, int32_t value_length,
32  int cell_flag);
33 typedef const char *(SerializedCellsWriter::*getfn)();
34 typedef int32_t (SerializedCellsWriter::*getlenfn)();
35 
38 
39 static PyObject *convert(const SerializedCellsWriter &scw) {
40  boost::python::object obj(handle<>(PyBuffer_FromMemory(
41  (void *)scw.get_buffer(), scw.get_buffer_length())));
42  return boost::python::incref(obj.ptr());
43 }
44 
45 BOOST_PYTHON_MODULE(libHyperPython)
46 {
47 
48  class_<Cell>("Cell")
49  .def("sanity_check", &Cell::sanity_check)
50  .def_readwrite("row", &Cell::row_key)
51  .def_readwrite("column_family", &Cell::column_family)
52  .def_readwrite("column_qualifier", &Cell::column_qualifier)
53  .def_readwrite("timestamp", &Cell::timestamp)
54  .def_readwrite("revision", &Cell::revision)
55  .def_readwrite("value", &Cell::value)
56  .def_readwrite("flag", &Cell::flag)
57  .def(self_ns::str(self_ns::self))
58  ;
59 
60  class_<SerializedCellsReader>("SerializedCellsReader",
61  init<const char *, uint32_t>())
62  .def("has_next", &SerializedCellsReader::next)
63  .def("get_cell", &SerializedCellsReader::get_cell,
64  return_value_policy<return_by_value>())
65  .def("row", &SerializedCellsReader::row,
66  return_value_policy<return_by_value>())
67  .def("column_family", &SerializedCellsReader::column_family,
68  return_value_policy<return_by_value>())
69  .def("column_qualifier", &SerializedCellsReader::column_qualifier,
70  return_value_policy<return_by_value>())
71  .def("value", &SerializedCellsReader::value_str,
72  return_value_policy<return_by_value>())
73  .def("value_len", &SerializedCellsReader::value_len)
74  .def("value_str", &SerializedCellsReader::value_str,
75  return_value_policy<return_by_value>())
76  .def("timestamp", &SerializedCellsReader::timestamp)
77  .def("cell_flag", &SerializedCellsReader::cell_flag)
78  .def("flush", &SerializedCellsReader::flush)
79  .def("eos", &SerializedCellsReader::eos)
80  ;
81 
82  class_<SerializedCellsWriter, boost::noncopyable>("SerializedCellsWriter",
83  init<int32_t, bool>())
84  .def("add", afn)
85  .def("finalize", &SerializedCellsWriter::finalize)
86  .def("empty", &SerializedCellsWriter::empty)
87  .def("clear", &SerializedCellsWriter::clear)
88  .def("__len__", lenfn)
89  .def("get", &convert)
90  ;
91 }
const char *(SerializedCellsWriter::* getfn)()
static getlenfn lenfn
Filesystem::Flags convert(std::string str)
Converts string mnemonic to corresponding Filesystem::Flags value.
Definition: Filesystem.cc:180
Po::typed_value< String > * str(String *v=0)
Definition: Properties.h:166
const char * column_qualifier
Definition: Cell.h:68
BOOST_PYTHON_MODULE(libHyperPython)
uint64_t revision
Definition: Cell.h:70
Compatibility Macros for C/C++.
const char * row_key
Definition: Cell.h:66
bool(SerializedCellsWriter::* addfn)(const char *row, const char *column_family, const char *column_qualifier, int64_t timestamp, const char *value, int32_t value_length, int cell_flag)
int32_t(SerializedCellsWriter::* getlenfn)()
Hypertable definitions
void sanity_check() const
Definition: Cell.h:43
const char * column_family
Definition: Cell.h:67
static addfn afn
uint8_t flag
Definition: Cell.h:73
const uint8_t * value
Definition: Cell.h:71
int64_t timestamp
Definition: Cell.h:69