fiddle with changes in borrow types since rusqlite changed their api
This commit is contained in:
parent
cdfd1f6b30
commit
5596873e8f
2 changed files with 26 additions and 26 deletions
|
@ -80,9 +80,9 @@ impl Projector for ScalarTwoStagePullProjector {
|
||||||
fn project<'stmt, 's>(&self, schema: &Schema, sqlite: &'s rusqlite::Connection, mut rows: Rows<'stmt>) -> Result<QueryOutput> {
|
fn project<'stmt, 's>(&self, schema: &Schema, sqlite: &'s rusqlite::Connection, mut rows: Rows<'stmt>) -> Result<QueryOutput> {
|
||||||
// Scalar is pretty straightforward -- zero or one entity, do the pull directly.
|
// Scalar is pretty straightforward -- zero or one entity, do the pull directly.
|
||||||
let results =
|
let results =
|
||||||
if let Some(r) = rows.next() {
|
if let Some(r) = rows.next().unwrap() {
|
||||||
let row = r?;
|
let row = r;
|
||||||
let entity: Entid = row.get(0); // This will always be 0 and a ref.
|
let entity: Entid = row.get(0).unwrap(); // This will always be 0 and a ref.
|
||||||
let bindings = self.puller.pull(schema, sqlite, once(entity))?;
|
let bindings = self.puller.pull(schema, sqlite, once(entity))?;
|
||||||
let m = Binding::Map(bindings.get(&entity).cloned().unwrap_or_else(Default::default));
|
let m = Binding::Map(bindings.get(&entity).cloned().unwrap_or_else(Default::default));
|
||||||
QueryResults::Scalar(Some(m))
|
QueryResults::Scalar(Some(m))
|
||||||
|
@ -120,14 +120,14 @@ impl TupleTwoStagePullProjector {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is exactly the same as for rel.
|
// This is exactly the same as for rel.
|
||||||
fn collect_bindings<'a>(&self, row: Row<'a>) -> Result<Vec<Binding>> {
|
fn collect_bindings<'a>(&self, row: &Row<'a>) -> Result<Vec<Binding>> {
|
||||||
// There will be at least as many SQL columns as Datalog columns.
|
// There will be at least as many SQL columns as Datalog columns.
|
||||||
// gte 'cos we might be querying extra columns for ordering.
|
// gte 'cos we might be querying extra columns for ordering.
|
||||||
// The templates will take care of ignoring columns.
|
// The templates will take care of ignoring columns.
|
||||||
assert!(row.column_count() >= self.len);
|
assert!(row.column_count() >= self.len);
|
||||||
self.templates
|
self.templates
|
||||||
.iter()
|
.iter()
|
||||||
.map(|ti| ti.lookup(&row))
|
.map(|ti| ti.lookup(row))
|
||||||
.collect::<Result<Vec<Binding>>>()
|
.collect::<Result<Vec<Binding>>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,8 +141,8 @@ impl TupleTwoStagePullProjector {
|
||||||
impl Projector for TupleTwoStagePullProjector {
|
impl Projector for TupleTwoStagePullProjector {
|
||||||
fn project<'stmt, 's>(&self, schema: &Schema, sqlite: &'s rusqlite::Connection, mut rows: Rows<'stmt>) -> Result<QueryOutput> {
|
fn project<'stmt, 's>(&self, schema: &Schema, sqlite: &'s rusqlite::Connection, mut rows: Rows<'stmt>) -> Result<QueryOutput> {
|
||||||
let results =
|
let results =
|
||||||
if let Some(r) = rows.next() {
|
if let Some(r) = rows.next().unwrap() {
|
||||||
let row = r?;
|
let row = r;
|
||||||
|
|
||||||
// Keeping the compiler happy.
|
// Keeping the compiler happy.
|
||||||
let pull_consumers: Result<Vec<PullConsumer>> = self.pulls
|
let pull_consumers: Result<Vec<PullConsumer>> = self.pulls
|
||||||
|
@ -152,14 +152,14 @@ impl Projector for TupleTwoStagePullProjector {
|
||||||
let mut pull_consumers = pull_consumers?;
|
let mut pull_consumers = pull_consumers?;
|
||||||
|
|
||||||
// Collect the usual bindings and accumulate entity IDs for pull.
|
// Collect the usual bindings and accumulate entity IDs for pull.
|
||||||
for mut p in pull_consumers.iter_mut() {
|
for p in pull_consumers.iter_mut() {
|
||||||
p.collect_entity(&row);
|
p.collect_entity(&row);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut bindings = self.collect_bindings(row)?;
|
let mut bindings = self.collect_bindings(row)?;
|
||||||
|
|
||||||
// Run the pull expressions for the collected IDs.
|
// Run the pull expressions for the collected IDs.
|
||||||
for mut p in pull_consumers.iter_mut() {
|
for p in pull_consumers.iter_mut() {
|
||||||
p.pull(sqlite)?;
|
p.pull(sqlite)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ impl RelTwoStagePullProjector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_bindings_into<'a>(&self, row: Row<'a>, out: &mut Vec<Binding>) -> Result<()> {
|
fn collect_bindings_into<'a>(&self, row: &Row<'a>, out: &mut Vec<Binding>) -> Result<()> {
|
||||||
// There will be at least as many SQL columns as Datalog columns.
|
// There will be at least as many SQL columns as Datalog columns.
|
||||||
// gte 'cos we might be querying extra columns for ordering.
|
// gte 'cos we might be querying extra columns for ordering.
|
||||||
// The templates will take care of ignoring columns.
|
// The templates will take care of ignoring columns.
|
||||||
|
@ -249,16 +249,16 @@ impl Projector for RelTwoStagePullProjector {
|
||||||
let mut pull_consumers = pull_consumers?;
|
let mut pull_consumers = pull_consumers?;
|
||||||
|
|
||||||
// Collect the usual bindings and accumulate entity IDs for pull.
|
// Collect the usual bindings and accumulate entity IDs for pull.
|
||||||
while let Some(r) = rows.next() {
|
while let Some(r) = rows.next().unwrap() {
|
||||||
let row = r?;
|
let row = r;
|
||||||
for mut p in pull_consumers.iter_mut() {
|
for p in pull_consumers.iter_mut() {
|
||||||
p.collect_entity(&row);
|
p.collect_entity(&row);
|
||||||
}
|
}
|
||||||
self.collect_bindings_into(row, &mut values)?;
|
self.collect_bindings_into(row, &mut values)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the pull expressions for the collected IDs.
|
// Run the pull expressions for the collected IDs.
|
||||||
for mut p in pull_consumers.iter_mut() {
|
for p in pull_consumers.iter_mut() {
|
||||||
p.pull(sqlite)?;
|
p.pull(sqlite)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,8 +311,8 @@ impl Projector for CollTwoStagePullProjector {
|
||||||
fn project<'stmt, 's>(&self, schema: &Schema, sqlite: &'s rusqlite::Connection, mut rows: Rows<'stmt>) -> Result<QueryOutput> {
|
fn project<'stmt, 's>(&self, schema: &Schema, sqlite: &'s rusqlite::Connection, mut rows: Rows<'stmt>) -> Result<QueryOutput> {
|
||||||
let mut pull_consumer = PullConsumer::for_operation(schema, &self.pull)?;
|
let mut pull_consumer = PullConsumer::for_operation(schema, &self.pull)?;
|
||||||
|
|
||||||
while let Some(r) = rows.next() {
|
while let Some(r) = rows.next().unwrap() {
|
||||||
let row = r?;
|
let row = r;
|
||||||
pull_consumer.collect_entity(&row);
|
pull_consumer.collect_entity(&row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,8 +58,8 @@ impl ScalarProjector {
|
||||||
impl Projector for ScalarProjector {
|
impl Projector for ScalarProjector {
|
||||||
fn project<'stmt, 's>(&self, _schema: &Schema, _sqlite: &'s rusqlite::Connection, mut rows: Rows<'stmt>) -> Result<QueryOutput> {
|
fn project<'stmt, 's>(&self, _schema: &Schema, _sqlite: &'s rusqlite::Connection, mut rows: Rows<'stmt>) -> Result<QueryOutput> {
|
||||||
let results =
|
let results =
|
||||||
if let Some(r) = rows.next() {
|
if let Some(r) = rows.next().unwrap() {
|
||||||
let row = r?;
|
let row = r;
|
||||||
let binding = self.template.lookup(&row)?;
|
let binding = self.template.lookup(&row)?;
|
||||||
QueryResults::Scalar(Some(binding))
|
QueryResults::Scalar(Some(binding))
|
||||||
} else {
|
} else {
|
||||||
|
@ -93,7 +93,7 @@ impl TupleProjector {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is just like we do for `rel`, but into a vec of its own.
|
// This is just like we do for `rel`, but into a vec of its own.
|
||||||
fn collect_bindings<'a>(&self, row: Row<'a>) -> Result<Vec<Binding>> {
|
fn collect_bindings<'a>(&self, row: &Row<'a>) -> Result<Vec<Binding>> {
|
||||||
// There will be at least as many SQL columns as Datalog columns.
|
// There will be at least as many SQL columns as Datalog columns.
|
||||||
// gte 'cos we might be querying extra columns for ordering.
|
// gte 'cos we might be querying extra columns for ordering.
|
||||||
// The templates will take care of ignoring columns.
|
// The templates will take care of ignoring columns.
|
||||||
|
@ -114,8 +114,8 @@ impl TupleProjector {
|
||||||
impl Projector for TupleProjector {
|
impl Projector for TupleProjector {
|
||||||
fn project<'stmt, 's>(&self, _schema: &Schema, _sqlite: &'s rusqlite::Connection, mut rows: Rows<'stmt>) -> Result<QueryOutput> {
|
fn project<'stmt, 's>(&self, _schema: &Schema, _sqlite: &'s rusqlite::Connection, mut rows: Rows<'stmt>) -> Result<QueryOutput> {
|
||||||
let results =
|
let results =
|
||||||
if let Some(r) = rows.next() {
|
if let Some(r) = rows.next().unwrap() {
|
||||||
let row = r?;
|
let row = r;
|
||||||
let bindings = self.collect_bindings(row)?;
|
let bindings = self.collect_bindings(row)?;
|
||||||
QueryResults::Tuple(Some(bindings))
|
QueryResults::Tuple(Some(bindings))
|
||||||
} else {
|
} else {
|
||||||
|
@ -151,7 +151,7 @@ impl RelProjector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_bindings_into<'a>(&self, row: Row<'a>, out: &mut Vec<Binding>) -> Result<()> {
|
fn collect_bindings_into<'a>(&self, row: &Row<'a>, out: &mut Vec<Binding>) -> Result<()> {
|
||||||
// There will be at least as many SQL columns as Datalog columns.
|
// There will be at least as many SQL columns as Datalog columns.
|
||||||
// gte 'cos we might be querying extra columns for ordering.
|
// gte 'cos we might be querying extra columns for ordering.
|
||||||
// The templates will take care of ignoring columns.
|
// The templates will take care of ignoring columns.
|
||||||
|
@ -188,8 +188,8 @@ impl Projector for RelProjector {
|
||||||
let width = self.len;
|
let width = self.len;
|
||||||
let mut values: Vec<_> = Vec::with_capacity(5 * width);
|
let mut values: Vec<_> = Vec::with_capacity(5 * width);
|
||||||
|
|
||||||
while let Some(r) = rows.next() {
|
while let Some(r) = rows.next().unwrap() {
|
||||||
let row = r?;
|
let row = r;
|
||||||
self.collect_bindings_into(row, &mut values)?;
|
self.collect_bindings_into(row, &mut values)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,8 +236,8 @@ impl CollProjector {
|
||||||
impl Projector for CollProjector {
|
impl Projector for CollProjector {
|
||||||
fn project<'stmt, 's>(&self, _schema: &Schema, _sqlite: &'s rusqlite::Connection, mut rows: Rows<'stmt>) -> Result<QueryOutput> {
|
fn project<'stmt, 's>(&self, _schema: &Schema, _sqlite: &'s rusqlite::Connection, mut rows: Rows<'stmt>) -> Result<QueryOutput> {
|
||||||
let mut out: Vec<_> = vec![];
|
let mut out: Vec<_> = vec![];
|
||||||
while let Some(r) = rows.next() {
|
while let Some(r) = rows.next().unwrap() {
|
||||||
let row = r?;
|
let row = r;
|
||||||
let binding = self.template.lookup(&row)?;
|
let binding = self.template.lookup(&row)?;
|
||||||
out.push(binding);
|
out.push(binding);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue