mirror of
https://github.com/apache/arrow.git
synced 2026-10-28 16:47:19 +08:00
introduce plasma namespace
This commit is contained in:
1 parent
a4a962868d
commit
777e9c79ef
16 files changed
+67
-8
No files matched your search
@@ -114,6 +114,9 @@ if (PLASMA_PYTHON)
|
||||
|
||||
set_source_files_properties(plasma/plasma.pyx PROPERTIES CYTHON_IS_CXX 1)
|
||||
|
||||
# for Cython
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable")
|
||||
|
||||
cython_add_module(plasma
|
||||
plasma_pyx
|
||||
plasma_output
|
||||
|
||||
@@ -51,6 +51,8 @@
|
||||
|
||||
#define XXH64_DEFAULT_SEED 0
|
||||
|
||||
namespace plasma {
|
||||
|
||||
// Number of threads used for memcopy and hash computations.
|
||||
constexpr int64_t kThreadPoolSize = 8;
|
||||
constexpr int64_t kBytesInMB = 1 << 20;
|
||||
@@ -577,3 +579,5 @@ Status PlasmaClient::Wait(int64_t num_object_requests, ObjectRequest* object_req
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
} // namespace plasma
|
||||
@@ -29,6 +29,8 @@
|
||||
|
||||
using arrow::Status;
|
||||
|
||||
namespace plasma {
|
||||
|
||||
#define PLASMA_DEFAULT_RELEASE_DELAY 64
|
||||
|
||||
// Use 100MB as an overestimate of the L3 cache size.
|
||||
@@ -351,4 +353,6 @@ class ARROW_EXPORT PlasmaClient {
|
||||
int64_t store_capacity_;
|
||||
};
|
||||
|
||||
} // namespace plasma
|
||||
|
||||
#endif // PLASMA_CLIENT_H
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "format/plasma_generated.h"
|
||||
|
||||
namespace plasma {
|
||||
|
||||
using arrow::Status;
|
||||
|
||||
UniqueID UniqueID::from_random() {
|
||||
@@ -81,3 +83,5 @@ Status plasma_error_status(int plasma_error) {
|
||||
}
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
} // namespace plasma
|
||||
@@ -29,6 +29,8 @@
|
||||
#include "arrow/status.h"
|
||||
#include "arrow/util/logging.h"
|
||||
|
||||
namespace plasma {
|
||||
|
||||
constexpr int64_t kUniqueIDSize = 20;
|
||||
|
||||
class UniqueID {
|
||||
@@ -60,4 +62,6 @@ typedef UniqueID ObjectID;
|
||||
|
||||
arrow::Status plasma_error_status(int plasma_error);
|
||||
|
||||
} // namespace plasma
|
||||
|
||||
#endif // PLASMA_COMMON_H
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
namespace plasma {
|
||||
|
||||
void EventLoop::file_event_callback(
|
||||
aeEventLoop* loop, int fd, void* context, int events) {
|
||||
FileCallback* callback = reinterpret_cast<FileCallback*>(context);
|
||||
@@ -79,3 +81,5 @@ int EventLoop::remove_timer(int64_t timer_id) {
|
||||
timer_callbacks_.erase(timer_id);
|
||||
return err;
|
||||
}
|
||||
|
||||
} // namespace plasma
|
||||
@@ -26,6 +26,8 @@ extern "C" {
|
||||
#include "ae/ae.h"
|
||||
}
|
||||
|
||||
namespace plasma {
|
||||
|
||||
/// Constant specifying that the timer is done and it will be removed.
|
||||
constexpr int kEventLoopTimerDone = AE_NOMORE;
|
||||
|
||||
@@ -96,4 +98,6 @@ class EventLoop {
|
||||
std::unordered_map<int64_t, std::unique_ptr<TimerCallback>> timer_callbacks_;
|
||||
};
|
||||
|
||||
} // namespace plasma
|
||||
|
||||
#endif // PLASMA_EVENTS
|
||||
@@ -19,6 +19,8 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace plasma {
|
||||
|
||||
void LRUCache::add(const ObjectID& key, int64_t size) {
|
||||
auto it = item_map_.find(key);
|
||||
ARROW_CHECK(it == item_map_.end());
|
||||
@@ -105,3 +107,5 @@ void EvictionPolicy::end_object_access(
|
||||
/* Add the object to the LRU cache.*/
|
||||
cache_.add(object_id, entry->info.data_size + entry->info.metadata_size);
|
||||
}
|
||||
|
||||
} // namespace plasma
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "plasma/common.h"
|
||||
#include "plasma/plasma.h"
|
||||
|
||||
namespace plasma {
|
||||
|
||||
// ==== The eviction policy ====
|
||||
//
|
||||
// This file contains declaration for all functions and data structures that
|
||||
@@ -131,4 +133,6 @@ class EvictionPolicy {
|
||||
LRUCache cache_;
|
||||
};
|
||||
|
||||
} // namespace plasma
|
||||
|
||||
#endif // PLASMA_EVICTION_POLICY_H
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "plasma/common.h"
|
||||
#include "plasma/protocol.h"
|
||||
|
||||
namespace plasma {
|
||||
|
||||
int warn_if_sigpipe(int status, int client_sock) {
|
||||
if (status >= 0) { return 0; }
|
||||
if (errno == EPIPE || errno == EBADF || errno == ECONNRESET) {
|
||||
@@ -62,3 +64,5 @@ ObjectTableEntry* get_object_table_entry(
|
||||
if (it == store_info->objects.end()) { return NULL; }
|
||||
return it->second.get();
|
||||
}
|
||||
|
||||
} // namespace plasma
|
||||
@@ -35,6 +35,8 @@
|
||||
#include "format/common_generated.h"
|
||||
#include "plasma/common.h"
|
||||
|
||||
namespace plasma {
|
||||
|
||||
#define HANDLE_SIGPIPE(s, fd_) \
|
||||
do { \
|
||||
Status _s = (s); \
|
||||
@@ -194,4 +196,6 @@ int warn_if_sigpipe(int status, int client_sock);
|
||||
|
||||
uint8_t* create_object_info_buffer(ObjectInfoT* object_info);
|
||||
|
||||
} // namespace plasma
|
||||
|
||||
#endif // PLASMA_PLASMA_H
|
||||
@@ -38,7 +38,7 @@ cdef class FixedSizeBufferOutputStream(NativeFile):
|
||||
|
||||
cdef extern from "plasma/common.h" nogil:
|
||||
|
||||
cdef cppclass CUniqueID" UniqueID":
|
||||
cdef cppclass CUniqueID" plasma::UniqueID":
|
||||
|
||||
@staticmethod
|
||||
CUniqueID from_binary(const c_string& binary)
|
||||
@@ -48,11 +48,11 @@ cdef extern from "plasma/common.h" nogil:
|
||||
c_string hex()
|
||||
|
||||
cdef extern from "plasma/plasma.h":
|
||||
cdef int64_t kDigestSize
|
||||
cdef int64_t kDigestSize" plasma::kDigestSize"
|
||||
|
||||
cdef extern from "plasma/client.h" nogil:
|
||||
|
||||
cdef cppclass CPlasmaClient" PlasmaClient":
|
||||
cdef cppclass CPlasmaClient" plasma::PlasmaClient":
|
||||
|
||||
CPlasmaClient()
|
||||
|
||||
@@ -81,7 +81,7 @@ cdef extern from "plasma/client.h" nogil:
|
||||
|
||||
cdef extern from "plasma/client.h" nogil:
|
||||
|
||||
cdef struct CObjectBuffer" ObjectBuffer":
|
||||
cdef struct CObjectBuffer" plasma::ObjectBuffer":
|
||||
int64_t data_size
|
||||
uint8_t* data
|
||||
int64_t metadata_size
|
||||
@@ -295,7 +295,7 @@ cdef class PlasmaClient:
|
||||
Args:
|
||||
num_bytes (int): The number of bytes to attempt to recover.
|
||||
"""
|
||||
cdef int64_t num_bytes_evicted
|
||||
cdef int64_t num_bytes_evicted = -1
|
||||
check_status(self.client.get().Evict(num_bytes, num_bytes_evicted))
|
||||
return num_bytes_evicted
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "plasma/common.h"
|
||||
#include "plasma/io.h"
|
||||
|
||||
namespace plasma {
|
||||
|
||||
using flatbuffers::uoffset_t;
|
||||
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>>
|
||||
@@ -500,3 +502,5 @@ Status ReadDataReply(
|
||||
*metadata_size = (int64_t)message->metadata_size();
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
} // namespace plasma
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "format/plasma_generated.h"
|
||||
#include "plasma/plasma.h"
|
||||
|
||||
namespace plasma {
|
||||
|
||||
using arrow::Status;
|
||||
|
||||
/* Plasma receive message. */
|
||||
@@ -167,4 +169,6 @@ Status SendDataReply(
|
||||
Status ReadDataReply(
|
||||
uint8_t* data, ObjectID* object_id, int64_t* object_size, int64_t* metadata_size);
|
||||
|
||||
} // namespace plasma
|
||||
|
||||
#endif /* PLASMA_PROTOCOL */
|
||||
@@ -55,6 +55,8 @@
|
||||
#include "plasma/io.h"
|
||||
#include "plasma/malloc.h"
|
||||
|
||||
namespace plasma {
|
||||
|
||||
extern "C" {
|
||||
void* dlmalloc(size_t bytes);
|
||||
void* dlmemalign(size_t alignment, size_t bytes);
|
||||
@@ -625,8 +627,10 @@ void start_server(char* socket_name, int64_t system_memory) {
|
||||
loop.run();
|
||||
}
|
||||
|
||||
} // namespace plasma
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
signal(SIGTERM, signal_handler);
|
||||
signal(SIGTERM, plasma::signal_handler);
|
||||
char* socket_name = NULL;
|
||||
int64_t system_memory = -1;
|
||||
int c;
|
||||
@@ -677,7 +681,7 @@ int main(int argc, char* argv[]) {
|
||||
#endif
|
||||
// Make it so dlmalloc fails if we try to request more memory than is
|
||||
// available.
|
||||
dlmalloc_set_footprint_limit((size_t)system_memory);
|
||||
plasma::dlmalloc_set_footprint_limit((size_t)system_memory);
|
||||
ARROW_LOG(DEBUG) << "starting server listening on " << socket_name;
|
||||
start_server(socket_name, system_memory);
|
||||
plasma::start_server(socket_name, system_memory);
|
||||
}
|
||||
@@ -27,6 +27,8 @@
|
||||
#include "plasma/plasma.h"
|
||||
#include "plasma/protocol.h"
|
||||
|
||||
namespace plasma {
|
||||
|
||||
struct GetRequest;
|
||||
|
||||
struct NotificationQueue {
|
||||
@@ -166,4 +168,6 @@ class PlasmaStore {
|
||||
std::unordered_map<int, NotificationQueue> pending_notifications_;
|
||||
};
|
||||
|
||||
} // namespace plasma
|
||||
|
||||
#endif // PLASMA_STORE_H
|
||||
Reference in new issue
Block a user