-
-
Notifications
You must be signed in to change notification settings - Fork 163
each Keyword in Oil
andychu edited this page May 30, 2019
·
15 revisions
- Up: Structured Data in Oil
- Related: TSV2 Proposal
Idea:
cat tasks.tsv2 | each (...) {
run-task $name $age
}
# extract 2 of 4 columns, assert that there are 4
cat tasks.tsv2 | each (_, name Str, age Int, _) {
run-task $name $age
}
Idea for ad-hoc data with no schema. This is useful because argv aren't typed!!!
tasks() {
# note no header line:
echo $'one\t000'
echo $'two\t555'
}
tasks | each [name age] { run-task $name $age }
- how do you specify parallelism?
cat tasks.tsv2 | each -parallel 4 (...) {
echo $name $age
}
Is that hard to parse?
each --verbose
or each --ui
-- show progress! Enable cancellation?
-
What is xargs -P? And When is it Useful? -- a 5 minute presentation.
- Solution when each process has non-trivial setup time: Coprocess Protocol Proposal
Instead of:
tasks() {
echo $'name\tage:int'
echo $'one\t000'
echo $'two x\t555'
}
In Oil you could write:
proc tasks {
tsv2-row name age:int
tsv2-row one 000
tsv2-row 'two x' 555
}
It's just a nicer syntax.