Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
e9f9bb4
Initial commit of the plasma store. Contributors: Philipp Moritz, Rob…
pcmoritz Jun 1, 2017
9ef7f41
make the plasma store compile
pcmoritz Jun 1, 2017
51ab963
fix compiler warnings
pcmoritz Jun 2, 2017
04c2edb
add missing file
pcmoritz Jun 2, 2017
e649c2a
fix compilation
pcmoritz Jun 2, 2017
cb3f3a3
compile C files with CMAKE_C_FLAGS
pcmoritz Jun 2, 2017
99537c9
fix compiler warnings
pcmoritz Jun 2, 2017
6372913
fix malloc?
pcmoritz Jun 3, 2017
c93034f
add Apache 2.0 headers
pcmoritz Jun 3, 2017
6cee1e2
fix
pcmoritz Jun 3, 2017
99420e8
add rat exceptions
pcmoritz Jun 3, 2017
79ea0ca
fix clang-tidy
pcmoritz Jun 3, 2017
7f7e7e7
more linting
pcmoritz Jun 3, 2017
b1e0335
fix linting
pcmoritz Jun 3, 2017
74ecb19
don't link against Python libraries
pcmoritz Jun 8, 2017
e11b0e8
fix pthread
pcmoritz Jun 8, 2017
f936adb
build plasma python client only if python is available
pcmoritz Jun 11, 2017
d6e60d2
do not compile plasma on windows
pcmoritz Jun 12, 2017
f40f85b
add clang-format exceptions
pcmoritz Jun 12, 2017
ed680f9
reformat the code
pcmoritz Jun 12, 2017
b9a5a06
fix includes
pcmoritz Jun 13, 2017
0b8593d
Port change from Ray. Change listen backlog size from 5 to 128.
robertnishihara Jun 13, 2017
9e5ae0e
port serialization tests to gtest
pcmoritz Jun 15, 2017
9c703c2
integrate client tests
pcmoritz Jun 15, 2017
217ff3d
add valgrind heuristic
pcmoritz Jun 15, 2017
7003a4a
fix valgrind test by setting working directory
pcmoritz Jun 15, 2017
65ac743
remove offending c++ flag from c flags
pcmoritz Jun 19, 2017
8daea69
fix includes according to google styleguide
pcmoritz Jun 19, 2017
0fdd4cd
link libarrow.a and remove hardcoded optimization flags
pcmoritz Jun 19, 2017
77d9822
put all the object code into a common library
pcmoritz Jun 19, 2017
30bd68b
remove plain pointer in plasma client, part I
pcmoritz Jun 19, 2017
627b7c7
fix python extension name
pcmoritz Jun 19, 2017
ca80e9a
remove plain pointer in plasma client, part II
pcmoritz Jun 19, 2017
7b08fd2
replace ObjectID pass by value with pass by const reference and fix c…
pcmoritz Jun 19, 2017
27f9c9e
fix formatting
pcmoritz Jun 20, 2017
b21f081
fix remaining comments about client
pcmoritz Jun 20, 2017
6432d3f
fix formatting
pcmoritz Jun 20, 2017
e7badc4
fix python extension
pcmoritz Jun 20, 2017
214c426
fix eviction policy
pcmoritz Jun 20, 2017
b36c6aa
fix fling.cc
pcmoritz Jun 20, 2017
a137e78
more fixes
pcmoritz Jun 20, 2017
5370ae0
fix plasma protocol
pcmoritz Jun 20, 2017
8143792
fix linting
pcmoritz Jun 20, 2017
00f17f2
fix licenses
pcmoritz Jun 20, 2017
4497e33
fix tests
pcmoritz Jun 20, 2017
61d421b
fix formatting
pcmoritz Jun 20, 2017
85aa171
fix mac tests
pcmoritz Jun 20, 2017
4c474d7
run plasma_store from the right directory
pcmoritz Jun 21, 2017
80f9df4
make format
pcmoritz Jun 21, 2017
0f321e1
try to fix tests
pcmoritz Jun 21, 2017
16d1f71
fix test hanging
pcmoritz Jun 21, 2017
d67160c
build dlmalloc with -O3
pcmoritz Jun 21, 2017
c100a45
fixes
pcmoritz Jun 21, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,99 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

--------------------------------------------------------------------------------

src/plasma/fling.cc and src/plasma/fling.h: Apache 2.0

Copyright 2013 Sharvil Nanavati

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

--------------------------------------------------------------------------------

src/plasma/thirdparty/ae: Modified / 3-Clause BSD

Copyright (c) 2006-2010, Salvatore Sanfilippo <antirez at gmail dot com>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Redis nor the names of its contributors may be used
to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

--------------------------------------------------------------------------------

src/plasma/thirdparty/dlmalloc.c: CC0

This is a version (aka dlmalloc) of malloc/free/realloc written by
Doug Lea and released to the public domain, as explained at
http://creativecommons.org/publicdomain/zero/1.0/ Send questions,
comments, complaints, performance data, etc to dl@cs.oswego.edu

--------------------------------------------------------------------------------

src/plasma/thirdparty/xxhash: BSD 2-Clause License

xxHash - Fast Hash algorithm
Copyright (C) 2012-2016, Yann Collet

BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php)

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

You can contact the author at :
- xxHash homepage: http://www.xxhash.com
- xxHash source repository : https://github.com/Cyan4973/xxHash

--------------------------------------------------------------------------------
5 changes: 2 additions & 3 deletions ci/travis_before_script_cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ source $TRAVIS_BUILD_DIR/ci/travis_env_common.sh
if [ $only_library_mode == "no" ]; then
# C++ toolchain
export CPP_TOOLCHAIN=$TRAVIS_BUILD_DIR/cpp-toolchain
export FLATBUFFERS_HOME=$CPP_TOOLCHAIN
export RAPIDJSON_HOME=$CPP_TOOLCHAIN

# Set up C++ toolchain from conda-forge packages for faster builds
source $TRAVIS_BUILD_DIR/ci/travis_install_conda.sh
conda create -y -q -p $CPP_TOOLCHAIN python=2.7 flatbuffers rapidjson
conda create -y -q -p $CPP_TOOLCHAIN python=2.7 rapidjson
fi

if [ $TRAVIS_OS_NAME == "osx" ]; then
Expand Down Expand Up @@ -73,7 +72,7 @@ else
$ARROW_CPP_DIR
fi

make -j4
make VERBOSE=1 -j4
make install

popd
1 change: 1 addition & 0 deletions ci/travis_script_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function build_arrow_libraries() {

cmake -DARROW_BUILD_TESTS=off \
-DARROW_PYTHON=on \
-DPLASMA_PYTHON=on \
-DCMAKE_INSTALL_PREFIX=$2 \
$CPP_DIR

Expand Down
20 changes: 17 additions & 3 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ include(san-config)

# For any C code, use the same flags.
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
# Remove --std=c++11 to avoid errors from C compilers
string(REPLACE "-std=c++11" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})

# Code coverage
if ("${ARROW_GENERATE_COVERAGE}")
Expand Down Expand Up @@ -362,7 +364,7 @@ function(ADD_ARROW_TEST REL_TEST_NAME)
APPEND_STRING PROPERTY
COMPILE_FLAGS " -DARROW_VALGRIND")
add_test(${TEST_NAME}
valgrind --tool=memcheck --leak-check=full --error-exitcode=1 ${TEST_PATH})
bash -c "cd ${EXECUTABLE_OUTPUT_PATH}; valgrind --tool=memcheck --leak-check=full --leak-check-heuristics=stdstring --error-exitcode=1 ${TEST_PATH}")
elseif(MSVC)
add_test(${TEST_NAME} ${TEST_PATH})
else()
Expand Down Expand Up @@ -694,6 +696,7 @@ if (ARROW_IPC)
ExternalProject_Add(flatbuffers_ep
URL "https://github.com/google/flatbuffers/archive/v${FLATBUFFERS_VERSION}.tar.gz"
CMAKE_ARGS
"-DCMAKE_CXX_FLAGS=-fPIC"
"-DCMAKE_INSTALL_PREFIX:PATH=${FLATBUFFERS_PREFIX}"
"-DFLATBUFFERS_BUILD_TESTS=OFF")

Expand Down Expand Up @@ -861,7 +864,12 @@ if (UNIX)

FOREACH(item ${LINT_FILES})
IF(NOT ((item MATCHES "_generated.h") OR
(item MATCHES "pyarrow_api.h")))
(item MATCHES "pyarrow_api.h") OR
(item MATCHES "xxhash.h") OR
(item MATCHES "xxhash.cc") OR
(item MATCHES "config.h") OR
(item MATCHES "zmalloc.h") OR
(item MATCHES "ae.h")))
LIST(APPEND FILTERED_LINT_FILES ${item})
ENDIF()
ENDFOREACH(item ${LINT_FILES})
Expand Down Expand Up @@ -889,7 +897,10 @@ if (${CLANG_FORMAT_FOUND})
sed -e '/windows_compatibility.h/g' |
sed -e '/pyarrow_api.h/g' |
sed -e '/config.h/g' | # python/config.h
sed -e '/platform.h/g'` # python/platform.h
sed -e '/platform.h/g' | # python/platform.h
sed -e '/ae.h/g' |
sed -e '/xxhash.cc/g' |
sed -e '/xxhash.h/g'`
)

# runs clang format and exits with a non-zero exit code if any files need to be reformatted
Expand Down Expand Up @@ -945,6 +956,9 @@ if(FLATBUFFERS_VENDORED)
set(ARROW_DEPENDENCIES ${ARROW_DEPENDENCIES} flatbuffers_ep)
endif()

if(NOT WIN32)
add_subdirectory(src/plasma)
endif()
add_subdirectory(src/arrow)
add_subdirectory(src/arrow/io)
if (ARROW_IPC)
Expand Down
23 changes: 23 additions & 0 deletions cpp/src/arrow/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ enum class StatusCode : char {
IOError = 5,
UnknownError = 9,
NotImplemented = 10,
PlasmaObjectExists = 20,
PlasmaObjectNonexistent = 21,
PlasmaStoreFull = 22
};

class ARROW_EXPORT Status {
Expand Down Expand Up @@ -129,6 +132,18 @@ class ARROW_EXPORT Status {
return Status(StatusCode::IOError, msg, -1);
}

static Status PlasmaObjectExists(const std::string& msg) {
return Status(StatusCode::PlasmaObjectExists, msg, -1);
}

static Status PlasmaObjectNonexistent(const std::string& msg) {
return Status(StatusCode::PlasmaObjectNonexistent, msg, -1);
}

static Status PlasmaStoreFull(const std::string& msg) {
return Status(StatusCode::PlasmaStoreFull, msg, -1);
}

// Returns true iff the status indicates success.
bool ok() const { return (state_ == NULL); }

Expand All @@ -139,6 +154,14 @@ class ARROW_EXPORT Status {
bool IsTypeError() const { return code() == StatusCode::TypeError; }
bool IsUnknownError() const { return code() == StatusCode::UnknownError; }
bool IsNotImplemented() const { return code() == StatusCode::NotImplemented; }
// An object with this object ID already exists in the plasma store.
bool IsPlasmaObjectExists() const { return code() == StatusCode::PlasmaObjectExists; }
// An object was requested that doesn't exist in the plasma store.
bool IsPlasmaObjectNonexistent() const {
return code() == StatusCode::PlasmaObjectNonexistent;
}
// An object is too large to fit into the plasma store.
bool IsPlasmaStoreFull() const { return code() == StatusCode::PlasmaStoreFull; }

// Return a string representation of this status suitable for printing.
// Returns the string "OK" for success.
Expand Down
8 changes: 4 additions & 4 deletions cpp/src/arrow/util/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace arrow {

// Log levels. LOG ignores them, so their values are abitrary.

#define ARROW_DEBUG (-1)
#define ARROW_INFO 0
#define ARROW_WARNING 1
#define ARROW_ERROR 2
Expand All @@ -38,10 +39,9 @@ namespace arrow {
#define ARROW_LOG_INTERNAL(level) ::arrow::internal::CerrLog(level)
#define ARROW_LOG(level) ARROW_LOG_INTERNAL(ARROW_##level)

#define ARROW_CHECK(condition) \
(condition) ? 0 \
: ::arrow::internal::FatalLog(ARROW_FATAL) \
<< __FILE__ << __LINE__ << " Check failed: " #condition " "
#define ARROW_CHECK(condition) \
(condition) ? 0 : ::arrow::internal::FatalLog(ARROW_FATAL) \
<< __FILE__ << __LINE__ << " Check failed: " #condition " "

#ifdef NDEBUG
#define ARROW_DFATAL ARROW_WARNING
Expand Down
112 changes: 112 additions & 0 deletions cpp/src/plasma/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

cmake_minimum_required(VERSION 2.8)

project(plasma)

find_package(PythonLibsNew REQUIRED)
find_package(Threads)

option(PLASMA_PYTHON
"Build the Plasma Python extensions"
OFF)

if(APPLE)
SET(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
endif(APPLE)

include_directories(SYSTEM ${PYTHON_INCLUDE_DIRS})
include_directories("${FLATBUFFERS_INCLUDE_DIR}" "${CMAKE_CURRENT_LIST_DIR}/" "${CMAKE_CURRENT_LIST_DIR}/thirdparty/" "${CMAKE_CURRENT_LIST_DIR}/../")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_XOPEN_SOURCE=500 -D_POSIX_C_SOURCE=200809L")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-conversion")

# Compile flatbuffers

set(PLASMA_FBS_SRC "${CMAKE_CURRENT_LIST_DIR}/format/plasma.fbs" "${CMAKE_CURRENT_LIST_DIR}/format/common.fbs")
set(OUTPUT_DIR ${CMAKE_CURRENT_LIST_DIR}/format/)

set(PLASMA_FBS_OUTPUT_FILES
"${OUTPUT_DIR}/common_generated.h"
"${OUTPUT_DIR}/plasma_generated.h")

add_custom_command(
OUTPUT ${PLASMA_FBS_OUTPUT_FILES}
# The --gen-object-api flag generates a C++ class MessageT for each
# flatbuffers message Message, which can be used to store deserialized
# messages in data structures. This is currently used for ObjectInfo for
# example.
COMMAND ${FLATBUFFERS_COMPILER} -c -o ${OUTPUT_DIR} ${PLASMA_FBS_SRC} --gen-object-api
DEPENDS ${PLASMA_FBS_SRC}
COMMENT "Running flatc compiler on ${PLASMA_FBS_SRC}"
VERBATIM)

add_custom_target(gen_plasma_fbs DEPENDS ${PLASMA_FBS_OUTPUT_FILES})

add_dependencies(gen_plasma_fbs flatbuffers_ep)

if(UNIX AND NOT APPLE)
link_libraries(rt)
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")

set_source_files_properties(thirdparty/dlmalloc.c PROPERTIES COMPILE_FLAGS -Wno-all)
set_source_files_properties(extension.cc PROPERTIES COMPILE_FLAGS -Wno-strict-aliasing)

set(PLASMA_SRCS
client.cc
common.cc
eviction_policy.cc
events.cc
fling.cc
io.cc
malloc.cc
plasma.cc
protocol.cc
thirdparty/ae/ae.c
thirdparty/xxhash.cc)

ADD_ARROW_LIB(plasma
SOURCES ${PLASMA_SRCS}
DEPENDENCIES gen_plasma_fbs
SHARED_LINK_LIBS ${FLATBUFFERS_STATIC_LIB} ${CMAKE_THREAD_LIBS_INIT} arrow_static
STATIC_LINK_LIBS ${FLATBUFFERS_STATIC_LIB} ${CMAKE_THREAD_LIBS_INIT} arrow_static)

# The optimization flag -O3 is suggested by dlmalloc.c, which is #included in
# malloc.cc; we set it here regardless of whether we do a debug or release build.
set_source_files_properties(malloc.cc PROPERTIES COMPILE_FLAGS "-Wno-error=conversion -O3")

add_executable(plasma_store store.cc)
target_link_libraries(plasma_store plasma_static)

ADD_ARROW_TEST(test/serialization_tests)
ARROW_TEST_LINK_LIBRARIES(test/serialization_tests plasma_static)
ADD_ARROW_TEST(test/client_tests)
ARROW_TEST_LINK_LIBRARIES(test/client_tests plasma_static)

if(PLASMA_PYTHON)
add_library(plasma_extension SHARED extension.cc)

if(APPLE)
target_link_libraries(plasma_extension plasma_static "-undefined dynamic_lookup")
else(APPLE)
target_link_libraries(plasma_extension plasma_static -Wl,--whole-archive ${FLATBUFFERS_STATIC_LIB} -Wl,--no-whole-archive)
endif(APPLE)
endif()
Loading