Subject: [bug#77541] [PATCH 09/38] gnu: python-vaex-core: Update to 4.17.1.

From: Nicolas Graves <[email-masked]>
Date: Fri, 4 Apr 2025 21:16:41 +0200

* gnu/packages/python-science.scm (python-vaex-core): Update to 4.17.1.
* gnu/packages/patches/python-vaex-core-fix-tsl-use.patch: Add patch.
* gnu/local.mk: Record patch.
---
 gnu/local.mk                                  |  1 +
 .../python-vaex-core-fix-tsl-use.patch        | 67 +++++++++++++++++++
 gnu/packages/python-science.scm               | 44 ++++++++----
 3 files changed, 100 insertions(+), 12 deletions(-)
 create mode 100644 gnu/packages/patches/python-vaex-core-fix-tsl-use.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 18ba0073fc..93f346481d 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2142,6 +2142,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/python-robotframework-sshlibrary-rf5-compat.patch \
   %D%/packages/patches/python-unittest2-python3-compat.patch	\
   %D%/packages/patches/python-unittest2-remove-argparse.patch	\
+  %D%/packages/patches/python-vaex-core-fix-tsl-use.patch	\
   %D%/packages/patches/python-vega-datasets-remove-la-riots-code.patch	\
   %D%/packages/patches/python-versioneer-guix-support.patch	\
   %D%/packages/patches/python-werkzeug-tests.patch		\
diff --git a/gnu/packages/patches/python-vaex-core-fix-tsl-use.patch b/gnu/packages/patches/python-vaex-core-fix-tsl-use.patch
new file mode 100644
index 0000000000..f4f6fc1c48
--- /dev/null
+++ b/gnu/packages/patches/python-vaex-core-fix-tsl-use.patch
@@ -0,0 +1,67 @@
+From 8cb8808b3ceccf4ab3ac542739ef490abe7e76b3 Mon Sep 17 00:00:00 2001
+Message-ID: <[email-masked]>
+From: Nicolas Graves <[email-masked]>
+Date: Wed, 2 Apr 2025 14:29:40 +0200
+Subject: [PATCH] Fix tsl map use
+
+---
+ packages/vaex-core/src/hash_string.hpp | 25 ++++++++++++++++---------
+ 1 file changed, 16 insertions(+), 9 deletions(-)
+
+diff --git a/packages/vaex-core/src/hash_string.hpp b/packages/vaex-core/src/hash_string.hpp
+index d3b60199..0ed69d1c 100644
+--- a/packages/vaex-core/src/hash_string.hpp
++++ b/packages/vaex-core/src/hash_string.hpp
+@@ -39,13 +39,15 @@ class hash_base : public hash_common<Derived, T, hashmap<T, int64_t>> {
+         for (int i = 0; i < nmaps; i++) {
+             string_arrays.emplace_back(std::make_shared<StringList64>());
+             StringList64 *strings = string_arrays[i].get();
+-            // equal_to<string_ref>& eq = this->maps[i].key_eq();
+-            this->maps[i].m_ht.strings_equals = strings;
+-            this->maps[i].m_ht.strings_hash = strings;
++            equal_to<key_type> eq;
++            eq.strings_equals = strings;
++            hash<key_type> h;
++            h.strings_hash = strings;
++            this->maps[i] = hashmap_type(8, h, eq);
+         }
+     };
+ 
+-    virtual std::string _get(hashmap_type &map, typename hashmap_type::key_type key) override { return map.m_ht.strings_equals->get(key.index); };
++    virtual std::string _get(hashmap_type &map, typename hashmap_type::key_type key) override { return string_arrays[0]->get(key.index); };
+ 
+     size_t bytes_used() const {
+         int64_t buffer_size = 0; // collect buffer size
+@@ -391,9 +393,12 @@ class ordered_set : public hash_base<ordered_set<T>, T, T, V> {
+     template <class SL>
+     static ordered_set *create(std::shared_ptr<SL> keys, int64_t null_value, int64_t nan_count, int64_t null_count, std::string *fingerprint) {
+         ordered_set *set = new ordered_set(1);
+-        set->maps[0].m_ht.strings_equals = keys.get();
+-        set->maps[0].m_ht.strings_hash = keys.get();
+         set->string_arrays[0] = keys;
++        equal_to<key_type> eq;
++        eq.strings_equals = keys.get();
++        hash<key_type> h;
++        h.strings_hash = keys.get();
++        set->maps[0] = hashmap_type(keys->length, h, eq);
+         {
+             size_t size = keys->length;
+             set->maps[0].reserve(size);
+@@ -701,9 +706,11 @@ class index_hash : public hash_base<index_hash<T>, T, T, V> {
+             // string_arrays_overflow.emplace_back(std::make_shared<StringList64>());
+             // for each key in overflow, it should be present in the main string array
+             StringList64 *strings = this->string_arrays[i].get();
+-            // equal_to<string_ref>& eq = this->maps[i].key_eq();
+-            overflows[i].m_ht.strings_equals = strings;
+-            overflows[i].m_ht.strings_hash = strings;
++            equal_to<key_type> eq;
++            eq.strings_equals = strings;
++            hash<key_type> h;
++            h.strings_hash = strings;
++            overflows[i] = overflow_type(8, h, eq);
+         }
+     }
+ 
+-- 
+2.49.0
+
diff --git a/gnu/packages/python-science.scm b/gnu/packages/python-science.scm
index 3bf266582d..73e08fccbe 100644
--- a/gnu/packages/python-science.scm
+++ b/gnu/packages/python-science.scm
@@ -4097,24 +4097,44 @@ (define-public python-opt-einsum
 (define-public python-vaex-core
   (package
     (name "python-vaex-core")
-    (version "4.17.1")
+    (version "4.18.1")
     (source
      (origin
-       (method url-fetch)
-       (uri (pypi-uri "vaex-core" version))
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://www.github.com/maartenbreddels/vaex")
+             (commit (string-append "core-v" version))))
+       (file-name (git-file-name name version))
        (sha256
-        (base32 "1rzx5px3fwi5mh1z8y91brvffk7dkhj287lnmqp8zp6836kkqhya"))
-       (modules '((guix build utils)))
+        (base32 "1sp096msbzgjlwi8c1ink2bp4pjff9pvikqz1y1li8d3in4gpgdr"))
+       (patches
+        (search-patches "python-vaex-core-fix-tsl-use.patch"))
+       (modules '((guix build utils)
+                  (ice-9 ftw)))
        (snippet
-        ;; Remove bundled libraries
-        '(for-each delete-file-recursively
-                   (list "vendor/boost"
-                         "vendor/pcre"
-                         "vendor/pybind11")))))
+        #~(begin
+            ;; Delete everything except for vaex-core itself:
+            (define (delete-except exception)
+              (lambda (file)
+                (unless (member file `("." ".." ,exception))
+                  (delete-file-recursively file))))
+            (for-each (delete-except "packages") (scandir "."))
+            (with-directory-excursion "packages"
+              (for-each (delete-except "vaex-core") (scandir ".")))
+            (for-each (lambda (file)
+                        (unless (member file '("." ".."))
+                          (rename-file
+                           (string-append "packages/vaex-core/" file)
+                           file)))
+                      (scandir "packages/vaex-core"))
+            (delete-file-recursively "packages")
+            (delete-file-recursively "vendor")))))
     (build-system pyproject-build-system)
-    (arguments (list #:tests? #false)) ;require vaex.server and others, which require vaex-core.
+    (arguments
+     ;; require vaex.server and others, which require vaex-core.
+     (list #:tests? #false))
     (inputs
-     (list boost pcre pybind11-2.3))
+     (list boost pcre pybind11 string-view-lite tsl-hopscotch-map))
     (propagated-inputs
      (list python-aplus
            python-blake3
-- 
2.49.0