You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datasketches.apache.org by ch...@apache.org on 2022/12/20 11:58:33 UTC
[datasketches-cpp] branch master updated: Finished init and test
This is an automated email from the ASF dual-hosted git repository.
charlie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/datasketches-cpp.git
The following commit(s) were added to refs/heads/master by this push:
new 80ed1a3 Finished init and test
80ed1a3 is described below
commit 80ed1a33bbc3f1584c67d86bcfb388f752efb802
Author: charlied <ch...@yahooinc.com>
AuthorDate: Tue Dec 20 11:58:24 2022 +0000
Finished init and test
---
CMakeLists.txt | 3 ++-
count/CMakeLists.txt | 42 ++++++++++++++++++++++++++++++++++++++++
count/include/count_min.hpp | 22 +++++++++++++++++++++
count/include/count_min_impl.hpp | 15 ++++++++++++++
count/test/CMakeLists.txt | 42 ++++++++++++++++++++++++++++++++++++++++
count/test/count_min_test.cpp | 14 ++++++++++++++
6 files changed, 137 insertions(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 705a009..3070f57 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -115,12 +115,13 @@ add_subdirectory(sampling)
add_subdirectory(tuple)
add_subdirectory(req)
add_subdirectory(quantiles)
+add_subdirectory(count)
if (WITH_PYTHON)
add_subdirectory(python)
endif()
-target_link_libraries(datasketches INTERFACE hll cpc kll fi theta sampling req quantiles)
+target_link_libraries(datasketches INTERFACE hll cpc kll fi theta sampling req quantiles count) # change here
if (COVERAGE)
find_program(LCOV_PATH NAMES "lcov")
diff --git a/count/CMakeLists.txt b/count/CMakeLists.txt
new file mode 100644
index 0000000..3cd48c5
--- /dev/null
+++ b/count/CMakeLists.txt
@@ -0,0 +1,42 @@
+# 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.
+
+add_library(count INTERFACE)
+
+add_library(${PROJECT_NAME}::COUNT ALIAS count)
+
+if (BUILD_TESTS)
+ add_subdirectory(test)
+endif()
+
+target_include_directories(count
+ INTERFACE
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>
+ )
+
+target_link_libraries(count INTERFACE common)
+target_compile_features(count INTERFACE cxx_std_11)
+
+install(TARGETS count
+ EXPORT ${PROJECT_NAME}
+ )
+
+install(FILES
+ include/count_min.hpp
+ include/count_min_impl.hpp
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/DataSketches")
diff --git a/count/include/count_min.hpp b/count/include/count_min.hpp
new file mode 100644
index 0000000..10f7148
--- /dev/null
+++ b/count/include/count_min.hpp
@@ -0,0 +1,22 @@
+#ifndef COUNT_MIN_HPP_
+#define COUNT_MIN_HPP_
+
+#include <cstdint>
+#include <vector>
+
+namespace datasketches {
+
+class count_min_sketch{
+public:
+ uint64_t num_hashes ;
+ count_min_sketch(uint64_t num_hashes) ;
+
+ // Getters
+ uint64_t get_num_hashes() ;
+};
+
+} /* namespace datasketches */
+
+#include "count_min_impl.hpp"
+
+#endif
\ No newline at end of file
diff --git a/count/include/count_min_impl.hpp b/count/include/count_min_impl.hpp
new file mode 100644
index 0000000..9140d3a
--- /dev/null
+++ b/count/include/count_min_impl.hpp
@@ -0,0 +1,15 @@
+#ifndef COUNT_MIN_IMPL_HPP_
+#define COUNT_MIN_IMPL_HPP_
+
+//#include "count_min.hpp"
+namespace datasketches {
+count_min_sketch::count_min_sketch(const uint64_t num_hashes):num_hashes(num_hashes){
+};
+
+uint64_t count_min_sketch::get_num_hashes() {
+ return num_hashes ;
+}
+
+} /* namespace datasketches */
+
+#endif
\ No newline at end of file
diff --git a/count/test/CMakeLists.txt b/count/test/CMakeLists.txt
new file mode 100644
index 0000000..9d07e83
--- /dev/null
+++ b/count/test/CMakeLists.txt
@@ -0,0 +1,42 @@
+# 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.
+
+add_executable(count_min_test)
+
+target_link_libraries(count_min_test count common_test_lib)
+
+set_target_properties(count_min_test PROPERTIES
+ CXX_STANDARD 11
+ CXX_STANDARD_REQUIRED YES
+ )
+
+file(TO_CMAKE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" COUNT_TEST_BINARY_PATH)
+string(APPEND COUNT_TEST_BINARY_PATH "/")
+target_compile_definitions(count_min_test
+ PRIVATE
+ TEST_BINARY_INPUT_PATH="${COUNT_TEST_BINARY_PATH}"
+ )
+
+add_test(
+ NAME count_min_test
+ COMMAND count_min_test
+)
+
+target_sources(count_min_test
+ PRIVATE
+ count_min_test.cpp
+ )
diff --git a/count/test/count_min_test.cpp b/count/test/count_min_test.cpp
new file mode 100644
index 0000000..b2d6d6b
--- /dev/null
+++ b/count/test/count_min_test.cpp
@@ -0,0 +1,14 @@
+#include <catch2/catch.hpp>
+
+#include "count_min.hpp"
+
+namespace datasketches{
+
+TEST_CASE("CM init"){
+ uint64_t n_hashes = 5 ;
+ count_min_sketch c(n_hashes) ;
+ REQUIRE(c.get_num_hashes() == 5) ;
+}
+
+} /* namespace datasketches */
+
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datasketches.apache.org
For additional commands, e-mail: commits-help@datasketches.apache.org