Skip to content

Patches for OSX compilation warnings - #24

Merged
dvirsky merged 1 commit into
RediSearch:masterfrom
mheiber:patch-2-os-x-compilation
Feb 8, 2017
Merged

dvirsky merged 1 commit into
RediSearch:masterfrom
mheiber:patch-2-os-x-compilation

Conversation

@mheiber

@mheiber mheiber commented Jan 22, 2017 •

Copy link
Copy Markdown
Contributor

Fix compilation warnings caught on OS X:

  • NormalizeFunc was defined twice: remove the duplicate and fix
    up #includes
  • Avoid unsigned integer overflow bug vector in trie_type.c:
    slen-len isn't safe when the lengths are unsigned.

Also modified the main Makefile to use the -Werror flag in all environments, since OS X doesn't complain anymore.

@mheiber mheiber changed the title Patch 2 os x compilation Patches for OSX compilation warnings Jan 22, 2017
Comment thread src/trie/trie_type.c
}
// in prefix mode we also factor in the total length of the suffix
if (prefixMode) {
ent->score /= sqrt(1 + fabs(slen - len));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove fabs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly, clang threw a warning for fabs here because slen and len are unsigned. But getting rid of fabs isn't the right solution, I should have cast each of slen and len to a signed type instead and kept the call to fabs. Nice catch. Will fix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it's not safe to cast size_t to an unsigned type, so now I'm just subtracting the lesser number from the greater number.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size_t is an unsigned type though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, I meant it's not safe to cast size_t to a signed type, since the standard doesn't specify what that type would be. And subtraction between unsigned types could underflow.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, what you did makes sense

Comment thread src/tests/time_sample.h Outdated
}

static long long TimeSampler_DurationNS(TimeSample *ts) {
// static long long TimeSampler_DurationNS(TimeSample *ts) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though they are not used, I want to separate this file into a stand-alone library, so the compiler flags here should alllow unused functions.

@mheiber
mheiber force-pushed the patch-2-os-x-compilation branch 2 times, most recently from 06bcc71 to fbe9b5c Compare January 28, 2017 22:33
@mheiber

mheiber commented Jan 28, 2017

Copy link
Copy Markdown
Contributor Author

@dvirsky I'm getting this test failure, are you seeing this too?

test_range.c:17: 46 != 60: 

@dvirsky

dvirsky commented Jan 31, 2017

Copy link
Copy Markdown
Contributor

@mheiber re the test failure - nope, the test failure is not happening for me. can you make sure you make clean before testing this?

Comment thread src/Makefile Outdated
SHOBJ_CFLAGS ?= -dynamic -fno-common -g -ggdb
SHOBJ_LDFLAGS ?= -bundle -undefined dynamic_lookup
endif

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lines 10+11

# We add -Werror to CFLAGS only on Linux since on OSX there are still tons of warnings
CFLAGS +=-Werror  

for linux only should be removed if -Werror is now global

@dvirsky

dvirsky commented Jan 31, 2017

Copy link
Copy Markdown
Contributor

@mheiber I've managed to get my hands on a Mac, and tried compiling it, got tons of linker errors, aren't you getting those?

In any case, I've googled a bit and found the fix, now I just need to be able to commit from that machine :)

@mheiber

mheiber commented Jan 31, 2017 via email

Copy link
Copy Markdown
Contributor Author

@dvirsky

dvirsky commented Jan 31, 2017

Copy link
Copy Markdown
Contributor

Nope. I removed them from CFLAGS, indeed they shouldn't be there. They should be in the linker flags. But what I got was tons of errors when linking against Snowball stemmer, about incompatible mac os versions. I managed to address this issue specifically and got rid of them.

@mheiber

mheiber commented Feb 1, 2017 via email

Copy link
Copy Markdown
Contributor Author

@dvirsky

dvirsky commented Feb 1, 2017

Copy link
Copy Markdown
Contributor

@mheiber yep.
The fix was to add -mmacosx-version-min=10.6 to the CFLAGS in dep/snowball/GNUMakeFile, and -mmacosx_version_min 10.6 to the SHOBJ_LDFLAGS in the root Makefile (notice the two forms of writing it, ld accepts different flags than gcc), only in the mac os part.

@mheiber
mheiber force-pushed the patch-2-os-x-compilation branch 2 times, most recently from 42e7133 to 2f1d376 Compare February 1, 2017 17:41
@mheiber

mheiber commented Feb 1, 2017

Copy link
Copy Markdown
Contributor Author

@dvirsky this PR currently includes:

  • changes to flags
  • changes to code

Since you refactored flags and are testing on OS X, I plan to modify this PR to include only code changes. 👍 ?

@dvirsky

dvirsky commented Feb 2, 2017

Copy link
Copy Markdown
Contributor

I'd be happy with both, but maybe just rebase first because I made a lot of changes to compilation flags. As long as no warnings are issued and tests all pass, I'm good.

Notice that right now I'm exporting CFLAGS in the main make file, and on all sub makefiles, I've changed to CFLAGS ?= ... which means that when compiled from the main makefile, we simply use the root makefile's CFLAGS.

@dvirsky dvirsky closed this Feb 2, 2017
@dvirsky dvirsky reopened this Feb 2, 2017
@mheiber

mheiber commented Feb 4, 2017

Copy link
Copy Markdown
Contributor Author

I'm still getting test_range.c:17: 46 != 60: on OSX, even on a fresh pull. I'm not seeing the problem on Ubuntu. I'll dig in.

@dvirsky

dvirsky commented Feb 5, 2017

Copy link
Copy Markdown
Contributor

@mheiber I should be getting a new Mac this week (yay!). you can leave it and I'll try to see what's up. it's interesting though that we have a bug and not just a compiler issue.

@mheiber

mheiber commented Feb 6, 2017

Copy link
Copy Markdown
Contributor Author

@dvirsky the problem may be with line https://github.com/RedisLabsModules/RediSearch/blob/master/src/tests/test_range.c#L15. rand() returned different values in OS X as compared to Ubuntu, though it was deterministic in both environments.

@dvirsky

dvirsky commented Feb 6, 2017

Copy link
Copy Markdown
Contributor

@mheiber I've seeded srand() to get consistent results. We can substitute this with a custom pseudo random function, but since it's just a problem with the test, let's ignore this failure for now, and I'll handle it when I switch to Mac.

So what's the status of the PR? Can you rebase and squash and let's finish with this?

@mheiber

mheiber commented Feb 7, 2017 via email

Copy link
Copy Markdown
Contributor Author

@dvirsky

dvirsky commented Feb 7, 2017 •

Copy link
Copy Markdown
Contributor

@mheiber I've added a custom PRNG function (Blum Blum Shub) to the tests (not pushed yet), if you want just replace it in the test.

+u_int prng_seed = 1337;
+#define PRNG_MOD 30980347
+u_int prng() {
+  prng_seed = (prng_seed * prng_seed) % PRNG_MOD;
+  return prng_seed;
+}
+
 int testRangeIterator() {
   NumericRangeTree *t = NewNumericRangeTree();
   ASSERT(t != NULL);

-  srand(1337);
   int N = 100;
   for (int i = 0; i < N; i++) {

     t_docId docId = i + 1;
-    float value = (double)(1 + rand() % 1000);
+    float value = (double)(1 + prng() % 1000);
     // printf("Adding %d > %f\n", docId, value);
     NumericRangeTree_Add(t, docId, value);
   }
-  // ASSERT_EQUAL(t->numRanges, 13);
+  ASSERT_EQUAL(t->numRanges, 8);
   ASSERT_EQUAL(t->numEntries, N);

   NumericFilter *flt = NewNumericFilter(-1, 1002, 0, 0);

@mheiber
mheiber force-pushed the patch-2-os-x-compilation branch from 2f1d376 to 5a34147 Compare February 8, 2017 03:49
@mheiber

mheiber commented Feb 8, 2017 •

Copy link
Copy Markdown
Contributor Author

@dvirsky I fixed up the compiler warnings.
Re the test: could we use srand to set the random seed?

@dvirsky

dvirsky commented Feb 8, 2017

Copy link
Copy Markdown
Contributor

I used srand in the previous version, it looks like the rand() function itself might work differently on OSX. Anyway the custom function I made is pre seeded with a fixed number so will always give the same sequence of random numbers.

@mheiber

mheiber commented Feb 8, 2017

Copy link
Copy Markdown
Contributor Author

@dvirsky the prng() function did the trick, tests are passing for me on both OS X and Ubuntu now.

@dvirsky

dvirsky commented Feb 8, 2017

Copy link
Copy Markdown
Contributor

Awesome. so are we good? Can you rebase and squash the entire branch? IIRC I've pushed the prng to master yesterday, so you'll probably see a collision.

@mheiber
mheiber force-pushed the patch-2-os-x-compilation branch from fbd2848 to 885c03f Compare February 8, 2017 16:03
- NormalizeFunc was defined twice: remove the duplicate and fix
up `#include`s
- Avoid unsigned integer overflow bug vector in trie_type.c:
`slen-len` isn't safe when the lengths are unsigned.

tests: test_range.c: use same "random" nums across environments

- Before, using rand() yielded different results across OSX and
Linux environments we tried. The test relies on the same values
being generated in the same order, so use @dvirsky's pseudo-
random number generator.
@mheiber
mheiber force-pushed the patch-2-os-x-compilation branch from 885c03f to a7b29f3 Compare February 8, 2017 16:06
@mheiber

mheiber commented Feb 8, 2017 via email

Copy link
Copy Markdown
Contributor Author

@dvirsky

dvirsky commented Feb 8, 2017

Copy link
Copy Markdown
Contributor

@mheiber thanks, I fixed the tests. I'll pull in a bit.

@dvirsky
dvirsky merged commit ea27de1 into RediSearch:master Feb 8, 2017
@dvirsky

dvirsky commented Feb 8, 2017

Copy link
Copy Markdown
Contributor

Merged. Thanks a lot!

@mheiber

mheiber commented Feb 8, 2017

Copy link
Copy Markdown
Contributor Author

@dvirsky thanks for the coaching

@mheiber
mheiber deleted the patch-2-os-x-compilation branch February 8, 2017 16:39
@dvirsky

dvirsky commented Feb 8, 2017

Copy link
Copy Markdown
Contributor

@mheiber I'm not seeing the mac os CFLAGS. did you add those?

@mheiber

mheiber commented Feb 8, 2017

Copy link
Copy Markdown
Contributor Author

@dvirsky

dvirsky commented Feb 8, 2017

Copy link
Copy Markdown
Contributor

There was the issue with the -mmacosx-version-min flag that cause all the linker errors. nevermind, I'll patch it up myself

hualoqueros pushed a commit to hualoqueros/redisearchgo that referenced this pull request Oct 7, 2020
[add] increasing code coverage on aggregate.go
ofiryanai pushed a commit that referenced this pull request Mar 2, 2026
* delete deps/ disk/ tests/ and redisearch_module.c

* add initial crate & CMakeLists.txt

* modify root CMakeLists.txt to build rust static lib

* change workflow to just build

* add dummy file, turn shared on, add CMAKE_ARGS

* revert .gitignore to main + cargo

* remove testing_symbols

* remove deps & tests from gitignore, remove dummy file

* remove c++ deps & add comment on shared=ON

* add error message

* Give CMAKE_ARGS a default to make CI happy

* Remove redisearch specifics from .gitignore

* Don't build redisearch as shared lib

* Build as `oss` type

* Update submodules to use ssh

* Update comment on shared build config

* add clippy lint task

* testing rebuild?

* Minimal Rust to get the server starting

* Update redisearch deps

* Open index

* Impl close

* Close index spec

* Move into modules

* Touchups

* impl IndexSpec

* put and index minimal, IndexSpec::insert_document, helpers

* add IndexSpec::index_document

* Impl needed code for term iterator

* Correctly get the document keys

* Respect updated documents

* Add tests for index spec

* Add `impl Into<Key>` for inserting documents

* Extract inverted index values into posting list struct

* Tests for posting list

This also removes the lifetime on the wrapping iterator since we can use
`'static` for now.

* Simplify into query iterator

* Rename to postings list

* small cleanup

* Simplify search disk

* Comments and renamings

* add unsafe comments

* number references to safety comments

* Improve comment

* Only use `dev` profile in DEBUG mode

* Remove unused function

* Rename function clashing with `Iterator::next`

This just avoids confusion with the iterator function calls.

* Fix document list indentation

* Use CMake's default casing

* Explicitly set release builds

* move some structs into separate files

* make casting consistent

* initial commit

* use explicit cast

* Update redisearch submodule

* Document static lifetime

* Use an inverted index structure

* use unwrap instead of expect

* clippy

* comments + as_mut_unchecked generic lifetime

* add documentation to dmd members

* add test workflow, fix doc metadata tests

* make test workflow smaller since only cargo runs

* typo

* add field mask field

* add field mask in term_iterator + tests

* nits

* use newer disk api and align the extern c functions in lib.rs

* small fixes

* use expect

* align to previous error

* add doc comments to IndexEntry, and test doc ids

* add a `cargo fmt check` to the lint workflow

* typo, test color again

* use --color=

* hack so colors are shown

* add comment explaining hack

* format code

* MOD-12397: Rust - Add Support To Track Deleted Document IDs (#19)

* initial commit

* code review fixes

* code review comments

* remove unused functions

* update cargo lock

* add test for deleting documents, try and fix lint issue

* format the code

* Fix intend in CI merge to queue event (#24)

* MOD-12398: Store DocumentType inside IndexSpec (#27)

* initial commit

* code review comments

* Remove broken pull request flow (#28)

* Restore pull request flow

* Just remove the broken file instead

* [MOD-12405] Use the iterator from the OSS (#16)

* Use the iterator from the OSS

This makes the wrapping iterator generic to allow us to use any of the
OSS iterators. This means also implementing the `IndexReader` for the
postings list.

* Remove need for loop

Co-authored-by: Enrico Borba <[email protected]>

* Idiomatic Rust index access

Co-authored-by: Enrico Borba <[email protected]>

* Use cast() instead

* Add missing documentation

* Don't set out of bounds index positions

* Make sure `postings_block_index` is not out of bounds

* Remove unneeded methods

* Reuse the wrapper from OSS

We no longer need our own implementation of this.

* Don't allow backwards skips

* Add comment for index fields

* Unwrap last entry instead

* Another last entry unwrap

* Better variable name

* More better names

Co-authored-by: kei-nan <[email protected]>

* Update redisearch submodule

---------

Co-authored-by: Enrico Borba <[email protected]>
Co-authored-by: kei-nan <[email protected]>

* [MOD-12413] speedb database creation (#26)

* WIP db impl

* add constant

* add tests

* add basic tests, and multi-threaded docs

* add doc_type

* Fix warnings in `inverted_index` integration test module (#30)

* [MOD-12445] Serialize and deserialize the DB types (#22)

* Serialize and deserialize document metatdata

* Serialize and deserialize a full term block

* Add versioning support

* Add safety comment

* Update comments

* Fix version and count comment

Co-authored-by: Copilot <[email protected]>

* Fix test function name

Co-authored-by: Copilot <[email protected]>

* Change safety to panic comments

Co-authored-by: Copilot <[email protected]>

* Convert unsafe from_bytes function

* Lazy read DMD data

* Convert another unsafe function to panic instead

* Use alias for metadata bytes

* Use `size_of`

Co-authored-by: Enrico Borba <[email protected]>

* Remove obvious comments

* Change return type to `t_docId`

* Prevent integer overflows

* Use constant for latest version

* Use a constant for `FullTerm` size

* Use `u8` to track number of terms

* Pass down `frequency`

* Use size constant in more places

* BASE_OFFSET constant & num_entries type fixes

* Restore test

* Remove hardcoded offsets

* Split doc IDs from metadata in storage

* Lint issues

* Fix comments about bound checking

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Enrico Borba <[email protected]>

* Respect weight when searching (#29)

Pass weight to the virtual RSIndexResult in
`InvertedIndex::term_iterator`

Signed-off-by: Henk Oordt <[email protected]>

* Make wildcard iterator (#32)

* [MOD-12396] Make a new type for document ID key (#25)

* Make a new type for document ID key

This allows us to use document IDs as keys in speedb where they will
need to be sortable lexicographically.

* Make padding width a constant

Co-authored-by: Enrico Borba <[email protected]>

* Make the inner doc ID private

---------

Co-authored-by: Enrico Borba <[email protected]>

* Fix wildcard compile issue (#34)

* Directly use Rust port of DocumentType from RediSearch (#33)

Change type of `doc_table::DocTable` from `ffi::DocumentType` to
`document::DocumentType`. Update other code affected by this change.

As `document::DocumentType` does not implement `Default`, we provide
a manual implementation of `Default` for `DocTable`, replacing
the derived implementation.

Signed-off-by: Henk Oordt <[email protected]>

* [MOD-12709] make unique docs return u64 for IndexReader (#36)

* make unique docs return u64

* align with RediSearch master

* properly align RediSearch

* MOD-12892: Open Index Spec Columns Upon IndexSpec Creation (#37)

* open index spec columns when opening an index

* code review fixes

* [MOD-12411] Doc table in speedb (#38)

* Pass the database down to `DocTable`

* Pass cf_name to doc table

* Store in speedb

* Make new type for speedb database handle

This just makes it easier to share around the code.

* Simplify

* Easier column family handle management

* Easier key management

* Propagate speedb errors

* Make it easier to get the doc id from a speedb key

* Improve comments

* Lint fixes

* Simple iterator

* More lint issues

* Hook up to search on disk database

* Better trait name

* Missing comment

* Use is deleted check instead

* Add comment about cf handle not being stored

* add more unittests to document_metadata (#42)

* add more unittests to document_metadata

* remove useless tests

* apply code suggestion changes

* MOD-12832: Add Integration Test Framework Using RLTest (#39)

* initial commit

* use python file to run tests

* remove old runtests.sh file

* usd bdd approach

* some additional fixes

* additional fixes

* enable flex option in redis-server

* support providing library path

* support rust backtraces, try and fix panic when opening database

* fixes

* code review fixes

* run each test in its own folder to allow test parallelism

* provide the redis-lib-path

* add caching support

* compilation fix

* try and find bs_speedb.so

* fix python package installation

* init submodules

* fix python installation flow

* fix sccache write errors

* try and fix sccache

* additional fixes

* fix test

* split caching to multiple steps

* remove semicolon

* try and fix caching, also use newer bdd

* fix lint issue

* change key to be based on redis sha1 commit id

* use release mode

* need to use sudo when restoring from cache into system folders

* change caching key, use repo variable for runs-on

* use debug in CI, support profile in build.sh

* code review fixes

* code review comments

* add wildcard featur testing

* code review comment

* support running tests in parallel

* add more unittests to document_id_key (#41)

* add more unittests to document_id_key

* remove useless tests

* Apply suggestions from code review

Co-authored-by: Pieter <[email protected]>

* fix more comments

---------

Co-authored-by: Pieter <[email protected]>

* [MOD-12987] Make inverted_index module with full_term_block privately in it  (#47)

* move full term block as private in inverted index

* undo change

* create an inverted index submodule with full term block private in it

* Update redisearch_disk/src/index_spec/inverted_index/mod.rs

Co-authored-by: Pieter <[email protected]>

---------

Co-authored-by: Pieter <[email protected]>

* [MOD-13005] Make doc_table module with document_metadata privately in it (#49)

* move full term block as private in inverted index

* undo change

* create an inverted index submodule with full term block private in it

* create a doc_table submodule with document metadata private in it

* Update redisearch_disk/src/index_spec/inverted_index/mod.rs

Co-authored-by: Pieter <[email protected]>

* Update redisearch_disk/src/index_spec/doc_table/mod.rs

Co-authored-by: Pieter <[email protected]>

---------

Co-authored-by: Pieter <[email protected]>

* Fix IsDeleted Logic In FFI (#51)

* try and stablize ci

* capture redis info at end of test

* info everything

* use resp3 to try and get potential warnings

* remove caching

* try and fix tests

* revert caching removal

* remove miri section

* revert task-test.yml

* remove redundant code

* refactor document id key removing storage module (#50)

* move full term block as private in inverted index

* undo change

* create an inverted index submodule with full term block private in it

* create a doc_table submodule with document metadata private in it

* refactor document id key removing storage module

* MOD-12970: Run Unit Tests with Miri in CI (#48)

* initial commit

* use a seperate runner for miri

* try without submodules

* generate github token

* Update .github/workflows/task-test.yml

apply code review comment

Co-authored-by: Itzikvaknin <[email protected]>

* fix code review comment, separate flows into different files, have a pr-validation step

* remove miri section

* update miri yml task

---------

Co-authored-by: Itzikvaknin <[email protected]>

* add rusttoolchain to align rust version with redisearch (#56)

* add rusttoolchain to align rust version with redisearch

* add clippy install to linting

* [MOD-12410] Implement merge function (#44)

Rename `src/index_spec.rs` to `src/index_spec/mod.rs` for consistency

Clean up `PostingsListBlock`
- Introduce docs constants and const functions to clarify
   the layout of a block, and the way offsets are calculated
   to which data is written in a block in `PostingsListBlock::push`

Define and implement `PostingsListBlockBuilder`
- Repeatedly calling `PostingsListBlock::push` introduces
  unneeded shifting operations. `PostingsListBlockBuilder`
  allows for efficiently creating a `PostingsListBlock` from
  scratch

Implement `DeletedIdsStore`

- To allow for shared and synchronized access to deleted ids,
  implement a store for deleted IDs and replace instances of
  `DeletedIds` with it.

Implement merge operator

- Implement `DeletedIdsMergeOperator` and register it using
  `speedb::Options::set_merge_operator`

Address review comments

- Replace `DeletedIds::into_store` with `DeletedIdsStore::new()` and
  `DeletedIdsStore::with_deleted_ids`
- Introduce `ArchivedFillTermBlock::iter` to iterate over documents
  in the block, and use it in
`DeletedIdsMergeOperator::full_merge_inner::push_from_archived_block` to
clean up the loop.
- Document closure created in
  `DeletedIdsMergeOperator::full_merge_inner`
- Assert existing block's last doc ID is greater than that of any
  of the operands and specify the function's invariants in
`DeleteIdsMergeOperator::full_merge_inner`
- Fix incorrect tests in `merge_op`
- Remove `PostingsListBlock::MAX_NUM_TERMS` and
  `PostingsListBlock::is_full` as they're not enforceable.

* [MOD-12412] Inverted index in speedb (#45)

* Pass database down to inverted index

* Pass down inverted index cf name

* Switch to speedb

* Make key management easier

* Fix lint issues

* More safety

* Touch ups

* Don't delete the temp dir until the tests are done

* Remove name from key

* Prevent cloning term by borrowing

* Zero padd last doc id

* Propagate insert errors

* Lint issues

* Add documentation

* Log insert error

* Skip inverted index (now on speedb) tests for Miri

* Update todo comment

* Handle empty blocks after merge

* Panic on error for now

We can handle this better later.

* Don't silently fail on overflow

* Return `None` on error in `DeleterIdsMergeOperator::full_merge_inner` (#58)

Instead of panicking when detecting a data corruption, return `None`,
which is the correct way to signal speedb the data is incorrect.
Similarly, return an empty block instead of None if the merge result
contains no documents.

* MOD-12959: Handle Errors In FFI Layer Without Panicing (#57)

* try and avoid expect and panics in lib.rs

* fix lint

* code review fixes

* code review fixes - remove tests since they can't easily compile

* code review comments

* [MOD-13065] Docement why `u8` is safe for num_terms (#59)

* Docement why `u8` is safe for num_terms

* Improve comment

Co-authored-by: kei-nan <[email protected]>

---------

Co-authored-by: kei-nan <[email protected]>

* Update redisearch submodule and use new tracing (#60)

* Update redisearch submodule and use new tracing

* Link static libraries

* Build module in miri tests

* MOD-12976: Make DocTable Threadsafe (#52)

* initial commit - make document id atomic, recover last document id on doc table creation

* Apply suggestions from code review

apply suggestions

Co-authored-by: Copilot <[email protected]>

* make doc table threadsafe, no mut refrences

* code review comments

* remove path

* rename inverted index module file and move it

* code review comments

---------

Co-authored-by: Copilot <[email protected]>

* [MOD-12834] add benchmark CI (#53)

* add benchmark CI yamls

* add benchmark case

* list of repos with permission update

* have benchmark flow use proper paths

* Update .github/workflows/benchmark-flow.yml

* add rusttoolchain to align rust version with redisearch

* fix redis path

* add comments in files

* change some wording

* MOD-12833: CI Add Microbenchmark Support (#54)

* add microbenchmarks

* point microbenchmarks to correct branch

* code review fixes

* code review fix

* allow build.sh to run benchmarks

* return to parent folder

* rebase fix

* make running benchmarks conditional on label

* code review fixes

* change label

* fix fomratting

* modify the logic

* code review fixes

* various fixes

* run benchmark comparison on nightly

* add required permissions

* code review fixes

* run all microbenchmarks

* update documentation

* bring back --check

* fixes

* code review comments

* run specific microbenchmarks

* code review fixes

* make benchmark tasks more modularized to remove code duplication

* code review fixes

* code review fixes

* code review fixes

* code review comment - run all benchmarks

* code review comments

* try and fix benchmark flow

* only run benchmarks

* disable library benchmarking

* finish rename

* [RED-172954] add unittest for document_id_key [from to key] (#61)

* add unittest for document_id_key

* format fix

* [MOD-12977] Use lazy iterators (#46)

* Use a lazy iterator over the inverted index

* More tests

* Better comments

* Missing test case

* Better variable name

* Lint issue

* Don't iterate into similar prefixes

* Also use lazy (wildcard) iterator for doc table

* Propagate read error

* Optimize skip_to

* Avoid binary search if next term matches

* Optimize binary search from current location

* Simplify

* Address lint issue

* Better end key match

* Be explicit about errors

* Document prefix match logic

* Use alias

* Panic on overflow

* Extract delimeter into constant

* Handle failed iterator on FFI

* Use associate function instead

* Log the document id of the last read block

This is to help in the cases of debugging reading errors.

* Reset index on errors

* Make lazy reader over document table

* Lint error

---------

Signed-off-by: Henk Oordt <[email protected]>
Co-authored-by: Enrico Zandomeni Borba <[email protected]>
Co-authored-by: chesedo <[email protected]>
Co-authored-by: Enrico Borba <[email protected]>
Co-authored-by: Henk Oordt <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Joan Fontanals <[email protected]>
Co-authored-by: Itzikvaknin <[email protected]>
ofiryanai pushed a commit that referenced this pull request Mar 2, 2026
…lock::ArchivedBlock (#63)

* delete deps/ disk/ tests/ and redisearch_module.c

* add initial crate & CMakeLists.txt

* modify root CMakeLists.txt to build rust static lib

* change workflow to just build

* add dummy file, turn shared on, add CMAKE_ARGS

* revert .gitignore to main + cargo

* remove testing_symbols

* remove deps & tests from gitignore, remove dummy file

* remove c++ deps & add comment on shared=ON

* add error message

* Give CMAKE_ARGS a default to make CI happy

* Remove redisearch specifics from .gitignore

* Don't build redisearch as shared lib

* Build as `oss` type

* Update submodules to use ssh

* Update comment on shared build config

* add clippy lint task

* testing rebuild?

* Minimal Rust to get the server starting

* Update redisearch deps

* Open index

* Impl close

* Close index spec

* Move into modules

* Touchups

* impl IndexSpec

* put and index minimal, IndexSpec::insert_document, helpers

* add IndexSpec::index_document

* Impl needed code for term iterator

* Correctly get the document keys

* Respect updated documents

* Add tests for index spec

* Add `impl Into<Key>` for inserting documents

* Extract inverted index values into posting list struct

* Tests for posting list

This also removes the lifetime on the wrapping iterator since we can use
`'static` for now.

* Simplify into query iterator

* Rename to postings list

* small cleanup

* Simplify search disk

* Comments and renamings

* add unsafe comments

* number references to safety comments

* Improve comment

* Only use `dev` profile in DEBUG mode

* Remove unused function

* Rename function clashing with `Iterator::next`

This just avoids confusion with the iterator function calls.

* Fix document list indentation

* Use CMake's default casing

* Explicitly set release builds

* move some structs into separate files

* make casting consistent

* initial commit

* use explicit cast

* Update redisearch submodule

* Document static lifetime

* Use an inverted index structure

* use unwrap instead of expect

* clippy

* comments + as_mut_unchecked generic lifetime

* add documentation to dmd members

* add test workflow, fix doc metadata tests

* make test workflow smaller since only cargo runs

* typo

* add field mask field

* add field mask in term_iterator + tests

* nits

* use newer disk api and align the extern c functions in lib.rs

* small fixes

* use expect

* align to previous error

* add doc comments to IndexEntry, and test doc ids

* add a `cargo fmt check` to the lint workflow

* typo, test color again

* use --color=

* hack so colors are shown

* add comment explaining hack

* format code

* MOD-12397: Rust - Add Support To Track Deleted Document IDs (#19)

* initial commit

* code review fixes

* code review comments

* remove unused functions

* update cargo lock

* add test for deleting documents, try and fix lint issue

* format the code

* Fix intend in CI merge to queue event (#24)

* MOD-12398: Store DocumentType inside IndexSpec (#27)

* initial commit

* code review comments

* Remove broken pull request flow (#28)

* Restore pull request flow

* Just remove the broken file instead

* [MOD-12405] Use the iterator from the OSS (#16)

* Use the iterator from the OSS

This makes the wrapping iterator generic to allow us to use any of the
OSS iterators. This means also implementing the `IndexReader` for the
postings list.

* Remove need for loop

Co-authored-by: Enrico Borba <[email protected]>

* Idiomatic Rust index access

Co-authored-by: Enrico Borba <[email protected]>

* Use cast() instead

* Add missing documentation

* Don't set out of bounds index positions

* Make sure `postings_block_index` is not out of bounds

* Remove unneeded methods

* Reuse the wrapper from OSS

We no longer need our own implementation of this.

* Don't allow backwards skips

* Add comment for index fields

* Unwrap last entry instead

* Another last entry unwrap

* Better variable name

* More better names

Co-authored-by: kei-nan <[email protected]>

* Update redisearch submodule

---------

Co-authored-by: Enrico Borba <[email protected]>
Co-authored-by: kei-nan <[email protected]>

* [MOD-12413] speedb database creation (#26)

* WIP db impl

* add constant

* add tests

* add basic tests, and multi-threaded docs

* add doc_type

* Fix warnings in `inverted_index` integration test module (#30)

* [MOD-12445] Serialize and deserialize the DB types (#22)

* Serialize and deserialize document metatdata

* Serialize and deserialize a full term block

* Add versioning support

* Add safety comment

* Update comments

* Fix version and count comment

Co-authored-by: Copilot <[email protected]>

* Fix test function name

Co-authored-by: Copilot <[email protected]>

* Change safety to panic comments

Co-authored-by: Copilot <[email protected]>

* Convert unsafe from_bytes function

* Lazy read DMD data

* Convert another unsafe function to panic instead

* Use alias for metadata bytes

* Use `size_of`

Co-authored-by: Enrico Borba <[email protected]>

* Remove obvious comments

* Change return type to `t_docId`

* Prevent integer overflows

* Use constant for latest version

* Use a constant for `FullTerm` size

* Use `u8` to track number of terms

* Pass down `frequency`

* Use size constant in more places

* BASE_OFFSET constant & num_entries type fixes

* Restore test

* Remove hardcoded offsets

* Split doc IDs from metadata in storage

* Lint issues

* Fix comments about bound checking

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Enrico Borba <[email protected]>

* Respect weight when searching (#29)

Pass weight to the virtual RSIndexResult in
`InvertedIndex::term_iterator`

Signed-off-by: Henk Oordt <[email protected]>

* Make wildcard iterator (#32)

* [MOD-12396] Make a new type for document ID key (#25)

* Make a new type for document ID key

This allows us to use document IDs as keys in speedb where they will
need to be sortable lexicographically.

* Make padding width a constant

Co-authored-by: Enrico Borba <[email protected]>

* Make the inner doc ID private

---------

Co-authored-by: Enrico Borba <[email protected]>

* Fix wildcard compile issue (#34)

* Directly use Rust port of DocumentType from RediSearch (#33)

Change type of `doc_table::DocTable` from `ffi::DocumentType` to
`document::DocumentType`. Update other code affected by this change.

As `document::DocumentType` does not implement `Default`, we provide
a manual implementation of `Default` for `DocTable`, replacing
the derived implementation.

Signed-off-by: Henk Oordt <[email protected]>

* [MOD-12709] make unique docs return u64 for IndexReader (#36)

* make unique docs return u64

* align with RediSearch master

* properly align RediSearch

* MOD-12892: Open Index Spec Columns Upon IndexSpec Creation (#37)

* open index spec columns when opening an index

* code review fixes

* [MOD-12411] Doc table in speedb (#38)

* Pass the database down to `DocTable`

* Pass cf_name to doc table

* Store in speedb

* Make new type for speedb database handle

This just makes it easier to share around the code.

* Simplify

* Easier column family handle management

* Easier key management

* Propagate speedb errors

* Make it easier to get the doc id from a speedb key

* Improve comments

* Lint fixes

* Simple iterator

* More lint issues

* Hook up to search on disk database

* Better trait name

* Missing comment

* Use is deleted check instead

* Add comment about cf handle not being stored

* add more unittests to document_metadata (#42)

* add more unittests to document_metadata

* remove useless tests

* apply code suggestion changes

* MOD-12832: Add Integration Test Framework Using RLTest (#39)

* initial commit

* use python file to run tests

* remove old runtests.sh file

* usd bdd approach

* some additional fixes

* additional fixes

* enable flex option in redis-server

* support providing library path

* support rust backtraces, try and fix panic when opening database

* fixes

* code review fixes

* run each test in its own folder to allow test parallelism

* provide the redis-lib-path

* add caching support

* compilation fix

* try and find bs_speedb.so

* fix python package installation

* init submodules

* fix python installation flow

* fix sccache write errors

* try and fix sccache

* additional fixes

* fix test

* split caching to multiple steps

* remove semicolon

* try and fix caching, also use newer bdd

* fix lint issue

* change key to be based on redis sha1 commit id

* use release mode

* need to use sudo when restoring from cache into system folders

* change caching key, use repo variable for runs-on

* use debug in CI, support profile in build.sh

* code review fixes

* code review comments

* add wildcard featur testing

* code review comment

* support running tests in parallel

* add more unittests to document_id_key (#41)

* add more unittests to document_id_key

* remove useless tests

* Apply suggestions from code review

Co-authored-by: Pieter <[email protected]>

* fix more comments

---------

Co-authored-by: Pieter <[email protected]>

* [MOD-12987] Make inverted_index module with full_term_block privately in it  (#47)

* move full term block as private in inverted index

* undo change

* create an inverted index submodule with full term block private in it

* Update redisearch_disk/src/index_spec/inverted_index/mod.rs

Co-authored-by: Pieter <[email protected]>

---------

Co-authored-by: Pieter <[email protected]>

* [MOD-13005] Make doc_table module with document_metadata privately in it (#49)

* move full term block as private in inverted index

* undo change

* create an inverted index submodule with full term block private in it

* create a doc_table submodule with document metadata private in it

* Update redisearch_disk/src/index_spec/inverted_index/mod.rs

Co-authored-by: Pieter <[email protected]>

* Update redisearch_disk/src/index_spec/doc_table/mod.rs

Co-authored-by: Pieter <[email protected]>

---------

Co-authored-by: Pieter <[email protected]>

* Fix IsDeleted Logic In FFI (#51)

* try and stablize ci

* capture redis info at end of test

* info everything

* use resp3 to try and get potential warnings

* remove caching

* try and fix tests

* revert caching removal

* remove miri section

* revert task-test.yml

* remove redundant code

* refactor document id key removing storage module (#50)

* move full term block as private in inverted index

* undo change

* create an inverted index submodule with full term block private in it

* create a doc_table submodule with document metadata private in it

* refactor document id key removing storage module

* MOD-12970: Run Unit Tests with Miri in CI (#48)

* initial commit

* use a seperate runner for miri

* try without submodules

* generate github token

* Update .github/workflows/task-test.yml

apply code review comment

Co-authored-by: Itzikvaknin <[email protected]>

* fix code review comment, separate flows into different files, have a pr-validation step

* remove miri section

* update miri yml task

---------

Co-authored-by: Itzikvaknin <[email protected]>

* add rusttoolchain to align rust version with redisearch (#56)

* add rusttoolchain to align rust version with redisearch

* add clippy install to linting

* [MOD-12410] Implement merge function (#44)

Rename `src/index_spec.rs` to `src/index_spec/mod.rs` for consistency

Clean up `PostingsListBlock`
- Introduce docs constants and const functions to clarify
   the layout of a block, and the way offsets are calculated
   to which data is written in a block in `PostingsListBlock::push`

Define and implement `PostingsListBlockBuilder`
- Repeatedly calling `PostingsListBlock::push` introduces
  unneeded shifting operations. `PostingsListBlockBuilder`
  allows for efficiently creating a `PostingsListBlock` from
  scratch

Implement `DeletedIdsStore`

- To allow for shared and synchronized access to deleted ids,
  implement a store for deleted IDs and replace instances of
  `DeletedIds` with it.

Implement merge operator

- Implement `DeletedIdsMergeOperator` and register it using
  `speedb::Options::set_merge_operator`

Address review comments

- Replace `DeletedIds::into_store` with `DeletedIdsStore::new()` and
  `DeletedIdsStore::with_deleted_ids`
- Introduce `ArchivedFillTermBlock::iter` to iterate over documents
  in the block, and use it in
`DeletedIdsMergeOperator::full_merge_inner::push_from_archived_block` to
clean up the loop.
- Document closure created in
  `DeletedIdsMergeOperator::full_merge_inner`
- Assert existing block's last doc ID is greater than that of any
  of the operands and specify the function's invariants in
`DeleteIdsMergeOperator::full_merge_inner`
- Fix incorrect tests in `merge_op`
- Remove `PostingsListBlock::MAX_NUM_TERMS` and
  `PostingsListBlock::is_full` as they're not enforceable.

* [MOD-12412] Inverted index in speedb (#45)

* Pass database down to inverted index

* Pass down inverted index cf name

* Switch to speedb

* Make key management easier

* Fix lint issues

* More safety

* Touch ups

* Don't delete the temp dir until the tests are done

* Remove name from key

* Prevent cloning term by borrowing

* Zero padd last doc id

* Propagate insert errors

* Lint issues

* Add documentation

* Log insert error

* Skip inverted index (now on speedb) tests for Miri

* Update todo comment

* Handle empty blocks after merge

* Panic on error for now

We can handle this better later.

* Don't silently fail on overflow

* Return `None` on error in `DeleterIdsMergeOperator::full_merge_inner` (#58)

Instead of panicking when detecting a data corruption, return `None`,
which is the correct way to signal speedb the data is incorrect.
Similarly, return an empty block instead of None if the merge result
contains no documents.

* MOD-12959: Handle Errors In FFI Layer Without Panicing (#57)

* try and avoid expect and panics in lib.rs

* fix lint

* code review fixes

* code review fixes - remove tests since they can't easily compile

* code review comments

* [MOD-13065] Docement why `u8` is safe for num_terms (#59)

* Docement why `u8` is safe for num_terms

* Improve comment

Co-authored-by: kei-nan <[email protected]>

---------

Co-authored-by: kei-nan <[email protected]>

* Update redisearch submodule and use new tracing (#60)

* Update redisearch submodule and use new tracing

* Link static libraries

* Build module in miri tests

* MOD-12976: Make DocTable Threadsafe (#52)

* initial commit - make document id atomic, recover last document id on doc table creation

* Apply suggestions from code review

apply suggestions

Co-authored-by: Copilot <[email protected]>

* make doc table threadsafe, no mut refrences

* code review comments

* remove path

* rename inverted index module file and move it

* code review comments

---------

Co-authored-by: Copilot <[email protected]>

* [MOD-12834] add benchmark CI (#53)

* add benchmark CI yamls

* add benchmark case

* list of repos with permission update

* have benchmark flow use proper paths

* Update .github/workflows/benchmark-flow.yml

* add rusttoolchain to align rust version with redisearch

* fix redis path

* add comments in files

* change some wording

* MOD-12833: CI Add Microbenchmark Support (#54)

* add microbenchmarks

* point microbenchmarks to correct branch

* code review fixes

* code review fix

* allow build.sh to run benchmarks

* return to parent folder

* rebase fix

* make running benchmarks conditional on label

* code review fixes

* change label

* fix fomratting

* modify the logic

* code review fixes

* various fixes

* run benchmark comparison on nightly

* add required permissions

* code review fixes

* run all microbenchmarks

* update documentation

* bring back --check

* fixes

* code review comments

* run specific microbenchmarks

* code review fixes

* make benchmark tasks more modularized to remove code duplication

* code review fixes

* code review fixes

* code review fixes

* code review comment - run all benchmarks

* code review comments

* try and fix benchmark flow

* only run benchmarks

* disable library benchmarking

* finish rename

* [RED-172954] add unittest for document_id_key [from to key] (#61)

* add unittest for document_id_key

* format fix

* [MOD-12977] Use lazy iterators (#46)

* Use a lazy iterator over the inverted index

* More tests

* Better comments

* Missing test case

* Better variable name

* Lint issue

* Don't iterate into similar prefixes

* Also use lazy (wildcard) iterator for doc table

* Propagate read error

* Optimize skip_to

* Avoid binary search if next term matches

* Optimize binary search from current location

* Simplify

* Address lint issue

* Better end key match

* Be explicit about errors

* Document prefix match logic

* Use alias

* Panic on overflow

* Extract delimeter into constant

* Handle failed iterator on FFI

* Use associate function instead

* Log the document id of the last read block

This is to help in the cases of debugging reading errors.

* Reset index on errors

* Make lazy reader over document table

* Lint error

* renaming full term document

* add term module

* other iteration of refactor

* end refactor

* fix lint

* small improv

* changes as per review

---------

Signed-off-by: Henk Oordt <[email protected]>
Co-authored-by: Enrico Zandomeni Borba <[email protected]>
Co-authored-by: chesedo <[email protected]>
Co-authored-by: jonathan keinan <[email protected]>
Co-authored-by: Enrico Borba <[email protected]>
Co-authored-by: Henk Oordt <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Itzikvaknin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants