Merge branch 'master' of github.com:bonitao/cmph
This commit is contained in:
commit
a17b3792d1
|
@ -1,7 +1,7 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT
|
||||
AC_CONFIG_SRCDIR([Makefile.am])
|
||||
AM_INIT_AUTOMAKE(cmph, 1.0)
|
||||
AM_INIT_AUTOMAKE(cmph, 2.0)
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
|
@ -50,9 +50,11 @@ if test x$cxxmph = xtrue; then
|
|||
AC_SUBST([CXXMPH], "cxxmph")
|
||||
fi
|
||||
|
||||
PKG_CHECK_MODULES([CHECK], [check >= 0.9.8])
|
||||
PKG_CHECK_MODULES([CHECK], [check >= 0.9.8], [HAVE_LIBCHECK=1], [HAVE_LIBCHECK=])
|
||||
if test "x$CHECK_LIBS" = "x" ; then
|
||||
AC_MSG_WARN([Testing library not found, make check will fail.])
|
||||
if test "x$cxxmph" = "xtrue"; then
|
||||
AC_MSG_WARN([Testing library not found, make check will fail.])
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(CHECK_LIBS)
|
||||
AC_SUBST(CHECK_CFLAGS)
|
||||
|
|
|
@ -4,14 +4,17 @@ noinst_PROGRAMS = bm_index bm_map
|
|||
bin_PROGRAMS = cxxmph
|
||||
|
||||
cxxmph_includedir = $(includedir)/cxxmph/
|
||||
cxxmph_include_HEADERS = mph_map.h mph_index.h MurmurHash3.h trigraph.h seeded_hash.h stringpiece.h hollow_iterator.h
|
||||
cxxmph_include_HEADERS = mph_bits.h mph_map.h mph_index.h MurmurHash3.h trigraph.h seeded_hash.h stringpiece.h hollow_iterator.h string_util.h
|
||||
|
||||
noinst_LTLIBRARIES = libcxxmph_test.la
|
||||
check_LTLIBRARIES = libcxxmph_test.la
|
||||
noinst_LTLIBRARIES = libcxxmph_bm.la
|
||||
lib_LTLIBRARIES = libcxxmph.la
|
||||
libcxxmph_la_SOURCES = MurmurHash3.h MurmurHash3.cpp trigragh.h trigraph.cc mph_bits.h mph_bits.cc mph_index.h mph_index.cc seeded_hash.h stringpiece.h benchmark.h benchmark.cc string_util.cc
|
||||
libcxxmph_la_SOURCES = MurmurHash3.cpp trigraph.cc mph_bits.cc mph_index.cc benchmark.h benchmark.cc string_util.cc
|
||||
libcxxmph_la_LDFLAGS = -version-info 0:0:0
|
||||
libcxxmph_test_la_SOURCES = test.h test.cc
|
||||
libcxxmph_test_la_LIBADD = libcxxmph.la
|
||||
libcxxmph_bm_la_SOURCES = benchmark.h benchmark.cc bm_common.h bm_common.cc
|
||||
libcxxmph_bm_la_LIBADD = libcxxmph.la
|
||||
|
||||
test_test_SOURCES = test_test.cc
|
||||
test_test_LDADD = libcxxmph_test.la $(CHECK_LIBS)
|
||||
|
@ -22,14 +25,14 @@ mph_map_test_SOURCES = mph_map_test.cc
|
|||
mph_index_test_LDADD = libcxxmph.la
|
||||
mph_index_test_SOURCES = mph_index_test.cc
|
||||
|
||||
bm_index_LDADD = libcxxmph.la -lcmph
|
||||
bm_index_SOURCES = bm_common.cc bm_index.cc
|
||||
|
||||
trigraph_test_LDADD = libcxxmph.la
|
||||
trigraph_test_SOURCES = trigraph_test.cc
|
||||
|
||||
bm_map_LDADD = libcxxmph.la
|
||||
bm_map_SOURCES = bm_common.cc bm_map.cc
|
||||
bm_index_LDADD = libcxxmph_bm.la -lcmph
|
||||
bm_index_SOURCES = bm_index.cc
|
||||
|
||||
bm_map_LDADD = libcxxmph_bm.la
|
||||
bm_map_SOURCES = bm_map.cc
|
||||
|
||||
cxxmph_LDADD = libcxxmph.la
|
||||
cxxmph_SOURCES = cxxmph.cc
|
||||
|
|
|
@ -26,7 +26,7 @@ struct hollow_iterator_base
|
|||
: public std::iterator<std::forward_iterator_tag,
|
||||
typename iterator::value_type> {
|
||||
public:
|
||||
typedef hollow_iterator_base<iterator, is_empty>& self_type;
|
||||
typedef hollow_iterator_base<iterator, is_empty> self_type;
|
||||
typedef self_type& self_reference;
|
||||
typedef typename iterator::reference reference;
|
||||
typedef typename iterator::pointer pointer;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace cxxmph {
|
||||
|
||||
using namespace cxxmph;
|
||||
using namespace std;
|
||||
|
||||
template <template<typename...> class map_type>
|
||||
|
@ -24,8 +25,9 @@ struct MapTester {
|
|||
static bool large_insert() {
|
||||
map_type<int64_t, int64_t> m;
|
||||
// Start counting from 1 to not touch default constructed value bugs
|
||||
for (int i = 1; i < 12 * 256 * 256; ++i) m.insert(make_pair(i, i));
|
||||
return m.size() == 12 * 256 * 256 - 1;
|
||||
int nkeys = 12 * 256 * 256;
|
||||
for (int i = 1; i < nkeys; ++i) m.insert(make_pair(i, i));
|
||||
return static_cast<int>(m.size()) == nkeys - 0;
|
||||
}
|
||||
static bool small_search() {
|
||||
map_type<int64_t, int64_t> m;
|
||||
|
@ -54,7 +56,7 @@ struct MapTester {
|
|||
int nkeys = 10 * 1000;
|
||||
vector<string> keys;
|
||||
for (int i = 0; i < nkeys; ++i) {
|
||||
keys.push_back(cxxmph::format("%v", i));
|
||||
keys.push_back(format("%v", i));
|
||||
}
|
||||
map_type<string, int64_t> m;
|
||||
for (int i = 0; i < nkeys; ++i) m.insert(make_pair(keys[i], i));
|
||||
|
@ -65,6 +67,42 @@ struct MapTester {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
static bool rehash_zero() {
|
||||
map_type<int64_t, int64_t> m;
|
||||
m.rehash(0);
|
||||
return m.size() == 0;
|
||||
}
|
||||
static bool rehash_size() {
|
||||
map_type<int64_t, int64_t> m;
|
||||
int nkeys = 10 * 1000;
|
||||
for (int i = 0; i < nkeys; ++i) { m.insert(make_pair(i, i)); }
|
||||
m.rehash(nkeys);
|
||||
for (int i = 0; i < nkeys; ++i) { if (m.find(i) == m.end()) return false; }
|
||||
for (int i = nkeys; i < nkeys * 2; ++i) {
|
||||
if (m.find(i) != m.end()) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static bool erase_iterator() {
|
||||
map_type<int64_t, int64_t> m;
|
||||
int nkeys = 10 * 1000;
|
||||
for (int i = 0; i < nkeys; ++i) { m.insert(make_pair(i, i)); }
|
||||
for (int i = nkeys; i >= 0; --i) {
|
||||
m.erase(m.find(i));
|
||||
if (static_cast<int>(m.size()) != i) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static bool erase_value() {
|
||||
map_type<int64_t, int64_t> m;
|
||||
int nkeys = 10 * 1000;
|
||||
for (int i = 0; i < nkeys; ++i) { m.insert(make_pair(i, i)); }
|
||||
for (int i = nkeys; i >= 0; --i) {
|
||||
m.erase(i);
|
||||
if (static_cast<int>(m.size()) != i) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace cxxxmph
|
||||
|
|
|
@ -11,3 +11,7 @@ CXXMPH_CXX_TEST_CASE(small_search, Tester::small_search);
|
|||
CXXMPH_CXX_TEST_CASE(default_search, Tester::default_search);
|
||||
CXXMPH_CXX_TEST_CASE(large_search, Tester::large_search);
|
||||
CXXMPH_CXX_TEST_CASE(string_search, Tester::string_search);
|
||||
CXXMPH_CXX_TEST_CASE(rehash_zero, Tester::rehash_zero);
|
||||
CXXMPH_CXX_TEST_CASE(rehash_size, Tester::rehash_size);
|
||||
CXXMPH_CXX_TEST_CASE(erase_value, Tester::erase_value);
|
||||
CXXMPH_CXX_TEST_CASE(erase_iterator, Tester::erase_iterator);
|
||||
|
|
|
@ -17,58 +17,7 @@ CXXMPH_CXX_TEST_CASE(small_search, Tester::small_search);
|
|||
CXXMPH_CXX_TEST_CASE(default_search, Tester::default_search);
|
||||
CXXMPH_CXX_TEST_CASE(large_search, Tester::large_search);
|
||||
CXXMPH_CXX_TEST_CASE(string_search, Tester::string_search);
|
||||
|
||||
/*
|
||||
using std::make_pair;
|
||||
using std::string;
|
||||
using cxxmph::mph_map;
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
mph_map<int64_t, int64_t> b;
|
||||
int32_t num_keys = 1000*10;
|
||||
for (int i = 0; i < num_keys; ++i) {
|
||||
b.insert(make_pair(i, i));
|
||||
}
|
||||
b.rehash(b.size());
|
||||
for (int i = 0; i < 1000000; ++i) {
|
||||
auto it = b.find(i % num_keys);
|
||||
if (it == b.end()) {
|
||||
std::cerr << "Failed to find " << i << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
if (it->first != it->second || it->first != i % num_keys) {
|
||||
std::cerr << "Found " << it->first << " looking for " << i << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
mph_map<string, int> h;
|
||||
h.insert(std::make_pair("-1",-1));
|
||||
mph_map<string, int>::const_iterator it;
|
||||
for (it = h.begin(); it != h.end(); ++it) {
|
||||
if (it->second != -1) exit(-1);
|
||||
}
|
||||
int32_t num_valid = 100;
|
||||
for (int i = 0; i < num_valid; ++i) {
|
||||
char buf[10];
|
||||
snprintf(buf, 10, "%d", i);
|
||||
h.insert(std::make_pair(buf, i));
|
||||
}
|
||||
for (int j = 0; j < 100; ++j) {
|
||||
for (int i = 1000; i > 0; --i) {
|
||||
char buf[10];
|
||||
snprintf(buf, 10, "%d", i - 1);
|
||||
auto it = h.find(buf);
|
||||
if (i < num_valid && it->second != i - 1) exit(-1);
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < 100; ++j) {
|
||||
for (int i = 1000; i > 0; --i) {
|
||||
char buf[10];
|
||||
int key = i*100 - 1;
|
||||
snprintf(buf, 10, "%d", key);
|
||||
auto it = h.find(buf);
|
||||
if (key < num_valid && it->second != key) exit(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
CXXMPH_CXX_TEST_CASE(rehash_zero, Tester::rehash_zero);
|
||||
CXXMPH_CXX_TEST_CASE(rehash_size, Tester::rehash_size);
|
||||
CXXMPH_CXX_TEST_CASE(erase_value, Tester::erase_value);
|
||||
CXXMPH_CXX_TEST_CASE(erase_iterator, Tester::erase_iterator);
|
||||
|
|
|
@ -3,7 +3,7 @@ noinst_PROGRAMS = bm_numbers
|
|||
lib_LTLIBRARIES = libcmph.la
|
||||
include_HEADERS = cmph.h cmph_types.h cmph_time.h chd_ph.h
|
||||
libcmph_la_SOURCES = hash.h hash.c \
|
||||
jenkins_hash.h jenkins_hash.c MurmurHash2.h\
|
||||
jenkins_hash.h jenkins_hash.c \
|
||||
hash_state.h debug.h \
|
||||
vstack.h vstack.c vqueue.h vqueue.c\
|
||||
graph.h graph.c bitbool.h \
|
||||
|
|
Loading…
Reference in New Issue