Skip to content
Snippets Groups Projects
Verified Commit e2bb7323 authored by Denis Smirnov's avatar Denis Smirnov
Browse files

refactoring: move duplicating code to a vtable method

parent 795ca021
1 merge request!1414sbroad import
......@@ -10,7 +10,6 @@ use crate::debug;
use crate::errors::QueryPlannerError;
use crate::executor::bucket::Buckets;
use crate::executor::ir::ExecutionPlan;
use crate::executor::vtable::VTableTuple;
use crate::ir::expression::Expression;
use crate::ir::operator::Relational;
use crate::ir::value::{EncodedValue, Value};
......@@ -163,22 +162,7 @@ impl ExecutionPlan {
}
SyntaxData::VTable(motion_id) => {
let vtable = self.get_motion_vtable(*motion_id)?;
let tuples: Vec<&VTableTuple> = match buckets {
Buckets::All => vtable.get_tuples().iter().collect(),
Buckets::Filtered(bucket_ids) => {
if vtable.get_index().is_empty() {
// TODO: Implement selection push-down (join_linker3_test).
vtable.get_tuples().iter().collect()
} else {
bucket_ids
.iter()
.filter_map(|bucket_id| vtable.get_index().get(bucket_id))
.flatten()
.filter_map(|pos| vtable.get_tuples().get(*pos))
.collect()
}
}
};
let tuples = (*vtable).get_tuples_with_buckets(buckets);
for t in tuples {
for v in t {
params.push(v.clone());
......@@ -364,22 +348,7 @@ impl ExecutionPlan {
.join(",")
};
let tuples: Vec<&VTableTuple> = match buckets {
Buckets::All => vtable.get_tuples().iter().collect(),
Buckets::Filtered(bucket_ids) => {
if vtable.get_index().is_empty() {
// TODO: Implement selection push-down (join_linker3_test).
vtable.get_tuples().iter().collect()
} else {
bucket_ids
.iter()
.filter_map(|bucket_id| vtable.get_index().get(bucket_id))
.flatten()
.filter_map(|pos| vtable.get_tuples().get(*pos))
.collect()
}
}
};
let tuples = (*vtable).get_tuples_with_buckets(buckets);
if tuples.is_empty() {
let values = (0..cols_count)
......@@ -417,7 +386,7 @@ impl ExecutionPlan {
})?;
for t in tuples {
for v in t {
for v in t.iter() {
params.push(v.clone());
}
}
......
......@@ -5,6 +5,7 @@ use std::vec;
use serde::{Deserialize, Serialize};
use crate::errors::QueryPlannerError;
use crate::executor::bucket::Buckets;
use crate::ir::relation::Column;
use crate::ir::transformation::redistribution::{MotionKey, Target};
use crate::ir::value::Value;
......@@ -129,6 +130,28 @@ impl VirtualTable {
self.index = index.into();
}
/// Get vtable's tuples corresponding to the buckets.
#[must_use]
pub fn get_tuples_with_buckets(&self, buckets: &Buckets) -> Vec<&VTableTuple> {
let tuples: Vec<&VTableTuple> = match buckets {
Buckets::All => self.get_tuples().iter().collect(),
Buckets::Filtered(bucket_ids) => {
if self.get_index().is_empty() {
// TODO: Implement selection push-down (join_linker3_test).
self.get_tuples().iter().collect()
} else {
bucket_ids
.iter()
.filter_map(|bucket_id| self.get_index().get(bucket_id))
.flatten()
.filter_map(|pos| self.get_tuples().get(*pos))
.collect()
}
}
};
tuples
}
/// Get virtual table tuples' values, participating in the distribution key.
///
/// # Errors
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment