Skip to content

Commit

Permalink
rustup
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntSushi committed Jan 4, 2015
1 parent 6aa1b2f commit 1ba8bff
Show file tree
Hide file tree
Showing 25 changed files with 89 additions and 83 deletions.
32 changes: 16 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/cmd/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Common options:
Must be a single character. (default: ,)
";

#[deriving(RustcDecodable)]
#[derive(RustcDecodable)]
struct Args {
cmd_rows: bool,
cmd_columns: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Common options:
Must be a single character. (default: ,)
";

#[deriving(RustcDecodable)]
#[derive(RustcDecodable)]
struct Args {
arg_input: Option<String>,
flag_no_headers: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/fixlengths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Common options:
Must be a single character. (default: ,)
";

#[deriving(RustcDecodable)]
#[derive(RustcDecodable)]
struct Args {
arg_input: Option<String>,
flag_length: Option<uint>,
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Common options:
Must be a single character. (default: ,)
";

#[deriving(RustcDecodable)]
#[derive(RustcDecodable)]
struct Args {
arg_input: Option<String>,
flag_condense: Option<uint>,
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Common options:
Must be a single character. (default: ,)
";

#[deriving(RustcDecodable)]
#[derive(RustcDecodable)]
struct Args {
arg_input: Option<String>,
flag_out_delimiter: Option<Delimiter>,
Expand Down
15 changes: 7 additions & 8 deletions src/cmd/frequency.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::io::{mod, File};
use std::io::{self, File};
use std::iter::range;
use std::os;

use csv::{mod, ByteString};
use csv::{self, ByteString};
use csv::index::Indexed;
use stats::{Frequencies, merge_all};

Expand Down Expand Up @@ -59,7 +59,7 @@ Common options:
Must be a single character. (default: ,)
";

#[deriving(Clone, RustcDecodable)]
#[derive(Clone, RustcDecodable)]
struct Args {
arg_input: Option<String>,
flag_select: SelectColumns,
Expand Down Expand Up @@ -136,8 +136,8 @@ impl Args {

fn parallel_ftables(&self, idx: &mut Indexed<io::File, io::File>)
-> CliResult<(Headers, FTables)> {
use std::comm::channel;
use std::sync::TaskPool;
use std::sync::mpsc::channel;

let mut rdr = try!(self.rconfig().reader());
let (headers, sel) = try!(self.sel_headers(&mut rdr));
Expand All @@ -157,16 +157,15 @@ impl Args {
let mut idx = args.rconfig().indexed().unwrap().unwrap();
idx.seek((i * chunk_size) as u64).unwrap();
let it = idx.csv().byte_records().take(chunk_size);
send.send(args.ftables(&sel, it).unwrap());
send.send(args.ftables(&sel, it).unwrap()).unwrap();
});
}
drop(send);
Ok((headers, merge_all(recv.iter()).unwrap()))
}

fn ftables<I: Iterator<csv::CsvResult<ByteRow>>>
(&self, sel: &Selection, mut it: I)
-> CliResult<FTables> {
fn ftables<I>(&self, sel: &Selection, mut it: I) -> CliResult<FTables>
where I: Iterator<Item=csv::CsvResult<ByteRow>> {
let null = ByteString::from_bytes(b"");
let nsel = sel.normal();
let mut tabs: Vec<_> =
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Common options:
Must be a single character. (default: ,)
";

#[deriving(RustcDecodable)]
#[derive(RustcDecodable)]
struct Args {
arg_input: Vec<String>,
flag_just_names: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Common options:
Must be a single character. (default: ,)
";

#[deriving(RustcDecodable)]
#[derive(RustcDecodable)]
struct Args {
arg_input: String,
flag_output: Option<String>,
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/join.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::io;
use std::iter::repeat;
use std::str;

use csv::{mod, ByteString};
use csv::{self, ByteString};
use csv::index::Indexed;

use CliResult;
Expand Down Expand Up @@ -69,7 +69,7 @@ Common options:
Must be a single character. (default: ,)
";

#[deriving(RustcDecodable)]
#[derive(RustcDecodable)]
struct Args {
arg_columns1: SelectColumns,
arg_input1: String,
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/sample.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::rand::Rng;

use csv::{mod, ByteString};
use csv::{self, ByteString};
use csv::index::Indexed;

use CliResult;
Expand Down Expand Up @@ -37,7 +37,7 @@ Common options:
Must be a single character. (default: ,)
";

#[deriving(RustcDecodable)]
#[derive(RustcDecodable)]
struct Args {
arg_input: Option<String>,
arg_sample_size: u64,
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Common options:
Must be a single character. (default: ,)
";

#[deriving(RustcDecodable)]
#[derive(RustcDecodable)]
struct Args {
arg_input: Option<String>,
arg_regex: String,
Expand Down
8 changes: 5 additions & 3 deletions src/cmd/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Common options:
Must be a single character. (default: ,)
";

#[deriving(RustcDecodable)]
#[derive(RustcDecodable)]
struct Args {
arg_input: Option<String>,
arg_selection: SelectColumns,
Expand All @@ -42,12 +42,14 @@ pub fn run(argv: &[&str]) -> CliResult<()> {
let sel = try!(rconfig.selection(headers[]));

if !rconfig.no_headers {
try!(wtr.write(sel.select(headers[])));
try!(wtr.write(sel.as_slice().iter().map(|&i| headers[i].as_slice())));
}
for r in rdr.byte_records() {
// TODO: I don't think we can do any better here. Since selection
// operates on indices, some kind of allocation is probably required.
try!(wtr.write(sel.select(try!(r)[])))
// try!(wtr.write(sel.select(try!(r)[])))
let r = try!(r);
try!(wtr.write(sel.as_slice().iter().map(|&i| r[i].as_slice())));
}
try!(wtr.flush());
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Common options:
Must be a single character. (default: ,)
";

#[deriving(RustcDecodable)]
#[derive(RustcDecodable)]
struct Args {
arg_input: Option<String>,
flag_start: Option<uint>,
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Common options:
Must be a single character. (default: ,)
";

#[deriving(RustcDecodable)]
#[derive(RustcDecodable)]
struct Args {
arg_input: Option<String>,
flag_select: SelectColumns,
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Common options:
Must be a single character. (default: ,)
";

#[deriving(Clone, RustcDecodable)]
#[derive(Clone, RustcDecodable)]
struct Args {
arg_input: Option<String>,
arg_outdir: String,
Expand Down Expand Up @@ -85,8 +85,8 @@ impl Args {

fn parallel_split(&self, idx: Indexed<io::File, io::File>)
-> CliResult<()> {
use std::comm::channel;
use std::sync::TaskPool;
use std::sync::mpsc::channel;

let nchunks = util::num_of_chunks(idx.count() as uint, self.flag_size);
let pool = TaskPool::new(self.njobs());
Expand All @@ -107,7 +107,7 @@ impl Args {
wtr.write(row.into_iter()).unwrap();
}
wtr.flush().unwrap();
tx.send(());
tx.send(()).unwrap();
});
}
drop(tx);
Expand Down
Loading

0 comments on commit 1ba8bff

Please sign in to comment.