From 9fe190f5d500e22b0894095e7c917f9c652e0a64 Mon Sep 17 00:00:00 2001 From: Douglas Rumbaugh Date: Wed, 20 Mar 2024 17:30:14 -0400 Subject: Updates/progress towards succinct trie support --- tests/include/testing.h | 59 +++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 7 deletions(-) (limited to 'tests/include/testing.h') diff --git a/tests/include/testing.h b/tests/include/testing.h index f935b53..a3c54c0 100644 --- a/tests/include/testing.h +++ b/tests/include/testing.h @@ -15,6 +15,8 @@ #include #include +#include +#include #include "util/types.h" #include "psu-util/alignment.h" @@ -25,6 +27,38 @@ typedef de::WeightedRecord WRec; typedef de::Record Rec; typedef de::EuclidPoint PRec; +typedef de::Record StringRec; + +std::string kjv_wordlist = "tests/data/kjv-wordlist.txt"; +std::string summa_wordlist = "tests/data/summa-wordlist.txt"; + +static std::vector read_string_data(std::string fname, size_t n) { + std::vector vec; + vec.reserve(n); + + std::fstream file; + file.open(fname, std::ios::in); + + for (size_t i=0; i std::vector strip_wrapping(std::vector> vec) { std::vector out(vec.size()); @@ -83,15 +117,26 @@ static de::MutableBuffer *create_test_mbuffer(size_t cnt) R rec; if constexpr (de::KVPInterface) { - for (size_t i = 0; i < cnt; i++) { - rec.key = rand(); - rec.value = rand(); - - if constexpr (de::WeightedRecordInterface) { - rec.weight = 1; + if constexpr (std::is_same_v) { + auto records = read_string_data(kjv_wordlist, cnt); + for (size_t i=0; i) { + rec.weight = 1; + } + + buffer->append(records[i]); } + } else { + for (size_t i = 0; i < cnt; i++) { + rec.key = rand(); + rec.value = rand(); + + if constexpr (de::WeightedRecordInterface) { + rec.weight = 1; + } - buffer->append(rec); + buffer->append(rec); + } } } else if constexpr (de::NDRecordInterface) { for (size_t i=0; i