Skip to main content

QueryOp

Enum QueryOp 

Source
pub enum QueryOp {
Show 99 variants Match(Regex), Reject(Regex), Field(FieldSel), Each, Where(Expr), Map(Expr), Count, Rate, Tally, Sum, Min, Max, Avg, Keys, Vals, Pick(Vec<String>), Sort { numeric: bool, reverse: bool, }, Uniq, Rev, First, Last, Take(usize), Drop(usize), Upper, Lower, Trim, Replace(Regex, String), Join(String), Nth(usize), Sel { css: String, attr: Option<String>, }, Find(String), Attr(String), Text, SortBy(String), UniqueBy(String), CountBy(String), MinBy(String), MaxBy(String), Has(String), Entries, Flatten, Add, Over(f64), Under(f64), Between(f64, f64), Enumerate, Words, Dedup, Tailn(usize), Pad(usize), Lpad(usize), Grepf(String, Regex), Flip, Csv, B64, B64d, Hex, Unhex, Urlenc, Urldec, Extract(Regex), Split(String), Substr(usize, usize), Chars, Title, Repeat(usize), Set(String, String), Del(String), Rename(String, String), Default(String, String), Merge, Floor, Ceil, Clamp(f64, f64), Tsv, Yaml, Toml, Calc(Expr), Contains(String), Starts(String), Ends(String), Nonempty, Numeric, Len, Wc, Abs, Round, Prepend(String), Append(String), Cut(String, usize), Median, Stddev, P95, Range, Product, Distinct, Sample(usize), Slice(usize, usize), Bins(usize),
}

Variants§

§

Match(Regex)

Keep lines matching the pattern.

§

Reject(Regex)

Drop lines matching the pattern.

§

Field(FieldSel)

Replace each line with a selected field (whitespace column or JSON key path).

§

Each

Flatten JSON-array lines into one line per element (jq []); non-array lines pass through unchanged.

§

Where(Expr)

Keep lines whose numeric value (x = line parsed as a number) satisfies the predicate — compiled to fusevm and evaluated per line.

§

Map(Expr)

Replace each line with the value of an expression (field-aware; x = line-as-number), computed on the fusevm VM.

§

Count

Reduce to the current line count.

§

Rate

Reduce to lines-per-second over the elapsed window.

§

Tally

Group identical values and count them, sorted by count desc then key asc.

§

Sum

Numeric reductions over lines parsed as numbers (non-numeric ignored).

§

Min

§

Max

§

Avg

§

Keys

Flatten a JSON object’s keys / values into one line each.

§

Vals

§

Pick(Vec<String>)

Project a JSON object down to the named keys (jq {a,b,c} / pick(.a,.b,.c)), preserving the listed order. Non-object lines pass through unchanged; missing keys are dropped.

§

Sort

Line-list transforms. Sort supports numeric (-n) and reverse (-r).

Fields

§numeric: bool
§reverse: bool
§

Uniq

§

Rev

§

First

§

Last

§

Take(usize)

§

Drop(usize)

§

Upper

Per-line string transforms.

§

Lower

§

Trim

§

Replace(Regex, String)

Regex replace-all per line (replace /RE/ TO; TO may use $1 captures).

§

Join(String)

Collapse all lines into one, joined by a separator.

§

Nth(usize)

Keep only the Nth line (1-based).

§

Sel

Parse the accumulated stream as one HTML document and emit, per element matching the CSS selector, its text (or a named attribute if attr is set; elements lacking that attribute are dropped).

Fields

§

Find(String)

Recursive descent (xpath //TAG): parse the accumulated stream as one HTML document and emit the outer HTML of every element matching the selector, one per line — so attr/text can then pull from each.

§

Attr(String)

From element fragments (one per line, as emitted by find), emit the named attribute of each (xpath @NAME, css attr); drop lines whose first element lacks it.

§

Text

From element fragments, emit each element’s inner text; non-element lines pass through unchanged.

§

SortBy(String)

Stable-sort JSON-record lines by FIELD; numeric if every field value parses as a number, else lexicographic on the field’s string value. Non-object lines sink after the sorted records in input order.

§

UniqueBy(String)

Keep the first record for each distinct value of FIELD, preserving input order. JSON-object lines dedup by that field’s value; other lines dedup by the whole line.

§

CountBy(String)

Group JSON records by the value of FIELD and count each group, returning value -> count pairs sorted by count desc then value asc; non-object lines are counted under their whole-line text. Reducer (early return).

§

MinBy(String)

Reducer: emit the single JSON record whose numeric FIELD is smallest (records with a missing/non-numeric FIELD are ignored; empty input yields no lines).

§

MaxBy(String)

Reducer: emit the single record whose numeric FIELD is the largest.

§

Has(String)

Retain only JSON-object lines that contain KEY; all other lines (missing key, non-object, unparseable) are dropped.

§

Entries

jq to_entries: expand each JSON object line into one {"key":<k>,"value":<v>} line per key (BTreeMap key order); non-object lines pass through.

§

Flatten

For each JSON-array line, emit each element (via json_to_string); if an element is itself a JSON array, emit ITS elements instead (one level deeper than each). Non-array lines pass through unchanged.

§

Add

jq add: reduce a JSON array line to a single value — sum numeric arrays (fmt_num), concatenate non-numeric arrays via their string values, empty array -> “”. Non-array lines pass through unchanged.

§

Over(f64)

Keep only lines that parse as a number strictly greater than N. Lines that do not parse as f64 are dropped.

§

Under(f64)

Keep only numeric lines whose value is strictly less than N; drop non-numeric lines.

§

Between(f64, f64)

Keep numeric lines x where lo <= x <= hi (inclusive); non-numeric lines are dropped.

§

Enumerate

Prefix each line with its 1-based index and a tab: “1\t”.

§

Words

Split each line on whitespace and emit one word per line (flatten); empty lines produce nothing.

§

Dedup

Collapse runs of adjacent identical lines to a single line (classic uniq), leaving non-adjacent repeats intact.

§

Tailn(usize)

Keep only the last N lines (complement of take, which keeps the first N). N>=len keeps all.

§

Pad(usize)

Right-pad each line with spaces to a minimum visible width N (no truncation if the line is already longer).

§

Lpad(usize)

Left-pad each line with spaces to a minimum width of N (lines already >= N are unchanged).

§

Grepf(String, Regex)

Retain lines whose FIELD (json key or 1-based whitespace column) matches the regex.

§

Flip

Reverse the Unicode scalar characters of each line (chars().rev()).

§

Csv

Treat the stream as CSV: the first line is the header; each data row becomes a JSON object keyed by the header, so field NAME works.

§

B64

§

B64d

Base64-decode each line (STANDARD alphabet) into a UTF-8 string; lines that fail to base64-decode or whose bytes aren’t valid UTF-8 pass through unchanged.

§

Hex

Lowercase hex-encode each line, two hex digits per UTF-8 byte.

§

Unhex

Decode a hex string to UTF-8 text by parsing byte pairs; on any error (odd length, non-hex digit, invalid UTF-8) the line is left unchanged.

§

Urlenc

Percent-encode each line, escaping every non-alphanumeric byte (RFC 3986 style).

§

Urldec

Percent-decode each line to UTF-8 (utf8_percent_decode); lines whose decoded bytes are not valid UTF-8 pass through unchanged.

§

Extract(Regex)

Emit the first regex match per line (capture group 1 if the pattern captures, else the whole match); drop lines with no match.

§

Split(String)

Explode each line by the literal string DELIM into multiple lines (one part per line). One-to-many: unlike cut (one field) or words (whitespace), every split segment becomes its own line.

§

Substr(usize, usize)

Character substring [A,B) 0-based, clamped to the line length (B may exceed len; A>B yields empty).

§

Chars

Explode each line into one output line per Unicode scalar (character); one line -> many.

§

Title

Title-case each line: uppercase the first letter of each whitespace-separated word, lowercase the rest, rejoin with single spaces.

§

Repeat(usize)

Replace each line with its content repeated N times, concatenated.

§

Set(String, String)

Set key K to the string value V (Value::String(V)) in each JSON object line; non-object / unparseable lines pass through unchanged.

§

Del(String)

Remove key K from each JSON object line (jq del(.K)); non-object lines pass through.

§

Rename(String, String)

Rename JSON object key OLD to NEW in each object, preserving the value; no-op if OLD absent. Non-object lines pass through.

§

Default(String, String)

Set string key K to V only when K is absent from the JSON object (jq //= for a missing key). Present keys keep their value; non-object / unparseable lines pass through unchanged. Key order is normalized on mutation.

§

Merge

Reduce all JSON object lines into a single object (later keys overwrite earlier); non-object lines are ignored. Emits one JSON object line, or none if no objects were seen.

§

Floor

Floor each numeric line to the nearest lower integer (fmt_num(x.floor())); non-numeric lines pass through unchanged.

§

Ceil

Round each numeric line up to the nearest integer (ceil); non-numeric lines pass through unchanged.

§

Clamp(f64, f64)

Clamp each numeric line into the inclusive range [LO, HI]; non-numeric lines pass through unchanged.

§

Tsv

Same as Csv but tab-separated (TSV).

§

Yaml

Parse the accumulated stream as a YAML document (or ----separated multi-document) and emit each document as a JSON line, so the JSON verbs (field/pick/keys/each) work over it (the yq leg).

§

Toml

Parse the accumulated stream as one TOML document and emit it as a JSON object line.

§

Calc(Expr)

Reduce to a scalar computed by an arithmetic expression over the current line count (x), evaluated on the fusevm VM.

§

Contains(String)

keep lines containing a literal substring.

§

Starts(String)

keep lines starting with a literal prefix.

§

Ends(String)

keep lines ending with a literal suffix.

§

Nonempty

drop empty / whitespace-only lines.

§

Numeric

keep only lines that parse as a number.

§

Len

replace each line with its character count.

§

Wc

replace each line with its word count.

§

Abs

absolute value of each numeric line.

§

Round

round each numeric line to the nearest integer.

§

Prepend(String)

prefix every line with a literal string.

§

Append(String)

suffix every line with a literal string.

§

Cut(String, usize)

split each line by DELIM, keep the Nth (1-based) field.

§

Median

median of numeric lines.

§

Stddev

population standard deviation of numeric lines.

§

P95

95th percentile (nearest-rank) of numeric lines.

§

Range

max minus min of numeric lines.

§

Product

product of numeric lines.

§

Distinct

count of distinct lines.

§

Sample(usize)

keep every Nth line (1-based).

§

Slice(usize, usize)

keep lines from index A to B inclusive (1-based).

§

Bins(usize)

bucket numeric lines into N equal-width ranges -> (range, count) pairs.

Trait Implementations§

Source§

impl Clone for QueryOp

Source§

fn clone(&self) -> QueryOp

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for QueryOp

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more