Skip to content

Commit c84fc47

Browse files
authored
chore: cleanup query related logic and simplify code (#596)
1 parent d935c17 commit c84fc47

File tree

18 files changed

+26
-707
lines changed

18 files changed

+26
-707
lines changed

python/cocoindex/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Cocoindex is a framework for building and running indexing pipelines.
33
"""
44

5-
from . import functions, query, sources, storages, cli, utils
5+
from . import functions, sources, storages, cli, utils
66

77
from .auth_registry import AuthEntryReference, add_auth_entry, ref_auth_entry
88
from .flow import FlowBuilder, DataScope, DataSlice, Flow, transform_flow

python/cocoindex/lib.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import Callable, Any
77

88
from . import _engine # type: ignore
9-
from . import flow, query, setting
9+
from . import flow, setting
1010
from .convert import dump_engine_object
1111

1212

@@ -24,7 +24,6 @@ def init(settings: setting.Settings | None = None) -> None:
2424
def start_server(settings: setting.ServerSettings) -> None:
2525
"""Start the cocoindex server."""
2626
flow.ensure_all_flows_built()
27-
query.ensure_all_handlers_built()
2827
_engine.start_server(settings.__dict__)
2928

3029

python/cocoindex/query.py

Lines changed: 0 additions & 115 deletions
This file was deleted.

src/builder/analyzer.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,8 +1066,8 @@ impl AnalyzerContext<'_> {
10661066
let export_target_factory = export_op_group.target_factory.clone();
10671067
Ok(async move {
10681068
trace!("Start building executor for export op `{op_name}`");
1069-
let executors = data_coll_output
1070-
.executors
1069+
let export_context = data_coll_output
1070+
.export_context
10711071
.await
10721072
.with_context(|| format!("Analyzing export op: {op_name}"))?;
10731073
trace!("Finished building executor for export op `{op_name}`");
@@ -1076,8 +1076,7 @@ impl AnalyzerContext<'_> {
10761076
target_id,
10771077
input: data_fields_info.local_collector_ref,
10781078
export_target_factory,
1079-
export_context: executors.export_context,
1080-
query_target: executors.query_target,
1079+
export_context,
10811080
primary_key_def: data_fields_info.primary_key_def,
10821081
primary_key_type: data_fields_info.primary_key_type,
10831082
value_fields: data_fields_info.value_fields_idx,

src/builder/plan.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ pub struct AnalyzedExportOp {
103103
pub input: AnalyzedLocalCollectorReference,
104104
pub export_target_factory: Arc<dyn ExportTargetFactory + Send + Sync>,
105105
pub export_context: Arc<dyn Any + Send + Sync>,
106-
pub query_target: Option<Arc<dyn QueryTarget>>,
107106
pub primary_key_def: AnalyzedPrimaryKeyDef,
108107
pub primary_key_type: schema::ValueType,
109108
/// idx for value fields - excluding the primary key field.

src/execution/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pub(crate) mod dumper;
33
pub(crate) mod evaluator;
44
pub(crate) mod indexing_status;
55
pub(crate) mod memoization;
6-
pub(crate) mod query;
76
pub(crate) mod row_indexer;
87
pub(crate) mod source_indexer;
98
pub(crate) mod stats;

src/execution/query.rs

Lines changed: 0 additions & 124 deletions
This file was deleted.

src/lib_context.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
use crate::prelude::*;
22

3+
use crate::builder::AnalyzedFlow;
34
use crate::execution::source_indexer::SourceIndexingContext;
45
use crate::service::error::ApiError;
56
use crate::settings;
67
use crate::setup;
7-
use crate::{builder::AnalyzedFlow, execution::query::SimpleSemanticsQueryHandler};
88
use axum::http::StatusCode;
9-
use sqlx::postgres::PgConnectOptions;
109
use sqlx::PgPool;
10+
use sqlx::postgres::PgConnectOptions;
1111
use std::collections::BTreeMap;
1212
use tokio::runtime::Runtime;
1313

1414
pub struct FlowContext {
1515
pub flow: Arc<AnalyzedFlow>,
1616
pub source_indexing_contexts: Vec<tokio::sync::OnceCell<Arc<SourceIndexingContext>>>,
17-
pub query_handlers: Mutex<BTreeMap<String, Arc<SimpleSemanticsQueryHandler>>>,
1817
}
1918

2019
impl FlowContext {
@@ -26,7 +25,6 @@ impl FlowContext {
2625
Self {
2726
flow,
2827
source_indexing_contexts,
29-
query_handlers: Mutex::new(BTreeMap::new()),
3028
}
3129
}
3230

@@ -43,20 +41,6 @@ impl FlowContext {
4341
})
4442
.await
4543
}
46-
47-
pub fn get_query_handler(&self, name: &str) -> Result<Arc<SimpleSemanticsQueryHandler>> {
48-
let query_handlers = self.query_handlers.lock().unwrap();
49-
let query_handler = query_handlers
50-
.get(name)
51-
.ok_or_else(|| {
52-
ApiError::new(
53-
&format!("Query handler not found: {name}"),
54-
StatusCode::NOT_FOUND,
55-
)
56-
})?
57-
.clone();
58-
Ok(query_handler)
59-
}
6044
}
6145

6246
static TOKIO_RUNTIME: LazyLock<Runtime> = LazyLock::new(|| Runtime::new().unwrap());

src/ops/factory_bases.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,8 @@ impl<T: SimpleFunctionFactoryBase> SimpleFunctionFactory for T {
265265
}
266266
}
267267

268-
pub struct TypedExportTargetExecutors<F: StorageFactoryBase + ?Sized> {
269-
pub export_context: Arc<F::ExportContext>,
270-
pub query_target: Option<Arc<dyn QueryTarget>>,
271-
}
272-
273268
pub struct TypedExportDataCollectionBuildOutput<F: StorageFactoryBase + ?Sized> {
274-
pub executors: BoxFuture<'static, Result<TypedExportTargetExecutors<F>>>,
269+
pub export_context: BoxFuture<'static, Result<Arc<F::ExportContext>>>,
275270
pub setup_key: F::Key,
276271
pub desired_setup_state: F::SetupState,
277272
}
@@ -400,12 +395,8 @@ impl<T: StorageFactoryBase> ExportTargetFactory for T {
400395
.into_iter()
401396
.map(|d| {
402397
Ok(interface::ExportDataCollectionBuildOutput {
403-
executors: async move {
404-
let executors = d.executors.await?;
405-
Ok(interface::ExportTargetExecutors {
406-
export_context: executors.export_context,
407-
query_target: executors.query_target,
408-
})
398+
export_context: async move {
399+
Ok(d.export_context.await? as Arc<dyn Any + Send + Sync>)
409400
}
410401
.boxed(),
411402
setup_key: serde_json::to_value(d.setup_key)?,

0 commit comments

Comments
 (0)