Insert

The update function takes a record object notation and mutates the dataset to append lines.

the insert record stream asks for insert strategy and pipes it through insert tablet streams. insert tablet stream writes the records as lines at the end of the tablet. at the end of the record stream the tablet content is grouped to a valid form by sorting.

To learn more about the architecture of csvs, see other User Guides, the Reference and the Requirements.

insert in dataset

FS -> Dir -> List Entry -> IO List Entry

pipe each query 
  to insert stream
  to return

insert stream

FS -> Dir -> Entry -> IO List Entry

schema = select schema
for each entry
  strategy = insert strategy with schema, query
  for each tablet of strategy
    append insert tablet stream
for each tablet of strategy
  sort tablet
pipe query 
  to each insert tablet stream
  to return

test cases

  • duplicate
    • query: record 2001
    • initial: default
    • expected: duplicate
  • duplicate leaf
    • query: record 2001 edited
    • initial: default
    • expected: duplicate leaf
  • add
    • query: record added
    • initial: default
    • expected: added

insert strategy

Schema -> Entry -> List Tablet

This describes all tablets needed to delete an entry

base = entry._
crown = find crown with schema, base
for each branch of crown
  for each trunk of schema.branch.trunks
    return {
      filename: trunk-branch.csv,
      trunk: trunk,
      branch: branch,
    }

insert tablet stream

FS -> Dir -> Tablet -> Entry -> IO
Entry

filepath = dir/tablet.filename
// in order to start other tablet streams
enqueue entry 
grains = mow query with tablet.trunk, tablet.branch
for each grain
  append grain.key,grain.value to filepath