MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / parse_command

Function parse_command

src/clusterd-test-driver/src/text.rs:427–518  ·  view source on GitHub ↗

Parse one command block (directive line plus indentation-structured body).

(input: &str)

Source from the content-addressed store, hash-verified

425
426/// Parse one command block (directive line plus indentation-structured body).
427fn parse_command(input: &str) -> anyhow::Result<Command> {
428 let lines = lex(input);
429 let (header, body) = lines.split_first().context("empty command")?;
430 ensure!(header.indent == 0, "directive must not be indented");
431 let (verb, args, flags) = parse_header(&header.text)?;
432 let command = match verb.as_str() {
433 "define-schema" => Command::DefineSchema {
434 name: req(&args, "name")?.to_string(),
435 columns: columns_from_body(body)?,
436 },
437 "write-single-ts" => Command::WriteSingleTs {
438 shard: req(&args, "shard")?.to_string(),
439 schema: opt_string(&args, "schema"),
440 ts: req_u64(&args, "ts")?,
441 count: req_u64(&args, "count")?,
442 start: opt_u64(&args, "start")?.unwrap_or(0),
443 row_bytes: opt_usize(&args, "row-bytes")?,
444 },
445 "write-spread" => Command::WriteSpread {
446 shard: req(&args, "shard")?.to_string(),
447 schema: opt_string(&args, "schema"),
448 count: req_u64(&args, "count")?,
449 n_ts: req_u64(&args, "n-ts")?,
450 start: opt_u64(&args, "start")?.unwrap_or(0),
451 row_bytes: opt_usize(&args, "row-bytes")?,
452 },
453 "write-rows" => Command::WriteRows {
454 shard: req(&args, "shard")?.to_string(),
455 schema: opt_string(&args, "schema"),
456 ts: req_u64(&args, "ts")?,
457 rows: rows_from_body(body)?,
458 },
459 "define-index" => Command::DefineIndex {
460 source_id: req_u64(&args, "source")?,
461 index_id: req_u64(&args, "index")?,
462 shard: req(&args, "shard")?.to_string(),
463 schema: opt_string(&args, "schema"),
464 key: parse_usize_list(req(&args, "key")?)?,
465 as_of: req_u64(&args, "as-of")?,
466 upper: req_u64(&args, "upper")?,
467 },
468 "schedule" => Command::Schedule {
469 id: req_u64(&args, "id")?,
470 },
471 "allow-compaction" => Command::AllowCompaction {
472 id: req_u64(&args, "id")?,
473 frontier: req_u64(&args, "frontier")?,
474 },
475 "allow-writes" => Command::AllowWrites {
476 id: req_u64(&args, "id")?,
477 },
478 "await-frontier" => Command::AwaitFrontier {
479 id: req_u64(&args, "id")?,
480 ts: req_u64(&args, "ts")?,
481 timeout_secs: opt_u64(&args, "timeout-secs")?,
482 allow_timeout: flags.iter().any(|f| f == "allow-timeout"),
483 },
484 "count" => Command::Count {

Callers 7

parse_fileFunction · 0.85
parses_simple_commandFunction · 0.85
parses_flag_and_listFunction · 0.85
parses_bodiesFunction · 0.85
parses_sink_export_kindsFunction · 0.85
parses_await_subscribeFunction · 0.85

Calls 15

parse_headerFunction · 0.85
columns_from_bodyFunction · 0.85
opt_stringFunction · 0.85
req_u64Function · 0.85
opt_u64Function · 0.85
opt_usizeFunction · 0.85
rows_from_bodyFunction · 0.85
parse_usize_listFunction · 0.85
parse_create_dataflowFunction · 0.85
settings_from_bodyFunction · 0.85
anyMethod · 0.80
lexFunction · 0.70

Tested by

no test coverage detected