Skip to content

Commit 9b2fab1

Browse files
committed
rustfmt
1 parent d3fa0ac commit 9b2fab1

File tree

5 files changed

+45
-32
lines changed

5 files changed

+45
-32
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ mod schema;
2020
mod soup_backend;
2121
mod utils;
2222

23-
pub use soup_backend::SoupBackend;
2423
pub use schema::Schema;
24+
pub use soup_backend::SoupBackend;

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ use std::sync::atomic::AtomicUsize;
3333
use std::sync::{Arc, RwLock};
3434
use std::thread;
3535

36-
use soup_backend::SoupBackend;
3736
use schema::Schema;
37+
use soup_backend::SoupBackend;
3838

3939
// Just give me a damn terminal logger
4040
// Duplicated from distributary, as the API subcrate doesn't export it.

src/rewrite.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
use nom_sql::{Column, ConditionBase, ConditionExpression, ConditionTree, CreateTableStatement,
2-
CreateViewStatement, FieldDefinitionExpression, FieldValueExpression, Literal,
3-
Operator, SelectSpecification, SelectStatement, SqlQuery};
1+
use nom_sql::{
2+
Column, ConditionBase, ConditionExpression, ConditionTree, CreateTableStatement,
3+
CreateViewStatement, FieldDefinitionExpression, FieldValueExpression, Literal, Operator,
4+
SelectSpecification, SelectStatement, SqlQuery,
5+
};
46

57
use std::collections::HashMap;
68
use std::mem;
@@ -67,7 +69,8 @@ pub(crate) fn expand_stars(sq: &mut SelectStatement, table_schemas: &HashMap<Str
6769
.into_iter()
6870
.flat_map(|field| match field {
6971
FieldDefinitionExpression::All => {
70-
let v: Vec<_> = sq.tables
72+
let v: Vec<_> = sq
73+
.tables
7174
.iter()
7275
.map(|t| t.name.clone())
7376
.flat_map(&expand_table)

src/schema.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
use msql_srv;
2-
use nom_sql::{self, ColumnConstraint, CreateTableStatement, CreateViewStatement,
3-
FieldDefinitionExpression, FieldValueExpression, InsertStatement, Literal,
4-
SelectSpecification, SelectStatement, SqlQuery, SqlType};
2+
use nom_sql::{
3+
self, ColumnConstraint, CreateTableStatement, CreateViewStatement, FieldDefinitionExpression,
4+
FieldValueExpression, InsertStatement, Literal, SelectSpecification, SelectStatement, SqlQuery,
5+
SqlType,
6+
};
57

68
use std::collections::HashMap;
79

src/soup_backend.rs

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
use distributary::{ControllerHandle, DataType, Table, View, ZookeeperAuthority};
22

33
use msql_srv::{self, *};
4-
use nom_sql::{self, ColumnConstraint, InsertStatement, Literal, SelectSpecification,
5-
SelectStatement, SqlQuery, UpdateStatement};
4+
use nom_sql::{
5+
self, ColumnConstraint, InsertStatement, Literal, SelectSpecification, SelectStatement,
6+
SqlQuery, UpdateStatement,
7+
};
68

79
use slog;
810
use std::borrow::Cow;
@@ -56,12 +58,14 @@ impl SoupBackendInner {
5658
let mut ch = ControllerHandle::new(zk_auth).unwrap();
5759

5860
let soup = SoupBackendInner {
59-
inputs: ch.inputs()
61+
inputs: ch
62+
.inputs()
6063
.expect("couldn't get inputs from Soup")
6164
.into_iter()
6265
.map(|(n, _)| (n.clone(), ch.table(&n).unwrap()))
6366
.collect::<BTreeMap<String, Table>>(),
64-
outputs: ch.outputs()
67+
outputs: ch
68+
.outputs()
6569
.expect("couldn't get outputs from Soup")
6670
.into_iter()
6771
.map(|(n, _)| (n.clone(), ch.view(&n).unwrap()))
@@ -84,10 +88,9 @@ impl SoupBackendInner {
8488

8589
fn get_or_make_getter<'a, 'b>(&'a mut self, view: &'b str) -> &'a mut View {
8690
let soup = &mut self.soup;
87-
self.outputs.entry(view.to_owned()).or_insert_with(|| {
88-
soup.view(view)
89-
.expect(&format!("no view named '{}'", view))
90-
})
91+
self.outputs
92+
.entry(view.to_owned())
93+
.or_insert_with(|| soup.view(view).expect(&format!("no view named '{}'", view)))
9194
}
9295
}
9396

@@ -197,7 +200,8 @@ impl SoupBackend {
197200
self.log,
198201
"Adding view \"{}\" to Soup as {}", q.definition, q.name
199202
);
200-
match self.inner
203+
match self
204+
.inner
201205
.soup
202206
.extend_recipe(&format!("{}: {};", q.name, q.definition))
203207
{
@@ -216,7 +220,8 @@ impl SoupBackend {
216220
q: nom_sql::DeleteStatement,
217221
results: QueryResultWriter<W>,
218222
) -> io::Result<()> {
219-
let cond = q.where_clause
223+
let cond = q
224+
.where_clause
220225
.expect("only supports DELETEs with WHERE-clauses");
221226

222227
let ts = self.table_schemas.read().unwrap();
@@ -263,7 +268,8 @@ impl SoupBackend {
263268
q: nom_sql::InsertStatement,
264269
results: QueryResultWriter<W>,
265270
) -> io::Result<()> {
266-
let data: Vec<Vec<DataType>> = q.data
271+
let data: Vec<Vec<DataType>> = q
272+
.data
267273
.iter()
268274
.map(|row| row.iter().map(|v| DataType::from(v)).collect())
269275
.collect();
@@ -373,7 +379,8 @@ impl SoupBackend {
373379
if let Some(qname) = gc.get(q) {
374380
qname.clone()
375381
} else {
376-
let qc = self.query_count
382+
let qc = self
383+
.query_count
377384
.fetch_add(1, sync::atomic::Ordering::SeqCst);
378385
let qname = format!("q_{}", qc);
379386

@@ -389,7 +396,8 @@ impl SoupBackend {
389396
"Adding ad-hoc query \"{}\" to Soup as {}", q, qname
390397
);
391398
}
392-
if let Err(e) = self.inner
399+
if let Err(e) = self
400+
.inner
393401
.soup
394402
.extend_recipe(&format!("QUERY {}: {};", qname, q))
395403
{
@@ -909,13 +917,15 @@ impl<W: io::Write> MysqlShim<W> for SoupBackend {
909917

910918
let query_lc = query.to_lowercase();
911919

912-
if query_lc.starts_with("begin") || query_lc.starts_with("start transaction")
920+
if query_lc.starts_with("begin")
921+
|| query_lc.starts_with("start transaction")
913922
|| query_lc.starts_with("commit")
914923
{
915924
return results.completed(0, 0);
916925
}
917926

918-
if query_lc.starts_with("show databases") || query_lc.starts_with("rollback")
927+
if query_lc.starts_with("show databases")
928+
|| query_lc.starts_with("rollback")
919929
|| query_lc.starts_with("alter table")
920930
|| query_lc.starts_with("create index")
921931
|| query_lc.starts_with("create unique index")
@@ -929,14 +939,12 @@ impl<W: io::Write> MysqlShim<W> for SoupBackend {
929939
}
930940

931941
if query_lc.starts_with("show tables") {
932-
let cols = [
933-
Column {
934-
table: String::from(""),
935-
column: String::from("Tables"),
936-
coltype: ColumnType::MYSQL_TYPE_STRING,
937-
colflags: ColumnFlags::empty(),
938-
},
939-
];
942+
let cols = [Column {
943+
table: String::from(""),
944+
column: String::from("Tables"),
945+
coltype: ColumnType::MYSQL_TYPE_STRING,
946+
colflags: ColumnFlags::empty(),
947+
}];
940948
// TODO(malte): we actually know what tables exist via self.table_schemas, so
941949
// return them here
942950
let writer = results.start(&cols)?;

0 commit comments

Comments
 (0)