Skip to content

feat: support streaming processing of binary search tree #17

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

Merged
merged 48 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
19a0391
wip: cause integer overflow error in packedrtree
HideBa Mar 1, 2025
e5d590f
feat: add coding guidelines for TypeScript and JavaScript, including …
HideBa Mar 2, 2025
b49e72e
add d1 spec
HideBa Mar 2, 2025
28f9ba0
docs: fix docs about attribute indexing
HideBa Mar 2, 2025
141e746
fix docs about attribute indexing over http
HideBa Mar 2, 2025
cf87458
update specs
HideBa Mar 2, 2025
227c84a
add diagram
HideBa Mar 2, 2025
a6257e0
docs: update productContext
HideBa Mar 2, 2025
7fc8ff7
update product context
HideBa Mar 2, 2025
212b1d1
update progress
HideBa Mar 2, 2025
888e41c
update docs
HideBa Mar 2, 2025
01cccb8
Merge branch 'main' into massive-dataset
HideBa Mar 2, 2025
6ef72fa
update docs
HideBa Mar 2, 2025
7ab67f6
update docs
HideBa Mar 3, 2025
2884e37
calc geographical extent as option
HideBa Mar 4, 2025
ee03857
fix cli
HideBa Mar 5, 2025
b7730f7
wip: impl stream attr index
HideBa Mar 5, 2025
6a4d18f
wip: impl stream search for bst
HideBa Mar 5, 2025
f7147fc
wip: add http stream search
HideBa Mar 6, 2025
8129c1a
add stream search over the web on sorted index
HideBa Mar 7, 2025
f9622fd
http stream search
HideBa Mar 7, 2025
9d7dca8
wip: add test case for single condition query
HideBa Mar 7, 2025
709c4c2
update rule
HideBa Mar 7, 2025
de688a3
add tdd guide
HideBa Mar 7, 2025
1422f37
update docs
HideBa Mar 7, 2025
c00a108
remove rtree deps from bst
HideBa Mar 7, 2025
57ef38f
wip: test cases for multi steam index
HideBa Mar 8, 2025
7e9bcac
fix regression on normal query
HideBa Mar 8, 2025
135c9ae
fix range query
HideBa Mar 9, 2025
34394df
simplify query conditions
HideBa Mar 9, 2025
c9a72ad
add value type func on byteserializable trait
HideBa Mar 9, 2025
4d3e0a5
refactor any index trait
HideBa Mar 9, 2025
38daa2d
remove http for now
HideBa Mar 9, 2025
d3844d0
simplify cmp
HideBa Mar 9, 2025
31d5162
remove http test
HideBa Mar 9, 2025
07f20a6
fix com for float
HideBa Mar 9, 2025
8e36493
clean up
HideBa Mar 9, 2025
9fe4c93
fix `from_reader`
HideBa Mar 9, 2025
ef868df
fix test for stream query
HideBa Mar 10, 2025
4c02da5
remove unsed print
HideBa Mar 10, 2025
74097a1
add readme of bst
HideBa Mar 10, 2025
d525340
refactor to_byte in attr_query
HideBa Mar 10, 2025
6c35fc8
pass stream query test but wip for date time
HideBa Mar 11, 2025
942abcf
impl and pass all test for stream query (still need to clean up and r…
HideBa Mar 12, 2025
37547fc
comment out wasm
HideBa Mar 13, 2025
23a5df9
benchmark
HideBa Mar 13, 2025
94d1f4f
remove print output
HideBa Mar 13, 2025
ffc6ef1
docs: update readme of bst
HideBa Mar 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .cursor/rules/general.mdc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: General rules about the project and coding guidelines
globs:
alwaysApply: false
alwaysApply: true
---
# Important Rules for LLM

Expand All @@ -11,6 +11,7 @@ alwaysApply: false
- If a test fails more than twice in a row, analyze the current situation and collaborate with the user to determine a solution. Avoid trial-and-error testing without a hypothesis.
- The user has extensive knowledge gained from GitHub and can implement individual algorithms and libraries faster than Cline and Cursor. Code should be written while explaining to the user, using test cases to verify correctness.
- However, Cline and Cursor is not good at handling processing logic based on the current context. If the context is unclear, confirm with the user.
- Once I ask you to do "memory it", you should update [general.mdc](mdc:.cursor/rules/general.mdc) or other corresponding document files such as [productContext.md](mdc:.cursor/rules/memory/productContext.md), [specification.md](mdc:.cursor/rules/memory/specification.md), [progress.md](mdc:.cursor/rules/memory/progress.md) so they are kept update to date. Even I don't ask, you should ask me to save memory or not when you think it's needed.

---

Expand All @@ -23,23 +24,26 @@ I am a specialized software engineer with a distinct characteristic: my memory r
All files are stored under [productContext.md](mdc:.cursor/rules/memory/productContext.md), [progress.md](mdc:.cursor/rules/memory/progress.md), [specification.md](mdc:.cursor/rules/memory/specification.md) and `.cursor/memory/*`. The memory bank consists of mandatory core files and optional context files, all formatted in Markdown.

### Core Files (Mandatory)
1. **`productContext.md`**
1. **`productContext.md`** [productContext.md](mdc:.cursor/rules/memory/productContext.md)
- Explains the purpose of the project.
- Identifies the problem it solves.
- Describes expected functionality and user experience goals.

2. **`specification.md`**
2. **`specification.md`** [specification.md](mdc:.cursor/rules/memory/specification.md)
- Explains the detail of FlatCityBuf specification
- Describes its encoding strategy and decisions made

2. **`progress.md`**
3. **`progress.md`** [progress.md](mdc:.cursor/rules/memory/progress.md)
- Completed features and pending tasks.
- Current status.
- Known issues.

4. **`tdd-guideline`** [tdd-rust-guidelines.md](mdc:.cursor/rules/memory/tdd-rust-guidelines.md)
- Explains the guidline about Test Driven Development

### Additional Context Files

Additional files and folders can be created inside `memory-bank/` if they aid in organization:
Additional files and folders can be created inside `memory/rules/memory*` if they aid in organization:
- Documentation for complex features.
- Integration specifications.
- API documentation.
Expand Down
20 changes: 16 additions & 4 deletions .cursor/rules/memory/productContext.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,18 @@ async fn query_by_attribute(fcb_path: &str, field: &str, value: &str) -> Result<

### **12.4 HTTP Range Requests (JavaScript via WASM)**
```javascript
import { HttpFcbReader } from 'fcb_wasm';
import init, { HttpFcbReader, WasmAttrQuery } from './fcb_wasm.js';

async function loadFeaturesFromUrl(url) {
// Initialize WASM module
await init();

// Create HTTP reader
const reader = await FlatCityBufReader.fromUrl(url);
const reader = await new HttpFcbReader(url);
console.log('httpfcbreader instance created.');

// Get header information
const header = await reader.getHeader();
const header = await reader.header();
console.log(`loaded file with ${header.features_count} features`);

// Perform spatial query (only downloads necessary parts)
Expand All @@ -261,11 +265,19 @@ async function loadFeaturesFromUrl(url) {
max_x: 4.4, max_y: 52.1
};

const features = await reader.queryBbox(
// Call the select_bbox method
const iter = await reader.select_bbox(
bbox.min_x, bbox.min_y,
bbox.max_x, bbox.max_y
);

// Iterate through features
let features = [];
let feature;
while ((feature = await iter.next()) !== null) {
features.push(feature);
}

console.log(`downloaded ${features.length} features using range requests`);
return features;
}
Expand Down
64 changes: 64 additions & 0 deletions .cursor/rules/memory/tdd-rust-guidelines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

# Test-Driven Development (TDD) Basics in Rust

## Core Concepts

Test-Driven Development (TDD) follows this development cycle:

1. **Red**: Write a failing test first.
2. **Green**: Implement the minimum necessary code to pass the test.
3. **Refactor**: Improve the code while ensuring tests still pass.

## Key Principles

- **Tests define the specification**: Test code expresses the expected behavior of the implementation.
- **Follow the Arrange-Act-Assert pattern**:
1. **Arrange**: Set up the necessary test environment.
2. **Act**: Execute the functionality under test.
3. **Assert**: Verify the expected result.
- **Test names should follow a "Condition → Action → Expected Result" format**. Example:
- `"Given a valid token, retrieving user information should succeed"`

## Essential Tools for the Refactoring Phase

Once tests pass, use the following tools to refine your code:

### 1. **Static Analysis & Linting**
- Run `cargo check` for type checking and borrow checking.
- Use `cargo clippy` to detect potential issues and enforce best practices.

### 2. **Dead Code Detection & Removal**
- Run `cargo deadlinks` to check for dead documentation links.
- Use `cargo udeps` to find unused dependencies.
- Run `cargo rustc -- -W dead_code` to detect unused functions.

### 3. **Code Coverage Analysis**
- Install `cargo-tarpaulin` for test coverage measurement:
```bash
cargo install cargo-tarpaulin
cargo tarpaulin --out html
```
- Open the generated HTML report to review coverage.

### 4. **Version Control with Git**
- Commit after each phase (test creation → implementation → refactoring).
- Review changes before committing:
```bash
git status # Check modified files
git add <relevant files>
git commit -m "<appropriate commit message>"
```
- Use commit prefixes for clarity:
- `test:` - Adding or modifying tests
- `feat:` - Implementing new features
- `refactor:` - Code refactoring
Comment on lines +26 to +54
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix Markdown list indentation issues.

The current indentation of unordered lists doesn't follow standard Markdown formatting conventions, which is causing linting errors.

-### 1. **Static Analysis & Linting**
-   - Run `cargo check` for type checking and borrow checking.
-   - Use `cargo clippy` to detect potential issues and enforce best practices.
+### 1. **Static Analysis & Linting**
+- Run `cargo check` for type checking and borrow checking.
+- Use `cargo clippy` to detect potential issues and enforce best practices.

-### 2. **Dead Code Detection & Removal**
-   - Run `cargo deadlinks` to check for dead documentation links.
-   - Use `cargo udeps` to find unused dependencies.
-   - Run `cargo rustc -- -W dead_code` to detect unused functions.
+### 2. **Dead Code Detection & Removal**
+- Run `cargo deadlinks` to check for dead documentation links.
+- Use `cargo udeps` to find unused dependencies.
+- Run `cargo rustc -- -W dead_code` to detect unused functions.

-### 3. **Code Coverage Analysis**
-   - Install `cargo-tarpaulin` for test coverage measurement:
+### 3. **Code Coverage Analysis**
+- Install `cargo-tarpaulin` for test coverage measurement:

-### 4. **Version Control with Git**
-   - Commit after each phase (test creation → implementation → refactoring).
-   - Review changes before committing:
+### 4. **Version Control with Git**
+- Commit after each phase (test creation → implementation → refactoring).
+- Review changes before committing:

-   - Use commit prefixes for clarity:
-     - `test:` - Adding or modifying tests
-     - `feat:` - Implementing new features
-     - `refactor:` - Code refactoring
+- Use commit prefixes for clarity:
+  - `test:` - Adding or modifying tests
+  - `feat:` - Implementing new features
+  - `refactor:` - Code refactoring
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### 1. **Static Analysis & Linting**
- Run `cargo check` for type checking and borrow checking.
- Use `cargo clippy` to detect potential issues and enforce best practices.
### 2. **Dead Code Detection & Removal**
- Run `cargo deadlinks` to check for dead documentation links.
- Use `cargo udeps` to find unused dependencies.
- Run `cargo rustc -- -W dead_code` to detect unused functions.
### 3. **Code Coverage Analysis**
- Install `cargo-tarpaulin` for test coverage measurement:
```bash
cargo install cargo-tarpaulin
cargo tarpaulin --out html
```
- Open the generated HTML report to review coverage.
### 4. **Version Control with Git**
- Commit after each phase (test creation → implementation → refactoring).
- Review changes before committing:
```bash
git status # Check modified files
git add <relevant files>
git commit -m "<appropriate commit message>"
```
- Use commit prefixes for clarity:
- `test:` - Adding or modifying tests
- `feat:` - Implementing new features
- `refactor:` - Code refactoring
### 1. **Static Analysis & Linting**
- Run `cargo check` for type checking and borrow checking.
- Use `cargo clippy` to detect potential issues and enforce best practices.
### 2. **Dead Code Detection & Removal**
- Run `cargo deadlinks` to check for dead documentation links.
- Use `cargo udeps` to find unused dependencies.
- Run `cargo rustc -- -W dead_code` to detect unused functions.
### 3. **Code Coverage Analysis**
- Install `cargo-tarpaulin` for test coverage measurement:
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

27-27: Unordered list indentation
Expected: 0; Actual: 3

(MD007, ul-indent)


28-28: Unordered list indentation
Expected: 0; Actual: 3

(MD007, ul-indent)


31-31: Unordered list indentation
Expected: 0; Actual: 3

(MD007, ul-indent)


32-32: Unordered list indentation
Expected: 0; Actual: 3

(MD007, ul-indent)


33-33: Unordered list indentation
Expected: 0; Actual: 3

(MD007, ul-indent)


36-36: Unordered list indentation
Expected: 0; Actual: 3

(MD007, ul-indent)


41-41: Unordered list indentation
Expected: 0; Actual: 3

(MD007, ul-indent)


44-44: Unordered list indentation
Expected: 0; Actual: 3

(MD007, ul-indent)


45-45: Unordered list indentation
Expected: 0; Actual: 3

(MD007, ul-indent)


51-51: Unordered list indentation
Expected: 0; Actual: 3

(MD007, ul-indent)


52-52: Unordered list indentation
Expected: 2; Actual: 5

(MD007, ul-indent)


53-53: Unordered list indentation
Expected: 2; Actual: 5

(MD007, ul-indent)


54-54: Unordered list indentation
Expected: 2; Actual: 5

(MD007, ul-indent)


## Further Reading

For more details on TDD practices in Rust, naming conventions for tests, and best practices for refactoring, refer to:

```
.docs/tdd-rust-guidelines.md
```

This file includes step-by-step instructions for test-first development, structuring test cases, and leveraging Rust’s testing framework efficiently.
26 changes: 0 additions & 26 deletions .cursor/rules/mpc.md

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ src/rust/fcb_core/tests/data/
.cursorrules

*.fcb

.cursor/mcp.json
12 changes: 10 additions & 2 deletions src/rust/bst/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ edition = "2021"

[features]
default = ["http"]
http = ["packed_rtree"]
http = ["http-range-client", "async-trait", "bytes"]

[dependencies]
bincode = { workspace = true }
Expand All @@ -14,5 +14,13 @@ anyhow = { workspace = true }
chrono = { workspace = true }
ordered-float = { workspace = true }
once_cell = { workspace = true }
packed_rtree = { path = "../packed_rtree", optional = true }
thiserror = { workspace = true }
http-range-client = { workspace = true, optional = true, default-features = false }
async-trait = { workspace = true, optional = true }
bytes = { workspace = true, optional = true }

[dev-dependencies]
tokio = { workspace = true, features = ["rt", "macros"] }
async-trait = { workspace = true }
bytes = { workspace = true }
tempfile = "3.10.1"
Loading
Loading