You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by GitBox <gi...@apache.org> on 2022/06/18 13:05:47 UTC

[GitHub] [incubator-kvrocks] PragmaTwice commented on a diff in pull request #584: feat(ops): Add more compression

PragmaTwice commented on code in PR #584:
URL: https://github.com/apache/incubator-kvrocks/pull/584#discussion_r900882501


##########
cmake/lz4.cmake:
##########
@@ -0,0 +1,82 @@
+# 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.
+
+include_guard()
+
+# lib name
+set(LZ4_LIB_NAME "lz4")
+# set lz4
+set(LZ4_SOURCE "lz4-1.9.3")
+# set download dir
+set(LZ4_ZIP_DL_DIR ${CMAKE_CURRENT_BINARY_DIR}/_deps)
+# set zip file name
+set(LZ4_ZIP_NAME "lz4-1.9.3.tar.gz")
+#
+set(LZ4_ZIP_ABSOLUT_PATH "${LZ4_ZIP_DL_DIR}/lz4-1.9.3.tar.gz")
+# url
+set(LZ4_DOWNLOAD_URL "https://github.com/lz4/lz4/archive/v1.9.3.tar.gz")
+# md5sum
+set(LZ4_MD5SUM "3a1ab1684e14fc1afc66228ce61b2db3")
+# set source dir
+set(LZ4_SOURCE_DIR "${LZ4_ZIP_DL_DIR}/${LZ4_SOURCE}")
+# include dir
+set(LZ4_LIB_INCLUDE_DIR ${LZ4_SOURCE_DIR}/lib)
+# src dir
+set(LZ4_LIB_SOURCE_DIR ${LZ4_SOURCE_DIR}/lib)
+# download timeout
+set(DOWNLOAD_LZ4_TIMEOUT 600 CACHE STRING "Timeout in seconds when downloading LZ4.")
+
+if (EXISTS ${LZ4_ZIP_ABSOLUT_PATH})
+	file(MD5 ${LZ4_ZIP_ABSOLUT_PATH} LZ4_MD5SUM_)
+	if (NOT ${LZ4_MD5SUM} STREQUAL ${LZ4_MD5SUM_})
+		message(STATUS "remove -f ${LZ4_ZIP_ABSOLUT_PATH}")
+		execute_process(COMMAND sh -c "rm -f ${LZ4_ZIP_ABSOLUT_PATH}")
+	endif()
+endif()
+
+if (NOT EXISTS ${LZ4_ZIP_ABSOLUT_PATH})
+	# download
+	message(STATUS "Downloading ${LZ4_ZIP_NAME} to ${LZ4_ZIP_ABSOLUT_PATH}")
+	file(DOWNLOAD ${LZ4_DOWNLOAD_URL}
+		${LZ4_ZIP_ABSOLUT_PATH}
+		TIMEOUT ${DOWNLOAD_LZ4_TIMEOUT}
+		STATUS ERR SHOW_PROGRESS)
+endif()
+
+if (EXISTS ${LZ4_ZIP_ABSOLUT_PATH})
+	file(MD5 ${LZ4_ZIP_ABSOLUT_PATH} LZ4_MD5SUM_)
+	if (NOT ${LZ4_MD5SUM} STREQUAL ${LZ4_MD5SUM_})
+		message(FATAL_ERROR "${LZ4_ZIP_ABSOLUT_PATH} seems be something wrong, please check")
+	endif()
+else()
+	message(FATAL_ERROR "${LZ4_ZIP_ABSOLUT_PATH} seems be something wrong, please check")
+endif()
+
+message(STATUS "remove ${LZ4_SOURCE_DIR}")
+execute_process(COMMAND sh -c "rm -rf ${LZ4_SOURCE_DIR}")

Review Comment:
   I think these commands are not friendly to incremental build, could you consider to remove them? 



##########
cmake/rocksdb.cmake:
##########
@@ -38,10 +38,14 @@ FetchContent_GetProperties(snappy)
 FetchContent_MakeAvailableWithArgs(rocksdb
   CMAKE_MODULE_PATH=${PROJECT_SOURCE_DIR}/cmake/modules # to locate FindJeMalloc.cmake
   Snappy_DIR=${PROJECT_SOURCE_DIR}/cmake/modules # to locate SnappyConfig.cmake
+  lz4_ROOT_DIR=${LZ4_LIB_SOURCE_DIR}
+  lz4_LIBRARIES=${LZ4_LIB_SOURCE_DIR}/liblz4.a
+  lz4_INCLUDE_DIRS=${LZ4_LIB_SOURCE_DIR}

Review Comment:
   Like cmake files in [cmake/modules](https://github.com/apache/incubator-kvrocks/tree/unstable/cmake/modules), injecting the lz4 target via hooking find package mechanism can propagate dependency relation into the rocksdb target, in addition this makes the dependencies more modular, we can easily do some switches to selectively enable them.
   Of course, if you are not familiar with them, I can follow up to help you implement them.



##########
cmake/lz4.cmake:
##########
@@ -0,0 +1,82 @@
+# 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.
+
+include_guard()
+
+# lib name
+set(LZ4_LIB_NAME "lz4")
+# set lz4
+set(LZ4_SOURCE "lz4-1.9.3")
+# set download dir
+set(LZ4_ZIP_DL_DIR ${CMAKE_CURRENT_BINARY_DIR}/_deps)
+# set zip file name
+set(LZ4_ZIP_NAME "lz4-1.9.3.tar.gz")
+#
+set(LZ4_ZIP_ABSOLUT_PATH "${LZ4_ZIP_DL_DIR}/lz4-1.9.3.tar.gz")
+# url
+set(LZ4_DOWNLOAD_URL "https://github.com/lz4/lz4/archive/v1.9.3.tar.gz")
+# md5sum
+set(LZ4_MD5SUM "3a1ab1684e14fc1afc66228ce61b2db3")
+# set source dir
+set(LZ4_SOURCE_DIR "${LZ4_ZIP_DL_DIR}/${LZ4_SOURCE}")
+# include dir
+set(LZ4_LIB_INCLUDE_DIR ${LZ4_SOURCE_DIR}/lib)
+# src dir
+set(LZ4_LIB_SOURCE_DIR ${LZ4_SOURCE_DIR}/lib)
+# download timeout
+set(DOWNLOAD_LZ4_TIMEOUT 600 CACHE STRING "Timeout in seconds when downloading LZ4.")
+
+if (EXISTS ${LZ4_ZIP_ABSOLUT_PATH})
+	file(MD5 ${LZ4_ZIP_ABSOLUT_PATH} LZ4_MD5SUM_)
+	if (NOT ${LZ4_MD5SUM} STREQUAL ${LZ4_MD5SUM_})
+		message(STATUS "remove -f ${LZ4_ZIP_ABSOLUT_PATH}")
+		execute_process(COMMAND sh -c "rm -f ${LZ4_ZIP_ABSOLUT_PATH}")
+	endif()
+endif()
+
+if (NOT EXISTS ${LZ4_ZIP_ABSOLUT_PATH})
+	# download
+	message(STATUS "Downloading ${LZ4_ZIP_NAME} to ${LZ4_ZIP_ABSOLUT_PATH}")
+	file(DOWNLOAD ${LZ4_DOWNLOAD_URL}
+		${LZ4_ZIP_ABSOLUT_PATH}
+		TIMEOUT ${DOWNLOAD_LZ4_TIMEOUT}
+		STATUS ERR SHOW_PROGRESS)
+endif()
+
+if (EXISTS ${LZ4_ZIP_ABSOLUT_PATH})
+	file(MD5 ${LZ4_ZIP_ABSOLUT_PATH} LZ4_MD5SUM_)
+	if (NOT ${LZ4_MD5SUM} STREQUAL ${LZ4_MD5SUM_})
+		message(FATAL_ERROR "${LZ4_ZIP_ABSOLUT_PATH} seems be something wrong, please check")
+	endif()
+else()
+	message(FATAL_ERROR "${LZ4_ZIP_ABSOLUT_PATH} seems be something wrong, please check")
+endif()

Review Comment:
   Could you use [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) instead of these manual downloading commands? 
   Just like [lua.cmake](https://github.com/apache/incubator-kvrocks/blob/unstable/cmake/lua.cmake#L22), it is easy to maintain and more straightforward.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org