Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extend rustfft to singlestore DB #49

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

extend rustfft to singlestore DB #49

wants to merge 4 commits into from

Conversation

attacker0211
Copy link
Collaborator

No description provided.

@@ -0,0 +1,53 @@
use rustfft::{FftPlanner};
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment here that just says that this file is a test driver for the module, and is intended to be compiled and run on the native platform?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I was going to ask you more about this. It's seems a bit inefficient to compile this with the module. This can be extended further to generate Makefile test (seems to be simple enough if we are going with the make test approach, I'm not sure). However, the main point is this can be kept separately, maybe a generate_tests library to generate tests for this (and potentially other modules we will be writing) but I don't know if it's a good idea or the best way to do this.

Copy link
Member

Choose a reason for hiding this comment

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

One way we can deal with this is to use the pattern here:
https://github.com/singlestore-labs/singlestoredb-extension-bloom-filters/blob/main/src/lib.rs

Using this approach, we can use Rust's built-in test framework and not require an additional file.

Note the conditional compilation of the interface at the top. For this purpose, you can just ignore the "handle" stuff.

Copy link
Member

Choose a reason for hiding this comment

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

Either way, I'm not sure it's possible to completely remove the cognitive overhead of having native tests (other than not to include them).

@@ -0,0 +1,36 @@
# Prerequisite
Copy link
Member

Choose a reason for hiding this comment

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

Let's flesh this file out a little more. Here's a good template to follow:

https://github.com/singlestore-labs/singlestoredb-extension-bloom-filters

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated

## Contents
This library provides the following database objects.

### `st_planner_forward(len: u8, buffer: [Complex<f64>])`
Copy link
Member

Choose a reason for hiding this comment

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

Let's use the database types here. So, for this case it would be:

st_planner_forward(len TINYINT UNSIGNED NOT NULL, buffer RECORD(re DOUBLE NOT NULL, im DOUBLE NOT NULL)

This is a bit long for the heading line, so maybe just put st_planner_forward in the heading and then put the UDF signature in the description.

This is a TVF that will create a a new FFT algorthim instance for computing forward FFT of size `len`. Divides the `buffer` into chunks of size `len`, and computes FFT forward on each chunk.
This method will panic (on Rust side) if:
```
buffer.len() % len > 0
Copy link
Member

Choose a reason for hiding this comment

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

Using database operators, this would be:

LENGTH(buffer) MOD len > 0

buffer.len() < len
```

### `st_planner_inverse(len: u8, buffer: [Complex<f64>])`
Copy link
Member

Choose a reason for hiding this comment

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

Same comments as above in favor of using database syntax.

```

## Usage
The following is a simple example that creates two tables with a columns of strings. The first table's column is used to generate a Bloom Filter, which we store in a User Defined Variable. We then run the Bloom Filter on the strings in the second table.
Copy link
Member

Choose a reason for hiding this comment

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

I think you forgot to delete this paragraph :-)


## Usage
The following is a simple example that creates two tables with a columns of strings. The first table's column is used to generate a Bloom Filter, which we store in a User Defined Variable. We then run the Bloom Filter on the strings in the second table.
The following is a simple example that performs forward FFT on a vector `buffer` of two complex numbers `{"re": 1.0, "im": 2.5}` and `{"re": 2.0, "im": 2.5}`. This will divides the vector `buffer` into chunks of size `1` and computes a FFT on each chunk.
Copy link
Member

Choose a reason for hiding this comment

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

divides -> divide
computes -> compute

The following is a simple example that creates two tables with a columns of strings. The first table's column is used to generate a Bloom Filter, which we store in a User Defined Variable. We then run the Bloom Filter on the strings in the second table.
The following is a simple example that performs forward FFT on a vector `buffer` of two complex numbers `{"re": 1.0, "im": 2.5}` and `{"re": 2.0, "im": 2.5}`. This will divides the vector `buffer` into chunks of size `1` and computes a FFT on each chunk.
```sql
SELECT * FROM (st_process_forward(1, [ROW(1.0, 2.5), ROW(2.0, 2.5)]));
Copy link
Member

Choose a reason for hiding this comment

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

The outer parens aren't needed here.

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.

None yet

2 participants