Skip to content
This repository has been archived by the owner on May 11, 2020. It is now read-only.

Update to run on rust nightly 1.15.0 #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 4 additions & 8 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(duration_span)]

#[macro_use]
extern crate log;

Expand All @@ -9,7 +7,7 @@ extern crate linenoise;
extern crate llamadb;

use std::io::Write;
use std::time::Duration;
use std::time::Instant;

mod prettyselect;
use prettyselect::pretty_select;
Expand Down Expand Up @@ -82,12 +80,10 @@ fn execute_statement(out: &mut Write, db: &mut llamadb::tempdb::TempDb, statemen
{
use llamadb::tempdb::ExecuteStatementResponse;

let mut execute_result = None;
let now = Instant::now();
let execute_result = Some(db.execute_statement(statement));
let duration = now.elapsed();

let duration = Duration::span(|| {
execute_result = Some(db.execute_statement(statement));
});

let seconds = duration.as_secs() as f32 + (duration.subsec_nanos() as f32 * 1.0e-9);

let duration_string = format!("{:.3}s", seconds);
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(into_cow, associated_type_defaults)]
#![feature(associated_type_defaults)]

#[macro_use]
extern crate log;
Expand Down
11 changes: 5 additions & 6 deletions src/queryplan/execute/groupbuckets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ impl<ColumnValue: Clone + Eq + Hash + 'static> Group for GroupBucket<ColumnValue
type ColumnValue = ColumnValue;

fn get_any_row<'b>(&'b self) -> Option<Cow<'b, [ColumnValue]>> {
use std::borrow::IntoCow;

self.rows.iter().nth(0).map(|r| r.into_cow())
self.rows.iter().nth(0).map(|row| {
let row_ref: &[ColumnValue] = &row;
Cow::Borrowed(row_ref)
})
}

fn count(&self) -> u64 {
Expand All @@ -73,10 +74,8 @@ impl<ColumnValue: Clone + Eq + Hash + 'static> Group for GroupBucket<ColumnValue

fn iter<'a>(&'a self) -> Box<Iterator<Item=Cow<'a, [ColumnValue]>> + 'a> {
Box::new(self.rows.iter().map(|row| {
use std::borrow::IntoCow;

let row_ref: &[ColumnValue] = &row;
row_ref.into_cow()
Cow::Borrowed(row_ref)
}))
}
}
6 changes: 3 additions & 3 deletions src/queryplan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ where DB: 'a, <DB as DatabaseInfo>::Table: 'a
groups_info: &mut GroupsInfo)
-> Result<SExpression<'a, DB>, QueryPlanCompileError>
{
use std::borrow::IntoCow;
use std::borrow::Cow;

match ast {
ast::Expression::Ident(s) => {
Expand Down Expand Up @@ -718,13 +718,13 @@ where DB: 'a, <DB as DatabaseInfo>::Table: 'a
})
},
ast::Expression::StringLiteral(s) => {
match DB::ColumnValue::from_string_literal(s.into_cow()) {
match DB::ColumnValue::from_string_literal(Cow::Borrowed(&s)) {
Ok(value) => Ok(SExpression::Value(value)),
Err(s) => Err(QueryPlanCompileError::BadStringLiteral(s.into_owned()))
}
},
ast::Expression::Number(s) => {
match DB::ColumnValue::from_number_literal(s.into_cow()) {
match DB::ColumnValue::from_number_literal(Cow::Borrowed(&s)) {
Ok(value) => Ok(SExpression::Value(value)),
Err(s) => Err(QueryPlanCompileError::BadNumberLiteral(s.into_owned()))
}
Expand Down
6 changes: 3 additions & 3 deletions src/tempdb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<'a> Group for ScanGroup<'a> {

Box::new(table.rowid_index.iter().map(move |key_v| {
use byteutils;
use std::borrow::IntoCow;
use std::borrow::Cow;

let raw_key: &[u8] = &key_v;
trace!("KEY: {:?}", raw_key);
Expand Down Expand Up @@ -108,13 +108,13 @@ impl<'a> Group for ScanGroup<'a> {
let bytes = &raw_key[key_offset..key_offset + size];

trace!("from bytes: {:?}, {:?}", column.dbtype, bytes);
let value = ColumnValueOps::from_bytes(column.dbtype, bytes.into_cow()).unwrap();
let value = ColumnValueOps::from_bytes(column.dbtype, Cow::Borrowed(bytes)).unwrap();
key_offset += size;
value
}
}).collect();

v.into_cow()
Cow::Owned(v)
}))
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/types/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use byteutils;
use columnvalueops::ColumnValueOps;
use types::DbType;
use types::F64NoNaN;
use std::borrow::{Cow, IntoCow};
use std::borrow::Cow;
use std::fmt;

#[derive(Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
Expand Down Expand Up @@ -215,7 +215,7 @@ impl ColumnValueOps for Variant {
(Variant::Bytes(bytes), v) => {
// every variant can be converted from their byte representation
let r: &[u8] = &bytes;
match ColumnValueOps::from_bytes(v, r.into_cow()) {
match ColumnValueOps::from_bytes(v, Cow::Borrowed(r)) {
Ok(s) => Some(s),
Err(()) => None
}
Expand Down