{"record":{"id":"c74f9b6dc17019aa","repo":"quickwit-oss/quickwit","slug":"storekey-encode-value","errorCode":null,"errorMessage":"storekey encode value: {}","messagePattern":"storekey encode value: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"quickwit/quickwit-parquet-engine/src/sorted_series/mod.rs","lineNumber":294,"sourceCode":"/// columns the *value* bytes are inverted in place (NOT the ordinal\n/// byte) so memcmp on the composite reverses the value's lex order\n/// while ordinals stay in declared order. Caller skips this function\n/// entirely for null columns — the next column's higher ordinal byte\n/// then appears in this column's place, which gives nulls-last\n/// ordering without a sentinel marker (matches the writer's\n/// `nulls_first=false` convention).\npub(crate) fn append_prefix_col_to_key<T>(\n    buf: &mut Vec<u8>,\n    ordinal: u8,\n    value: &T,\n    descending: bool,\n) -> Result<()>\nwhere\n    T: ?Sized + storekey::Encode,\n{\n    storekey::encode(&mut *buf, &ordinal).map_err(|e| anyhow!(\"storekey encode ordinal: {}\", e))?;\n    let value_start = buf.len();\n    storekey::encode(&mut *buf, value).map_err(|e| anyhow!(\"storekey encode value: {}\", e))?;\n    if descending {\n        invert_bytes(&mut buf[value_start..]);\n    }\n    Ok(())\n}\n\n/// Bitwise-NOT a byte slice in place, inverting the sort order for\n/// descending columns in the composite key. This is the standard\n/// ordered-code technique: if ascending bytes A < B, then !A > !B,\n/// so memcmp on the inverted bytes gives descending order.\nfn invert_bytes(bytes: &mut [u8]) {\n    for byte in bytes.iter_mut() {\n        *byte = !*byte;\n    }\n}\n\n/// Extract a string value from a column at the given row.\n///","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/quickwit-oss/quickwit/blob/a39730c5cdcd1a4fe798403737ae293999ea21f8/quickwit/quickwit-parquet-engine/src/sorted_series/mod.rs#L276-L312","documentation":"This error fires when storekey fails to encode the value portion (a generic T: ?Sized + storekey::Encode, e.g. a byte array or prefix-column value) into the row-key buffer. The ordinal was already encoded successfully; the failure is specific to serializing the value. Bytes are optionally byte-inverted afterwards for descending sort order.","triggerScenarios":"Calling encode_byte_array_value or encode_prefix_col_value with a value whose storekey::Encode implementation fails — unsupported value type, encoding limit exceeded, or a writer error on the buffer.","commonSituations":"Encoding string/byte-array sort values into compound row keys in quickwit-parquet-engine; passing a value type not covered by the storekey encoder's registered impls.","solutions":["Inspect the wrapped storekey error to see why the value failed to encode","Confirm the value type implements storekey::Encode and is one the engine supports (byte arrays/strings)","Check value length constraints — very large values may exceed encoder limits","Verify identical storekey versions in Cargo.lock across workspace crates"],"exampleFix":"// before\nstorekey::encode(&mut *buf, value).map_err(|e| anyhow!(\"storekey encode value: {}\", e))?;\n// after: validate first\nif let Some(max) = MAX_VALUE_LEN { ensure!(value.len() <= max, \"row-key value too long: {}\", value.len()); }\nstorekey::encode(&mut *buf, value).map_err(|e| anyhow!(\"storekey encode value: {}\", e))?;","handlingStrategy":"validation","validationCode":"let _ = storekey::encode(&mut Vec::new(), value).map_err(|e| format!(\"value not encodable: {e}\"))?;","typeGuard":null,"tryCatchPattern":"if let Err(e) = encode_byte_array_value(&mut buf, ordinal, value, descending) {\n    if e.to_string().contains(\"encode value\") { /* record value type/len for diagnosis */ }\n}","preventionTips":["Validate value length and type before encoding row keys","Add round-trip tests for all value types used in sort schemas","Avoid very large values in compound keys"],"tags":["serialization","rust","storekey","row-key"],"backgroundTag":"internal-invariant-violation","analyzedSha":"a39730c5cdcd1a4fe798403737ae293999ea21f8","analyzedAt":"2026-09-08T13:19:37.784Z","contentChangedAt":"2026-09-08T13:19:37.784Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}