MCPcopy Index your code
hub / github.com/tanelpoder/0xtools / __init__

Method __init__

xtop/core/query_engine.py:89–118  ·  view source on GitHub ↗

Initialize with data source

(self, data_source: XCaptureDataSource, use_materialized: bool = False, duckdb_profiling_mode: Optional[str] = None)

Source from the content-addressed store, hash-verified

87 }
88
89 def __init__(self, data_source: XCaptureDataSource, use_materialized: bool = False, duckdb_profiling_mode: Optional[str] = None):
90 """Initialize with data source"""
91 self.data_source = data_source
92 self.query_cache = {}
93 # Get the SQL directory relative to this file
94 self.template_path = Path(__file__).parent.parent / 'sql'
95 self.fragments_path = self.template_path / 'fragments'
96 self.logger = logging.getLogger('xtop.query_engine')
97
98 # Initialize the new query builder
99 self.query_builder = QueryBuilder(
100 datadir=data_source.datadir,
101 fragments_path=self.fragments_path,
102 use_materialized=use_materialized
103 )
104
105 # Initialize materializer
106 self.materializer = DataMaterializer(data_source.conn, data_source.datadir)
107 self.use_materialized = use_materialized
108 # Desired DuckDB profiling mode when debug logging is enabled
109 # Accepts 'standard', 'query_tree', or 'json' (DuckDB options). Defaults to 'standard'.
110 self.duckdb_profiling_mode = (duckdb_profiling_mode or 'standard').lower()
111
112 # Cache for schema information
113 self.schema_cache: Dict[str, List[Tuple[str, str]]] = {}
114 self._discover_all_schemas()
115 try:
116 self.query_builder.set_schema_info(self.data_source.get_schema_info())
117 except Exception as exc:
118 self.logger.warning(f"Failed to share schema info with QueryBuilder: {exc}")
119
120 # Removed load_template method - no longer needed with only dynamic queries
121

Callers

nothing calls this directly

Calls 5

_discover_all_schemasMethod · 0.95
QueryBuilderClass · 0.85
DataMaterializerClass · 0.85
set_schema_infoMethod · 0.80
get_schema_infoMethod · 0.80

Tested by

no test coverage detected