How mainak9093/asterdb works
AsterDB is a single-threaded, in-memory analytical SQL engine. Its principal workflow accepts SQL, parses and binds it, optimizes a logical plan, plans and executes a batch-oriented operator tree, then returns results. A separate LOAD path reads CSV tables into the session catalog. The README also documents selection-vector filtering, dictionary-encoded strings, configurable optimizer rewrites, EXPLAIN, and selectable hash or nested-loop joins. Some operator and storage implementations were not excerpted; edges to them are limited to planner references or documented behavior.
Main entry points: main.cpp Session dispatch · planner.cpp Physical planner · catalog.cpp Table catalog · column.cpp Column storage
Components 24
Session interface
- Session dispatch
src/main.cpp
SQL planning
- Lexer
src/parser/lexer.cpp - SQL parser
src/parser/parser.cpp - Name binder
src/optimizer/binder.cpp - Logical plan
src/optimizer/logical_plan.cpp - Rewrite rules
src/optimizer/rules.cpp
Query execution
- Physical planner
src/execution/planner.cpp - Operator executor
src/execution/executor.cpp - Sequential scan
src/execution/seq_scan.cpp - Filter operator
src/execution/filter_op.cpp - Join operators
src/execution/join_op.cpp - Hash aggregate
src/execution/hash_aggregate.cpp - Projection
src/execution/project_op.cpp - Sort
src/execution/sort_op.cpp - Limit
src/execution/limit_op.cpp - Materialization
src/execution/materialize.cpp
Columnar storage
- CSV reader
src/storage/csv_reader.cpp - Table catalog
src/storage/catalog.cpp - Columnar tables
src/storage/table.cpp - Column storage
src/storage/column.cpp - Filter kernel
src/storage/filter_kernel.cpp - String dictionary
src/storage/dictionary.cpp
Shared runtime
- Types and status
include/common/types.h
Other components
- SQL user
Connections 28
- SQL user → Session dispatch: submits SQL
README.md - Session dispatch → SQL parser: parses SQL
src/main.cpp - SQL parser → Lexer: tokenizes input
src/parser/parser.cpp - Session dispatch → Name binder: binds statement
src/main.cpp - Name binder → Logical plan: builds plan
src/optimizer/binder.cpp - Session dispatch → Rewrite rules: optimizes plan
src/main.cpp - Rewrite rules → Logical plan: rewrites plan
src/optimizer/rules.cpp - Session dispatch → Physical planner: plans query
src/main.cpp - Physical planner → Sequential scan: creates operators
src/execution/planner.cpp - Physical planner → Filter operator: creates operators
src/execution/planner.cpp - Physical planner → Join operators: creates operators
src/execution/planner.cpp - Physical planner → Hash aggregate: creates operators
src/execution/planner.cpp - Physical planner → Projection: creates operators
src/execution/planner.cpp - Physical planner → Sort: creates operators
src/execution/planner.cpp - Physical planner → Limit: creates operators
src/execution/planner.cpp - Session dispatch → Operator executor: executes tree
src/main.cpp - Operator executor → Types and status: returns result status
- Session dispatch → CSV reader: loads CSV
src/main.cpp - Session dispatch → Table catalog: registers table
src/main.cpp - CSV reader → Columnar tables: builds table
- Table catalog → Columnar tables: stores tables
- Sequential scan → Table catalog: reads table
- Filter operator → Filter kernel: filters columns
- Filter kernel → Column storage: reads column data
- Column storage → String dictionary: encodes strings
- Join operators → Materialization: drains child rows
- Materialization → Column storage: builds output columns
- Hash aggregate → Types and status: uses SQL types