Skip to content

Commit

Permalink
Update PGM-index submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
gvinciguerra committed Mar 27, 2024
1 parent 034e98f commit 3993f26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion PGM-index
Submodule PGM-index updated 75 files
+45 −0 .github/workflows/build.yml
+41 −0 .github/workflows/codeql.yml
+5 −1 .gitignore
+1 −1 .replit
+0 −15 .travis.yml
+21 −21 CMakeLists.txt
+42 −17 README.md
+2 −0 benchmark/CMakeLists.txt
+81 −30 benchmark/args.hxx
+133 −0 benchmark/benchmark.cpp
+282 −0 benchmark/benchmark.hpp
+93 −0 benchmark/plots.ipynb
+7 −0 c-interface/CMakeLists.txt
+148 −0 c-interface/cpgm.cpp
+77 −0 c-interface/cpgm.h
+8 −0 c-interface/examples/CMakeLists.txt
+41 −0 c-interface/examples/simple.c
+57 −0 c-interface/examples/updates.c
+20 −0 examples/CMakeLists.txt
+58 −0 examples/mapped.cpp
+43 −0 examples/multidimensional.cpp
+4 −4 examples/multiset.cpp
+34 −0 examples/simple.cpp
+43 −0 examples/updates.cpp
+574 −0 include/pgm/morton_nd.hpp
+76 −68 include/pgm/pgm_index.hpp
+717 −0 include/pgm/pgm_index_dynamic.hpp
+1,221 −0 include/pgm/pgm_index_variants.hpp
+47 −53 include/pgm/piecewise_linear_model.hpp
+10,828 −0 include/pgm/sdsl.hpp
+0 −317 include/pgm_index_compressed.hpp
+0 −654 include/pgm_index_dynamic.hpp
+0 −189 include/pgm_index_in_memory.hpp
+0 −398 include/tuner.hpp
+0 −9 lib/alglib/CMakeLists.txt
+0 −339 lib/alglib/gpl2.txt
+0 −674 lib/alglib/gpl3.txt
+0 −57,987 lib/alglib/manual.cpp.html
+0 −16,651 lib/alglib/src/alglibinternal.cpp
+0 −1,495 lib/alglib/src/alglibinternal.h
+0 −8,609 lib/alglib/src/alglibmisc.cpp
+0 −2,008 lib/alglib/src/alglibmisc.h
+0 −12,005 lib/alglib/src/ap.cpp
+0 −4,260 lib/alglib/src/ap.h
+0 −49,098 lib/alglib/src/dataanalysis.cpp
+0 −10,098 lib/alglib/src/dataanalysis.h
+0 −1,320 lib/alglib/src/diffequations.cpp
+0 −276 lib/alglib/src/diffequations.h
+0 −3,751 lib/alglib/src/fasttransforms.cpp
+0 −731 lib/alglib/src/fasttransforms.h
+0 −4,242 lib/alglib/src/integration.cpp
+0 −863 lib/alglib/src/integration.h
+0 −55,740 lib/alglib/src/interpolation.cpp
+0 −10,027 lib/alglib/src/interpolation.h
+0 −50,918 lib/alglib/src/linalg.cpp
+0 −8,165 lib/alglib/src/linalg.h
+0 −65,378 lib/alglib/src/optimization.cpp
+0 −11,256 lib/alglib/src/optimization.h
+0 −13,680 lib/alglib/src/solvers.cpp
+0 −3,648 lib/alglib/src/solvers.h
+0 −10,264 lib/alglib/src/specialfunctions.cpp
+0 −2,207 lib/alglib/src/specialfunctions.h
+0 −19,832 lib/alglib/src/statistics.cpp
+0 −1,359 lib/alglib/src/statistics.h
+0 −2 lib/alglib/src/stdafx.h
+0 −9,390 lib/sdsl.hpp
+2 −1 test/CMakeLists.txt
+1,405 −790 test/catch.hpp
+2 −171 test/main.cpp
+284 −0 test/tests.cpp
+90 −0 test/utils.hpp
+0 −117 tuner.cpp
+3 −0 tuner/CMakeLists.txt
+111 −0 tuner/tuner.cpp
+350 −0 tuner/tuner.hpp
25 changes: 12 additions & 13 deletions pygm/pygm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <unordered_map>
#include <vector>

#include "pgm_index.hpp"
#include "pgm/pgm_index.hpp"

namespace py = pybind11;
using namespace pybind11::literals;
Expand Down Expand Up @@ -85,7 +85,7 @@ bool set_unique_includes(InputIt1 first1, InputIt1 last1, InputIt2 first2, Input
#define IGNORED_PARAMETER 1
#define EPSILON_RECURSIVE 4

template <typename K> class PGMWrapper : private PGMIndex<K, IGNORED_PARAMETER, EPSILON_RECURSIVE, double> {
template <typename K> class PGMWrapper : private pgm::PGMIndex<K, IGNORED_PARAMETER, EPSILON_RECURSIVE, double> {
std::vector<K> data;
bool duplicates;
size_t epsilon = 64;
Expand All @@ -98,10 +98,10 @@ template <typename K> class PGMWrapper : private PGMIndex<K, IGNORED_PARAMETER,
}
this->first_key = data.front();
if (this->n < 1ull << 15)
this->build(begin(), end(), epsilon, EPSILON_RECURSIVE);
this->build(begin(), end(), epsilon, EPSILON_RECURSIVE, this->segments, this->levels_offsets);
else {
py::gil_scoped_release release;
this->build(begin(), end(), epsilon, EPSILON_RECURSIVE);
this->build(begin(), end(), epsilon, EPSILON_RECURSIVE, this->segments, this->levels_offsets);
}
}

Expand Down Expand Up @@ -141,7 +141,6 @@ template <typename K> class PGMWrapper : private PGMIndex<K, IGNORED_PARAMETER,
this->n = p.n;
this->segments = p.segments;
this->first_key = p.first_key;
this->levels_sizes = p.levels_sizes;
this->levels_offsets = p.levels_offsets;
} else {
build_internal_pgm();
Expand Down Expand Up @@ -182,7 +181,7 @@ template <typename K> class PGMWrapper : private PGMIndex<K, IGNORED_PARAMETER,
build_internal_pgm();
}

ApproxPos search(const K &key) const {
pgm::ApproxPos search(const K &key) const {
auto k = std::max(this->first_key, key);
auto it = this->segment_for_key(k);
auto pos = std::min<size_t>((*it)(k), std::next(it)->intercept);
Expand Down Expand Up @@ -268,18 +267,18 @@ template <typename K> class PGMWrapper : private PGMIndex<K, IGNORED_PARAMETER,

size_t num_segments(size_t level_num) {
if (level_num < 0)
throw std::invalid_argument("level can't be negative");
if (level_num > this->height())
throw std::invalid_argument("level can't be greater than index height");
throw std::invalid_argument("level can't be < 0");
if (level_num >= this->height())
throw std::invalid_argument("level can't be >= index height");

return this->levels_sizes[level_num];
return this->levels_offsets[level_num + 1] - this->levels_offsets[level_num] - 1;
}

std::unordered_map<std::string, double> segment(size_t level_num, int segment_num) {
if (level_num < 0)
throw std::invalid_argument("level can't be negative");
if (level_num > this->height())
throw std::invalid_argument("level can't be greater than index height");
throw std::invalid_argument("level can't be < 0");
if (level_num >= this->height())
throw std::invalid_argument("level can't be >= index height");

std::unordered_map<std::string, double> segment;
segment["epsilon"] = level_num == 0 ? get_epsilon() : get_epsilon_recursive();
Expand Down

0 comments on commit 3993f26

Please sign in to comment.