initial plasma cython client commit

This commit is contained in:
Philipp Moritz committed 2017-07-19 10:06:32 -07:00
1 parent 2c5b412c28
commit 9044a01627
4 files changed
+94 -1

No files matched your search

+2
View File
@@ -56,6 +56,8 @@ constexpr int64_t kThreadPoolSize = 8;
constexpr int64_t kBytesInMB = 1 << 20;
static std::vector<std::thread> threadpool_(kThreadPoolSize);
PlasmaClient::PlasmaClient() {}
// If the file descriptor fd has been mmapped in this client process before,
// return the pointer that was returned by mmap, otherwise mmap it and store the
// pointer in a hash table.
+4 -1
View File
@@ -24,6 +24,7 @@
#include <deque>
#include <string>
#include "arrow/util/visibility.h"
#include "plasma/plasma.h"
using arrow::Status;
@@ -77,8 +78,10 @@ struct ObjectInUseEntry {
bool is_sealed;
};
class PlasmaClient {
class ARROW_EXPORT PlasmaClient {
public:
PlasmaClient();
/// Connect to the local plasma store and plasma manager. Return
/// the resulting connection.
///
+76
View File
@@ -0,0 +1,76 @@
# cython: profile=False
# distutils: language = c++
# cython: embedsignature = True
from libcpp cimport bool as c_bool, nullptr
from libcpp.memory cimport shared_ptr, unique_ptr, make_shared
from libcpp.string cimport string as c_string
from libc.stdint cimport int64_t, uint8_t
cdef extern from "arrow/api.h" namespace "arrow" nogil:
# We can later add more of the common status factory methods as needed
cdef CStatus CStatus_OK "Status::OK"()
cdef cppclass CStatus "arrow::Status":
CStatus()
c_string ToString()
c_bool ok()
c_bool IsIOError()
c_bool IsOutOfMemory()
c_bool IsInvalid()
c_bool IsKeyError()
c_bool IsNotImplemented()
c_bool IsTypeError()
cdef extern from "plasma/common.h" nogil:
cdef cppclass CUniqueID" UniqueID":
@staticmethod
CUniqueID from_binary(const c_string& binary)
c_string hex()
cdef extern from "plasma/client.h" nogil:
cdef cppclass CPlasmaClient" PlasmaClient":
CPlasmaClient()
CStatus Connect(const c_string& store_socket_name, const c_string& manager_socket_name, int release_delay)
CStatus Create(const CUniqueID& object_id, int64_t data_size, uint8_t* metadata,
int64_t metadata_size, uint8_t** data)
CStatus Disconnect()
cdef class ObjectID:
cdef:
CUniqueID data
def __cinit__(self, object_id):
self.data = CUniqueID.from_binary(object_id)
def __repr__(self):
return "ObjectID(" + self.data.hex().decode() + ")"
cdef class PlasmaClient:
cdef:
shared_ptr[CPlasmaClient] client
def __cinit__(self):
self.client.reset(new CPlasmaClient())
def connect(self, store_socket_name, manager_socket_name, release_delay):
self.client.get().Connect(store_socket_name, manager_socket_name, release_delay)
def create(self, ObjectID object_id, data_size):
cdef uint8_t* data
self.client.get().Create(object_id.data, data_size, NULL, 0, &data)
def disconnect(self):
self.client.get().Disconnect()
+12
View File
@@ -0,0 +1,12 @@
from setuptools import setup, find_packages, Extension
from Cython.Build import cythonize
extensions = [
Extension(
'plasma',
["plasma.pyx"],
language="c++",
extra_link_args=["../../build/debug/libplasma.a", "../../build/debug/libarrow.a"],
extra_compile_args=["-std=c++11", "-I.", "-I..", "-I../../../cpp/build/flatbuffers_ep-prefix/src/flatbuffers_ep-install/include"])]
setup(ext_modules = cythonize(extensions))