Skip to content

Commit c33152a

Browse files
konardclaude
andcommitted
Fix Transaction implementation to properly delegate to Client
The Transaction wrapper was a stub that didn't actually perform any database operations: - create_links: returned empty handler without creating anything - delete_links: always returned Err(NotExists) without checking DB This caused the delete benchmark to panic with NotExists(4000) because: 1. Neo4j_NonTransaction completed successfully (used real Client) 2. Neo4j_Transaction failed immediately (used broken stub) Solution: - Made Client's CypherResponse types and execute_cypher method public - Added public accessor methods for Client fields - Rewrote Transaction to delegate all operations to underlying Client Now both Transaction and NonTransaction benchmarks use the same Neo4j HTTP API, providing meaningful comparison data. Fixes #3 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent dec6d65 commit c33152a

File tree

2 files changed

+286
-42
lines changed

2 files changed

+286
-42
lines changed

rust/src/client.rs

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,65 @@ struct Statement {
3434
parameters: Option<Value>,
3535
}
3636

37+
/// Response from Neo4j Cypher query
3738
#[derive(Debug, Deserialize)]
38-
struct CypherResponse {
39-
results: Vec<QueryResult>,
39+
pub struct CypherResponse {
40+
pub results: Vec<QueryResult>,
4041
#[serde(default)]
41-
errors: Vec<CypherError>,
42+
pub errors: Vec<CypherError>,
4243
}
4344

45+
/// Result from a single Cypher query statement
4446
#[derive(Debug, Deserialize)]
45-
struct QueryResult {
47+
pub struct QueryResult {
4648
#[serde(default)]
4749
#[allow(dead_code)]
48-
columns: Vec<String>,
50+
pub columns: Vec<String>,
4951
#[serde(default)]
50-
data: Vec<RowData>,
52+
pub data: Vec<RowData>,
5153
}
5254

55+
/// A single row of data from a Cypher query
5356
#[derive(Debug, Deserialize)]
54-
struct RowData {
55-
row: Vec<Value>,
57+
pub struct RowData {
58+
pub row: Vec<Value>,
5659
}
5760

61+
/// Error returned from Neo4j
5862
#[derive(Debug, Deserialize)]
59-
struct CypherError {
63+
pub struct CypherError {
6064
#[allow(dead_code)]
61-
code: String,
65+
pub code: String,
6266
#[allow(dead_code)]
63-
message: String,
67+
pub message: String,
6468
}
6569

6670
impl<T: LinkType> Client<T> {
71+
/// Get the host for this client
72+
pub fn host(&self) -> &str {
73+
&self.host
74+
}
75+
76+
/// Get the port for this client
77+
pub fn port(&self) -> u16 {
78+
self.port
79+
}
80+
81+
/// Get the auth header for this client
82+
pub fn auth(&self) -> &str {
83+
&self.auth
84+
}
85+
86+
/// Get the constants for this client
87+
pub fn constants(&self) -> &LinksConstants<T> {
88+
&self.constants
89+
}
90+
91+
/// Get and increment the next_id atomically
92+
pub fn fetch_next_id(&self) -> i64 {
93+
self.next_id.fetch_add(1, Ordering::SeqCst)
94+
}
95+
6796
pub fn new(uri: &str, user: &str, password: &str) -> Result<Self> {
6897
// Parse URI to extract host and port
6998
let uri = uri.replace("bolt://", "").replace("http://", "");
@@ -118,7 +147,8 @@ impl<T: LinkType> Client<T> {
118147
Ok(client)
119148
}
120149

121-
fn execute_cypher(&self, query: &str, params: Option<Value>) -> Result<CypherResponse> {
150+
/// Execute a Cypher query against Neo4j
151+
pub fn execute_cypher(&self, query: &str, params: Option<Value>) -> Result<CypherResponse> {
122152
let request = CypherRequest {
123153
statements: vec![Statement {
124154
statement: query.to_string(),

0 commit comments

Comments
 (0)