xiaohongshu
xiaohongshu
Implement and deserialize all CQL types including primitives (int, text, timestamp, uuid, varint, decimal), collections (list, set, map), tuples, UDTs (user-defined types), and frozen types. Use when working with CQL type deserialization, schema validation, collection parsing, UDT handling, or ty...
Full skill instructions
This skill provides guidance on implementing Cassandra CQL type system with schema-provided deserialization.
Per PRD: schema passed in, not inferred
// Schema provides type information
fn deserialize_cell(
data: &[u8],
column_type: &CqlType, // From schema
) -> Result<CqlValue>
Never try to infer type from data alone - always use schema.
boolean - 1 byte (0x00 or 0x01)tinyint - 1 byte signedsmallint - 2 bytes signed, big-endianint - 4 bytes signed, big-endianbigint - 8 bytes signed, big-endianfloat - 4 bytes IEEE 754double - 8 bytes IEEE 754date - 4 bytes (days since epoch)time - 8 bytes (nanoseconds since midnight)text/varchar - UTF-8 encoded stringblob - raw bytesascii - ASCII-only stringuuid/timeuuid - 16 bytesinet - 4 bytes (IPv4) or 16 bytes (IPv6)varint - variable-length big integerdecimal - scale (4 bytes) + unscaled varintduration - months, days, nanoseconds (3 VInts)timestamp - 8 bytes (milliseconds since Unix epoch)See collections-and-udts.md for detailed format.
Collection Format:
[4 bytes: element_count (big-endian)]
[for each element:]
[4 bytes: element_size (big-endian)]
[bytes: element_data]
Types:
list<T> - Ordered, allows duplicatesset<T> - Unordered, no duplicatesmap<K,V> - Key-value pairsFormat:
[element_1_data]
[element_2_data]
...
No size prefix - elements serialized back-to-back. Each element uses its type's serialization.
Format:
[for each field in schema order:]
[4 bytes: field_size (-1 for null, 0 for empty, >0 for data)]
[if size > 0:]
[bytes: field_data]
UDT schema defines field names and types.
Frozen types:
Non-frozen collections:
use bytes::Bytes;
fn deserialize_text(data: Bytes) -> Result<String> {
// Zero-copy: validate UTF-8 then wrap
let s = std::str::from_utf8(&data)?;
Ok(s.to_string()) // Only copy if needed
}
fn deserialize_blob(data: Bytes) -> Result<Bytes> {
// Zero-copy: just return the slice
Ok(data)
}
fn deserialize_length_prefixed(data: &[u8]) -> Result<(Bytes, &[u8])> {
if data.len() < 4 {
return Err(Error::NotEnoughBytes);
}
let size = i32::from_be_bytes([data[0], data[1], data[2], data[3]]);
if size < 0 {
return Ok((Bytes::new(), &data[4..])); // Null
}
let size = size as usize;
if data.len() < 4 + size {
return Err(Error::NotEnoughBytes);
}
let value = Bytes::copy_from_slice(&data[4..4 + size]);
let remaining = &data[4 + size..];
Ok((value, remaining))
}
fn deserialize_list(
data: &[u8],
element_type: &CqlType,
) -> Result<Vec<CqlValue>> {
let count = i32::from_be_bytes([data[0], data[1], data[2], data[3]]) as usize;
let mut offset = 4;
let mut elements = Vec::with_capacity(count);
for _ in 0..count {
let (element_data, remaining) = deserialize_length_prefixed(&data[offset..])?;
let element = deserialize_value(&element_data, element_type)?;
elements.push(element);
offset = data.len() - remaining.len();
}
Ok(elements)
}
system_schema.tables, system_schema.columnsstruct TableSchema {
keyspace: String,
table: String,
partition_keys: Vec<ColumnDef>,
clustering_keys: Vec<ColumnDef>,
regular_columns: Vec<ColumnDef>,
static_columns: Vec<ColumnDef>,
}
struct ColumnDef {
name: String,
cql_type: CqlType,
}
enum CqlType {
// Primitives
Boolean,
Int,
BigInt,
Text,
Uuid,
Timestamp,
// ... more primitives
// Collections
List(Box<CqlType>),
Set(Box<CqlType>),
Map(Box<CqlType>, Box<CqlType>),
// Complex
Tuple(Vec<CqlType>),
Udt(UdtDef),
// Modifiers
Frozen(Box<CqlType>),
}
Supports Milestone M1 (Core Reading Library):
Supports Milestone M5 (Write Support):
❌ Wrong: Look at data to guess type ✅ Right: Use schema to know type
❌ Wrong: Vec<u8> for every field
✅ Right: Bytes with zero-copy slicing
❌ Wrong: Assume all fields present ✅ Right: Check for null (-1 size prefix)
❌ Wrong: Try to update frozen collection elements ✅ Right: Replace entire frozen value
❌ Wrong: Allow non-frozen nested collections ✅ Right: Nested collections must be frozen
Detailed specifications in:
Generate type-correct test data:
# Use test-data-management skill for Docker-based generation
cd test-data
./scripts/start-clean.sh
./scripts/generate.sh
Validate parsing against sstabledump:
sstabledump test-data/datasets/sstables/keyspace/table/*.db
When adding new type support:
CqlType enumxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience