pub struct QueryCorrelator {
pub left_prefix: Option<String>,
pub right_prefix: Option<String>,
}Expand description
Query result correlator for joining data from multiple databases
Enables joining and correlating query results from different databases using common keys, similar to SQL JOINs but across distributed databases.
§Example
use rust_logic_graph::multi_db::{QueryCorrelator, JoinStrategy};
use serde_json::json;
let mut correlator = QueryCorrelator::new();
// Data from OMS database
let users = json!([
{"user_id": 1, "name": "Alice"},
{"user_id": 2, "name": "Bob"},
]);
// Data from Orders database
let orders = json!([
{"order_id": 101, "user_id": 1, "amount": 50.0},
{"order_id": 102, "user_id": 1, "amount": 75.0},
{"order_id": 103, "user_id": 3, "amount": 100.0},
]);
let result = correlator.join(
&users,
&orders,
"user_id",
"user_id",
JoinStrategy::Inner
).unwrap();
println!("Joined {} rows", result.as_array().unwrap().len());Fields§
§left_prefix: Option<String>Optional prefix for disambiguating column names from left dataset
right_prefix: Option<String>Optional prefix for disambiguating column names from right dataset
Implementations§
Source§impl QueryCorrelator
impl QueryCorrelator
Sourcepub fn with_left_prefix(self, prefix: impl Into<String>) -> Self
pub fn with_left_prefix(self, prefix: impl Into<String>) -> Self
Set prefix for left dataset columns (e.g., “user_”)
Sourcepub fn with_right_prefix(self, prefix: impl Into<String>) -> Self
pub fn with_right_prefix(self, prefix: impl Into<String>) -> Self
Set prefix for right dataset columns (e.g., “order_”)
Sourcepub fn join(
&self,
left: &Value,
right: &Value,
left_key: &str,
right_key: &str,
strategy: JoinStrategy,
) -> Result<Value, RustLogicGraphError>
pub fn join( &self, left: &Value, right: &Value, left_key: &str, right_key: &str, strategy: JoinStrategy, ) -> Result<Value, RustLogicGraphError>
Join two datasets on specified keys
§Arguments
left- Left dataset (JSON array of objects)right- Right dataset (JSON array of objects)left_key- Key field name in left datasetright_key- Key field name in right datasetstrategy- Join strategy (Inner, Left, Right, Full)
§Returns
JSON array containing joined rows
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QueryCorrelator
impl RefUnwindSafe for QueryCorrelator
impl Send for QueryCorrelator
impl Sync for QueryCorrelator
impl Unpin for QueryCorrelator
impl UnwindSafe for QueryCorrelator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more