Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-11522 libmemcached plugin #6691

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 52 additions & 0 deletions cmake_modules/FindMEMCACHED.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
################################################################################
# HPCC SYSTEMS software Copyright (C) 2014 HPCC Systems.
#
# 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.
################################################################################

# - Try to find the libmemcached library
# Once done this will define
#
# LIBMEMCACHED_FOUND - system has the libmemcached library
# LIBMEMCACHED_INCLUDE_DIR - the libmemcached include directory(s)
# LIBMEMCACHED_LIBRARIES - The libraries needed to use libmemcached

IF (NOT LIBMEMCACHED_FOUND)
IF (WIN32)
SET (libmemcached_lib "libmemcached")
SET (libmemcachedUtil_lib "libmemcachedutil")
ELSE()
SET (libmemcached_lib "memcached")
SET (libmemcachedUtil_lib "memcachedutil")
ENDIF()

FIND_PATH(LIBMEMCACHED_INCLUDE_DIR memcached.hpp PATHS /usr/include /usr/share/include /usr/local/include PATH_SUFFIXES libmemcached)

FIND_LIBRARY (LIBMEMCACHEDCORE_LIBRARY NAMES ${libmemcached_lib} PATHS /usr/lib usr/lib/libmemcached /usr/share /usr/lib64 /usr/local/lib /usr/local/lib64)
FIND_LIBRARY (LIBMEMCACHEDUTIL_LIBRARY NAMES ${libmemcachedUtil_lib} PATHS /usr/lib /usr/share /usr/lib64 /usr/local/lib /usr/local/lib64)

#IF (LIBMEMCACHED_LIBRARY STREQUAL "LIBMEMCACHED_LIBRARY-NOTFOUND")
# SET (LIBMEMCACHEDCORE_LIBRARY "") # Newer versions of libmemcached are header-only, with no associated library.
#ENDIF()

SET (LIBMEMCACHED_LIBRARIES ${LIBMEMCACHEDCORE_LIBRARY} ${LIBMEMCACHEDUTIL_LIBRARY})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(memcached DEFAULT_MSG
LIBMEMCACHED_LIBRARIES
LIBMEMCACHED_INCLUDE_DIR
)

MARK_AS_ADVANCED(LIBMEMCACHED_INCLUDE_DIRS LIBMEMCACHED_LIBRARIES)
ENDIF()

3 changes: 2 additions & 1 deletion cmake_modules/commonSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
option(USE_V8 "Enable V8 JavaScript support" ON)
option(USE_JNI "Enable Java JNI support" ON)
option(USE_RINSIDE "Enable R support" ON)
option(USE_MEMCACHED "Enable Memcached support" ON)

option(USE_OPTIONAL "Automatically disable requested features with missing dependencies" ON)

if ( USE_PYTHON OR USE_V8 OR USE_JNI OR USE_RINSIDE OR USE_SQLITE3 OR USE_MYSQL OR USE_CASSANDRA)
if ( USE_PYTHON OR USE_V8 OR USE_JNI OR USE_RINSIDE OR USE_SQLITE3 OR USE_MYSQL OR USE_CASSANDRA OR USE_MEMCACHED)
set( WITH_PLUGINS ON )
endif()

Expand Down
1 change: 1 addition & 0 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ add_subdirectory (pyembed)
add_subdirectory (javaembed)
add_subdirectory (Rembed)
add_subdirectory (cassandra)
add_subdirectory (memcached)
67 changes: 67 additions & 0 deletions plugins/memcached/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
################################################################################
# HPCC SYSTEMS software Copyright (C) 2014 HPCC Systems.
#
# 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.
################################################################################

# Component: memcached

#####################################################
# Description:
# ------------
# Cmake Input File for memcached
#####################################################

project( memcached )

if (USE_MEMCACHED)
ADD_PLUGIN(memcached PACKAGES MEMCACHED OPTION MAKE_MEMCACHED)
if ( MAKE_MEMCACHED )
set ( SRCS
memcachedplugin.hpp
memcachedplugin.cpp
)

include_directories (
./../../system/include
./../../rtl/eclrtl
./../../rtl/include
./../../common/deftype
./../../common/workunit
./../../system/jlib
${LIBMEMCACHED_INCLUDE_DIR}
)

ADD_DEFINITIONS( -D_USRDLL -DECL_MEMCACHED_EXPORTS)
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")

HPCC_ADD_LIBRARY( memcached SHARED ${SRCS} )
if (${CMAKE_VERSION} VERSION_LESS "2.8.9")
message("WARNING: Cannot set NO_SONAME. shlibdeps will give warnings when package is installed")
else()
set_target_properties( memcached PROPERTIES NO_SONAME 1 )
endif()

install ( TARGETS memcached DESTINATION plugins)

target_link_libraries ( memcached
eclrtl
jlib
workunit
${LIBMEMCACHED_LIBRARIES}
)
endif()
endif()

#Even if not making the memcached plugin, we want to install the header
install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/lib_memcached.ecllib DESTINATION plugins COMPONENT Runtime)
40 changes: 40 additions & 0 deletions plugins/memcached/lib_memcached.ecllib
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*##############################################################################

HPCC SYSTEMS software Copyright (C) 2014 HPCC Systems.

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.
############################################################################## */

export memcached := SERVICE : plugin('memcached')
BOOLEAN SetUnicode(CONST VARSTRING servers, CONST VARSTRING key, CONST UNICODE value, CONST VARSTRING partitionKey = '', UNSIGNED4 expire = 0) : cpp,action,context,entrypoint='MSet';
BOOLEAN SetString(CONST VARSTRING servers, CONST VARSTRING key, CONST STRING value, CONST VARSTRING partitionKey = '', UNSIGNED4 expire = 0) : cpp,action,context,entrypoint='MSet';
BOOLEAN SetUtf8(CONST VARSTRING servers, CONST VARSTRING key, CONST UTF8 value, CONST VARSTRING partitionKey = '', UNSIGNED4 expire = 0) : cpp,action,context,entrypoint='MSetUtf8';
BOOLEAN SetBoolean(CONST VARSTRING servers, CONST VARSTRING key, BOOLEAN value, CONST VARSTRING partitionKey = '', UNSIGNED4 expire = 0) : cpp,action,context,entrypoint='MSet';
BOOLEAN SetReal(CONST VARSTRING servers, CONST VARSTRING key, REAL value, CONST VARSTRING partitionKey = '', UNSIGNED4 expire = 0) : cpp,action,context,entrypoint='MSet';
BOOLEAN SetInteger(CONST VARSTRING servers, CONST VARSTRING key, INTEGER value, CONST VARSTRING partitionKey = '', UNSIGNED4 expire = 0) : cpp,action,context,entrypoint='MSet';
BOOLEAN SetUnsigned(CONST VARSTRING servers, CONST VARSTRING key, UNSIGNED value,CONST VARSTRING partitionKey = '', UNSIGNED4 expire = 0) : cpp,action,context,entrypoint='MSet';
BOOLEAN SetData(CONST VARSTRING servers, CONST VARSTRING key, CONST DATA value, CONST VARSTRING partitionKey = '', UNSIGNED4 expire = 0) : cpp,action,context,entrypoint='MSetData';

INTEGER8 GetInteger(CONST VARSTRING servers, CONST VARSTRING key, CONST VARSTRING partitionKey = '') : cpp,action,context,entrypoint='MGetInt8';
UNSIGNED8 GetUnsigned(CONST VARSTRING servers, CONST VARSTRING key, CONST VARSTRING partitionKey = '') : cpp,action,context,entrypoint='MGetUint8';
STRING GetString(CONST VARSTRING servers, CONST VARSTRING key, CONST VARSTRING partitionKey = '') : cpp,action,context,entrypoint='MGetStr';
UNICODE GetUnicode(CONST VARSTRING servers, CONST VARSTRING key, CONST VARSTRING partitionKey = '') : cpp,action,context,entrypoint='MGetUChar';
UTF8 GetUtf8(CONST VARSTRING servers, CONST VARSTRING key, CONST VARSTRING partitionKey = '') : cpp,action,context,entrypoint='MGetUtf8';
BOOLEAN GetBoolean(CONST VARSTRING servers, CONST VARSTRING key, CONST VARSTRING partitionKey = '') : cpp,action,context,entrypoint='MGetBool';
REAL GetReal(CONST VARSTRING servers, CONST VARSTRING key, CONST VARSTRING partitionKey = '') : cpp,action,context,entrypoint='MGetDouble';
DATA GetData(CONST VARSTRING servers, CONST VARSTRING key, CONST VARSTRING partitionKey = '') : cpp,action,context,entrypoint='MGetData';

BOOLEAN Exist(CONST VARSTRING servers, CONST VARSTRING key, CONST VARSTRING partitionKey = '') : cpp,action,context,entrypoint='MExist';
CONST VARSTRING KeyType(CONST VARSTRING servers, CONST VARSTRING key, CONST VARSTRING partitionKey = '') : cpp,action,context,entrypoint='MKeyType'; //NOTE: calls get
BOOLEAN Clear(CONST VARSTRING servers) : cpp,action,context,entrypoint='MClear';
END;