Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support logical plan compilation #2648

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions datafusion/jit/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ impl FunctionBuilder {
}

/// Enter the function body at start the building.
pub fn enter_block(&mut self) -> CodeBlock {
pub fn enter_block(mut self) -> CodeBlock {
self.fields.push_back(HashMap::new());
CodeBlock {
fields: &mut self.fields,
state: &self.assembler_state,
fields: self.fields,
state: self.assembler_state,
stmts: vec![],
while_state: None,
if_state: None,
Expand Down Expand Up @@ -214,14 +214,14 @@ impl IfElseState {
}

/// Code block consists of statements and acts as anonymous namespace scope for items and variable declarations.
pub struct CodeBlock<'a> {
pub struct CodeBlock {
/// A stack that containing all defined variables so far. The variables defined
/// in the current block are at the top stack frame.
/// Fields provides a shadow semantics of the same name in outsider block, and are
/// used to guarantee type safety while constructing AST.
fields: &'a mut VecDeque<HashMap<String, JITType>>,
fields: VecDeque<HashMap<String, JITType>>,
/// The state of Assembler, used for type checking function calls.
state: &'a Arc<Mutex<AssemblerState>>,
state: Arc<Mutex<AssemblerState>>,
/// Holding all statements for the current code block.
stmts: Vec<Stmt>,
while_state: Option<WhileState>,
Expand All @@ -230,7 +230,7 @@ pub struct CodeBlock<'a> {
fn_state: Option<GeneratedFunction>,
}

impl<'a> CodeBlock<'a> {
impl CodeBlock {
pub fn build(&mut self) -> GeneratedFunction {
assert!(
self.fn_state.is_some(),
Expand All @@ -242,7 +242,7 @@ impl<'a> CodeBlock<'a> {
}

/// Leave the current block and returns the statements constructed.
fn leave(&mut self) -> Result<Stmt> {
pub fn leave(&mut self) -> Result<Stmt> {
self.fields.pop_back();
if let Some(ref mut while_state) = self.while_state {
let WhileState { condition } = while_state;
Expand Down Expand Up @@ -374,8 +374,8 @@ impl<'a> CodeBlock<'a> {
} else {
self.fields.push_back(HashMap::new());
Ok(CodeBlock {
fields: self.fields,
state: self.state,
fields: self.fields.clone(),
state: self.state.clone(),
stmts: vec![],
while_state: Some(WhileState { condition: cond }),
if_state: None,
Expand All @@ -391,8 +391,8 @@ impl<'a> CodeBlock<'a> {
} else {
self.fields.push_back(HashMap::new());
Ok(CodeBlock {
fields: self.fields,
state: self.state,
fields: self.fields.clone(),
state: self.state.clone(),
stmts: vec![],
while_state: None,
if_state: Some(IfElseState {
Expand Down
Loading