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

Class QueryEngine

xtop/core/query_engine.py:41–779  ·  view source on GitHub ↗

Processes SQL queries against xcapture data

Source from the content-addressed store, hash-verified

39
40
41class QueryEngine:
42 """Processes SQL queries against xcapture data"""
43
44 # Default group columns - now only one set for dynamic queries (all lowercase)
45 DEFAULT_GROUP_COLS = {
46 'dynamic': ['state', 'username', 'comm2', 'syscall', 'filenamesum']
47 }
48
49 # Map of data sources to their fragment files and dependencies
50 DATA_SOURCES = {
51 'samples': {
52 'fragment': 'get_samples.sql',
53 'alias': 'samples',
54 'depends_on': [],
55 'is_base': True
56 },
57 'syscend': {
58 'fragment': 'get_syscend.sql',
59 'alias': 'sc',
60 'depends_on': [],
61 'is_base': False
62 },
63 'iorqend': {
64 'fragment': 'get_iorqend.sql',
65 'alias': 'io',
66 'depends_on': [],
67 'is_base': False
68 },
69 'kstacks': {
70 'fragment': 'get_kstacks.sql',
71 'alias': 'ks',
72 'depends_on': [],
73 'is_base': False
74 },
75 'ustacks': {
76 'fragment': 'get_ustacks.sql',
77 'alias': 'us',
78 'depends_on': [],
79 'is_base': False
80 },
81 'partitions': {
82 'fragment': 'get_partitions.sql',
83 'alias': 'part',
84 'depends_on': ['iorqend'], # Requires iorqend for dev_maj/dev_min
85 'is_base': False
86 }
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

Calls

no outgoing calls

Tested by 2

test_query_executionFunction · 0.72