Skip to content

Type construction and operation reference

This is the complete protocol contract for constructing and operating on Amaquet’s 91 registered types. The individual type pages provide copyable creation examples; this page defines arguments, defaults, results, and the implementation behavior behind them.

Use this command envelope to invoke a type-specific operation on an existing key.

{
"command": "OP",
"args": {
"key": "jobs",
"operation": "ENQUEUE",
"args": {
"value": { "type": "json", "value": { "id": "job-1" } }
}
}
}

Operation names are case-insensitive at dispatch. Argument names are case-sensitive JSON object keys. A nested typed value always uses {"type":"…","value":…}; see Wire values.

Read operations do not increment the key version. A successful mutation reserves approximate memory first and increments the version after the type object changes. A failed validation or operation does not increment it. Empty reads generally return null, an empty collection, or false as documented below.

Read-classified paths can still perform internal lazy maintenance. In particular, reliable-queue STATS and snapshots requeue or dead-letter expired leases without a version increment or a separate AOF mutation record.

The word GET in a directly encoded type’s individual page means the top-level key command. It is not automatically an OP GET. Only operations listed in the tables below are accepted by OP.

Direct values use SET; their JSON representations are defined in Wire values. json, messagepack, and cbor support both direct SET and an empty CREATE initializer. Other composite/specialized values use:

{
"command": "CREATE",
"args": {
"key": "example",
"type": "list",
"options": {},
"ttl_ms": 60000,
"nx": true
}
}

CREATE and SET both accept optional ttl_ms, nx, and xx. nx fails if a live key exists; xx fails if no live key exists. Supplying both is legal to decode but can never produce a useful conditional write. expires_at_unix_nano is the absolute-time form used by deterministic replay and advanced clients.

These creation options define the initial shape and constraints of collection and structured values.

TypeOptions and defaultsConstraints
list, set, sorted_set, ordered_set, multiset, hashmap, ordered_map, multimapnoneStart empty
arraytyped:false, element_type omittedA typed array requires each nested value to match element_type
dequecapacity:16Values below 8 become 8; grows by doubling
ring_buffercapacity:1024Minimum 1; overwrites the oldest value when full
tuplevalues:[]Array of nested typed values; fixed after creation
jsonnoneStarts as {}
messagepack, cbornoneStart as empty opaque bytes
recordschema:[]Each field has name, registered type, and nullable
matrixrows:1, cols:1, dtype:"float64", zero-filled datadata length must equal rows × columns
tensorshape:[1], dtype:"float64", zero-filled dataEvery dimension positive; product must equal data length

The type package defines dtype constants float64, float32, int64, and int32. The constructor currently stores any supplied dtype string without validating it, and values are represented internally as float64; use the defined constants for portable data because dtype is descriptive metadata rather than an enforced conversion on every assignment.

Messaging structures begin empty unless their row identifies retention, delivery-attempt, or group-name state. These values are creation-time options; runtime behavior is controlled through the operations documented later on this page.

TypeOptions and defaultsConstraints
fifo_queue, lifo_stack, priority_queue, blocking_queue, delayed_queue, stream, pubsub, event_lognoneStart empty
reliable_queuemax_attempts:5Values below 1 become 5
consumer_groupname:"default"Standalone snapshot object; stream groups are normally created on a stream
persistent_topicmax_messages:00 means no retention-count cap

Bit and probabilistic structures allocate or grow their internal state from these sizing parameters. Defaults favor general-purpose use, while constructor validation or fallback behavior is listed explicitly in the constraints column.

TypeOptions and defaultsConstraints
bitmap, bit_set, roaring_bitmapnoneGrow as values/bits are added
bit_fieldsize_bytes:0Negative values become 0; later writes grow it
hyperloglogprecision:14Precision 4…18
bloom_filter, counting_bloom_filterexpected:100000, false_positive_rate:0.01Expected > 0; rate strictly between 0 and 1
cuckoo_filtercapacity:100000Allocates power-of-two four-slot buckets sized from capacity
count_min_sketchwidth:2048, depth:5Both positive
top_kk:10Values below 1 become 1
t_digestcompression:100Values below 20 become 100

Time-series, geo, vector, and index options

Section titled “Time-series, geo, vector, and index options”

These constructors define retention, aggregation, dimensions, distance metrics, and index tuning. Some string options are stored at creation and validated only when an operation needs them, as noted after the table.

TypeOptions and defaultsConstraints
timeseries, counter_series, gauge_serieslabels:{}, retention_ms:00 means no retention trimming
histogrambounds:[]Bounds are sorted; one overflow bucket is added
timeseries_labelslabels:{}Mutable string map
aggregated_seriesbucket_ms:60000, aggregation:"avg"Source key is supplied at read time
geo_spatial_index, geospatial_secondary_indexnoneStart empty
vector_set, flat_vector_indexrequired positive dim, metric:"cosine"Metrics: cosine, dot, euclidean, manhattan
vector_metadatanoneStarts as an empty JSON-like map
hnsw_indexrequired positive dim, metric:"cosine", m:16, ef_search:64m<2 becomes 16; ef_search<m becomes 64
btree_indexdegree:16Degree below 2 becomes 16
hash_index, radix_tree, trie, inverted_index, secondary_indexnoneStart empty
full_text_documentid:"", metadata:nullField arrays start empty
tag_fieldname:"", values:[]Standalone field value
numeric_fieldname:"", value:0Standalone field value
text_fieldname:"", value:"", weight:1Standalone field value

The portable aggregation names are avg, sum, min, max, count, first, and last; an aggregated_series stores the creation string and reports an unknown mode when a read tries to use it. Likewise, vector constructors store the metric string, while distance/search evaluation rejects anything other than cosine, dot, euclidean, or manhattan.

Graph, synchronization, and network options

Section titled “Graph, synchronization, and network options”

These options initialize graph, synchronization, and rate-limiting values before their first operation.

TypeOptions and defaultsConstraints
adjacency_set, lease, locknoneStart empty/unheld
atomic_counterinitial:0Signed 64-bit
barriertarget:1Positive participant count
semaphorelimit:1Positive permit count
rate_limit_bucketcapacity:100, refill_per_second:10Negative values clamp to 0; starts full

geo_point, bounding_box, polygon, dense_vector, sparse_vector, quantized_vector, cidr_network, and url are direct SET values rather than CREATE types.

The following operations mutate or inspect scalar values that are normally created with SET.

TypeOperationArgumentsResult and behavior
integerADDdelta signed integerNew signed value
unsigned_integerADDdelta unsigned integerNew unsigned value
floatADDdelta numberNew float64 value
decimal, big_decimalADD, SUBvalue decimal stringExact result string; scales are aligned before arithmetic
decimal, big_decimalCMPvalue decimal string-1, 0, or 1; read-only
booleanTOGGLEnoneNew boolean
durationADDdelta_ms integer milliseconds or duration stringNew Go-duration string
big_integerADDvalue base-10 integer stringNew arbitrary-precision integer string
geo_pointDISTANCEpoint:{lat,lon}Haversine distance in meters using radius 6,371,008.8 m
bounding_box, polygonCONTAINSpoint:{lat,lon}Boolean containment; polygon uses ray casting on lon/lat coordinates
dense_vectorDISTANCEvector:[...], optional metric:"cosine"Numeric distance; dimensions must match
quantized_vectorDEQUANTIZEnoneFloat32 vector (q-zero_point)*scale
cidr_networkCONTAINSip stringBoolean parsed-IP containment
urlHOST, SCHEMEnoneParsed host or scheme string

binary_string, utf8_string, null, timestamp, uuid, symbol, and sparse_vector have no type-specific OP; use the normal key commands. Standalone sparse-vector distance is not exposed by the current dispatcher.

Signed and unsigned fixed-width additions (integer, unsigned_integer, atomic_counter, and the millisecond addition used by duration) use Go’s native fixed-width arithmetic and wrap on overflow. big_integer and the decimal types use arbitrary-precision representations instead.

Vector metric results are distances sorted ascending: cosine is 1-cosine_similarity, dot is the negative dot product, Euclidean is L2, and Manhattan is L1. A zero vector has cosine distance 1.

These operations manage ordered, unordered, map-like, and fixed-shape collection values.

TypeOperationArgumentsResult and behavior
listPUSH_FRONT, PUSH_BACKnested valueNew length
listPOP_FRONT, POP_BACKnoneTyped value or null
listRANGEstart:0, stop:-1Inclusive slice; negative indexes count from end
listLENnoneLength
arrayAPPENDnested valueNew length; enforces typed-array element type
arraySETindex, nested valuetrue; negative indexes allowed; out of range errors
arrayGETindexTyped value or null; negative indexes allowed
arrayVALUES, LENnoneCopy of values or array length
dequePUSH_FRONT, PUSH_BACKnested valueNew length
dequePOP_FRONT, POP_BACKnoneTyped value or null
dequeVALUES, LENnoneLogical-order values or length
ring_bufferPUSHnested valueCurrent length; overwrites oldest at capacity
ring_bufferVALUES, LENnoneOldest-to-newest values or length
tupleGETindexTyped value or null; negative indexes allowed
tupleVALUES, LENnoneFixed values or tuple length
setADD, REMOVE, CONTAINSnested valueBoolean added/removed/present
setMEMBERS, LENnoneMembers or count; member order is unspecified
sorted_setADDnested member, numeric scoretrue if new, false if score replaced
sorted_setREMOVE, SCOREnested memberRemoved boolean; score or null
sorted_setRANGEstart:0, stop:-1, reverse:falseInclusive score-ordered entries; value identity breaks score ties
ordered_setADD, REMOVEnested valueBoolean; re-adding an existing value does not move it
ordered_setVALUESnoneInsertion-order values
multisetADD, REMOVEnested value, optional count:1Remaining/new unsigned count
multisetCOUNTnested valueCurrent count
hashmapSETfield, nested valuetrue
hashmapGETfieldTyped value or null
hashmapDELETEfieldRemoved boolean
hashmapKEYSnoneLexically sorted field names
ordered_mapSETfield, nested valuetrue; replacement retains original position
ordered_mapGETfieldTyped value or null
ordered_mapDELETEfieldRemoved boolean
ordered_mapENTRIESnoneInsertion-order key/value entries
multimapADDfield, nested valuetrue; duplicates are allowed
multimapGETfieldCopy of all values
multimapREMOVEfield, nested valueRemoves the first equal value; boolean

Lists use Go slices, so front insertion/removal is linear. Deques use a growable circular buffer. Sets use a deterministic typed-value key. Sorted-set reads sort current map entries by score rather than maintaining a skip list.

These operations read and modify records, documents, matrices, tensors, and other structured values.

TypeOperationArgumentsResult and behavior
jsonGETnoneDeep-copied JSON document
jsonSETarbitrary JSON valuetrue; replaces the whole document
recordSETfield, nested valuetrue; schema/type/nullability enforced
recordGETfieldTyped value or null
matrix, tensorGETindices:[...]Numeric cell; rank and bounds enforced
matrix, tensorSETindices:[...], numeric valuetrue
matrix, tensorLENnoneFlat element count

messagepack and cbor expose only top-level GET; they are opaque byte containers and are not decoded by Amaquet.

These operations enqueue, dequeue, inspect, and coordinate queue-like values.

TypeOperationArgumentsResult and behavior
fifo_queueENQUEUEnested valueNew length
fifo_queueDEQUEUE, PEEKnoneOldest typed value or null
fifo_queueLENnoneLength
lifo_stackPUSHnested valueNew length
lifo_stackPOP, PEEKnoneNewest typed value or null
lifo_stackLENnoneLength
priority_queueENQUEUEnested value, numeric priorityNew length
priority_queueDEQUEUEnone{value,priority,sequence} or null; higher priority first, FIFO for ties
priority_queueLENnoneLength
blocking_queueENQUEUEnested valuetrue; errors after close
blocking_queueDEQUEUEnoneWaits for a value, close, cancellation, or server command deadline
blocking_queueCLOSEnonetrue; wakes a waiter; close is permanent
blocking_queueLENnoneLength
delayed_queueENQUEUEid, nested value, available_at_ms Unix millisecondsNew length
delayed_queuePOP_READYoptional replay-only now_unix_nanoEarliest ready item, FIFO sequence for equal times, or null
delayed_queueLENnoneLength
reliable_queueENQUEUEid, nested valuetrue; IDs are not checked for uniqueness
reliable_queueCLAIMoptional lease_ms:30000Oldest ready message or null; increments attempts
reliable_queueACK, NACKidBoolean; NACK requeues or dead-letters at max_attempts
reliable_queueSTATSnone{ready,pending,dead} after expired leases are requeued/dead-lettered

Delayed-queue ready selection scans the current items. Reliable-queue expired leases are processed lazily during claim, stats, and snapshot operations.

These operations append, consume, acknowledge, and inspect stream and messaging values.

TypeOperationArgumentsResult and behavior
streamADDfields map of nested values; optional id:"millis-sequence"Monotonic stream ID; server generates a deterministic ID when omitted
streamRANGEoptional count:100First entries up to count; current protocol does not expose start/end bounds
streamGROUP_CREATEgrouptrue; starts before the first entry
streamGROUP_READgroup, consumer, optional count:10New entries after group’s last-delivered ID and records them pending
streamACKgroup, ids:["…"]Number removed from pending
streamPENDINGgroupPending records sorted by stream ID
streamLENnoneEntry count
consumer_groupSNAPSHOTnoneStandalone group’s name, cursor, and pending entries
pubsubPUBLISHchannel, nested valueNumber of server subscriber buffers that accepted the message
pubsubSTATSnoneCumulative {published,delivered,dropped}
persistent_topicPUBLISHoptional message_key, nested valueMonotonic zero-based offset
persistent_topicREADrequired from, optional count:100Messages with offset ≥ from
event_logAPPENDevent_type, optional aggregate_id, nested payloadEvent with one-based sequence and UTC timestamp
event_logREADoptional from:1, count:100Events with sequence ≥ from
event_logLENnoneEvent count

Pub/Sub subscriptions do not use OP. Send the dedicated SUBSCRIBE opcode with key, channel, and optional buffer (default 16 on the server; the Go helper defaults to 64). Delivery is best-effort: a full subscriber buffer drops that event instead of blocking publishers. persistent_topic and event_log retain messages as database values; Pub/Sub does not.

These operations manipulate individual bits, ranges, and compact bit-oriented indexes.

TypeOperationArgumentsResult and behavior
bitmap, bit_setSETunsigned bit, optional value:truePrevious bit value; storage grows to the addressed 64-bit word
bitmap, bit_setGETBITunsigned bitBoolean; out-of-range reads are false
bitmap, bit_setCOUNTnonePopulation count
bit_fieldSEToffset, width, value unsignedtrue; width must be 1…64; bits are big-endian within bytes
bit_fieldGEToffset, widthUnsigned value; an unread allocated range returns 0
roaring_bitmapADD, REMOVE, CONTAINSunsigned value ≤ 2³²−1Boolean
roaring_bitmapVALUESnoneSorted uint32 values
roaring_bitmapCARDINALITYnoneCount

Roaring values are partitioned by the high 16 bits. Each low-16-bit container adapts among sorted arrays, 65,536-bit bitmaps, and run containers. Dense arrays switch around 4,096 values; long consecutive ranges prefer run storage.

These operations update and query approximate-membership, cardinality, frequency, and percentile structures.

TypeOperationArgumentsResult and behavior
hyperloglogADDstring valueWhether a register increased
hyperloglogCOUNTnoneRounded approximate cardinality with small-range linear counting
bloom_filterADDstring valueWhether any filter bit changed
bloom_filterCONTAINSstring valueProbabilistic membership
counting_bloom_filterADDstring valuetrue; saturating uint16 counters
counting_bloom_filterREMOVEstring valueBoolean; decrements only if every counter is nonzero
counting_bloom_filterCONTAINSstring valueProbabilistic membership
cuckoo_filterADDstring valueBoolean; insertion can fail after 500 relocations
cuckoo_filterREMOVEstring valueBoolean indicating whether a matching fingerprint was removed
cuckoo_filterCONTAINSstring valueProbabilistic membership
count_min_sketchADDstring value, optional unsigned count:1Current minimum counter estimate
count_min_sketchESTIMATEstring valueApproximate frequency (never below inserted count absent overflow)
top_kADDstring value, optional unsigned count:1Count-Min estimate
top_kITEMSnoneUp to k candidates by estimated count, then lexical tie-break
t_digestADDnumeric value, optional weight:1true; non-positive weights are ignored internally
t_digestQUANTILEnumeric qApproximate quantile; q clamps to 0…1; empty digest returns JSON-incompatible NaN and therefore should be avoided

All hashing in these probabilistic structures derives 64-bit values from SHA-256 with explicit seeds. Bloom filters use double hashing. The Cuckoo filter uses four 16-bit fingerprints per bucket. Top-K retains at most roughly 4*k candidates over a fixed 2048×5 Count-Min Sketch. These structures provide estimates/false-positive tradeoffs, not exact sets or counters.

These operations append observations and query retained time-series and aggregated data.

TypeOperationArgumentsResult and behavior
timeseriesADDoptional timestamp Unix ms (default now), numeric valuetrue; replaces an existing point at the same timestamp
counter_seriesADDoptional timestamp, numeric value deltatrue; stores last value plus delta
gauge_seriesSEToptional timestamp, numeric valuetrue; stores the supplied value
all three seriesRANGEoptional from:0, to:now Unix msInclusive sorted points
all three seriesLASTnoneLast point or null
all three seriesAGGREGATEoptional from, to, bucket_ms:60000, aggregation:"avg"Bucket-start/value points
all three seriesLENnonePoint count
histogramOBSERVEnumeric valuetrue; increments first bound ≥ value, otherwise overflow bucket
histogramSNAPSHOTnone{bounds,counts,count,sum}
timeseries_labelsGETnoneCopy of label map
timeseries_labelsSETlabel, string valuetrue
aggregated_seriesRANGE, AGGREGATEsource_key; optional from, to, bucket_ms, aggregationAggregates a timeseries, counter_series, or gauge_series key

Aggregation modes are avg, sum, min, max, count, first, and last. Buckets are anchored at from. Retention trimming occurs on writes and uses the server’s current time, not the newest sample time; old out-of-order points can therefore be removed immediately.

These operations store geographic members and query positions, bounds, and radius matches.

TypeOperationArgumentsResult and behavior
geo_spatial_index, geospatial_secondary_indexADDid, point:{lat,lon}, optional string metadata maptrue; replacing an ID moves its grid cell
both indexesREMOVEidBoolean
both indexesRADIUScenter, radius_meters, optional limit:100Distance-sorted hits with distance_meters
both indexesBOXbox:{minLat,minLon,maxLat,maxLon}ID-sorted items inside inclusive bounds
both indexesPOLYGONpoints:[...]ID-sorted items passing point-in-polygon

The index uses 0.25-degree latitude/longitude grid cells to find candidates, then applies exact Haversine/box/ray-casting checks. Queries whose bounding box spans more than 100,000 cells fall back to scanning all items. Polygons are planar lon/lat ray casts and do not add special antimeridian wrapping.

These operations manage vectors and run exact or approximate similarity searches.

TypeOperationArgumentsResult and behavior
vector_set, flat_vector_indexADDid, vector, optional metadatatrue; vector dimension enforced; replaces same ID
bothREMOVEidBoolean
bothSEARCHvector, optional k:10Exact full-scan results sorted by ascending distance
bothLENnoneItem count
hnsw_indexADDid, vector, optional metadatatrue; replaces same ID and reconnects graph
hnsw_indexREMOVEidBoolean
hnsw_indexSEARCHvector, optional k:10Approximate ascending-distance neighbors
vector_metadataGETnoneCopy of metadata map
vector_metadataSETfield, arbitrary JSON valuetrue
vector_metadataDELETEfieldWhether a field existed

The current protocol does not expose metadata-filter expressions even though the internal search API accepts a filter callback. HNSW assigns deterministic levels from FNV-1a of the item ID, uses bidirectional edges, caps degree at m above level 0 and 2*m at level 0, and searches with configured ef_search (raised to at least k). Exact vector sets scan all items.

These operations populate and query indexes, trees, and full-text search structures.

TypeOperationArgumentsResult and behavior
btree_indexINSERTstring value, idtrue
btree_indexDELETEstring value, idRemoved boolean
btree_indexSEARCHstring valueLexically sorted IDs for exact key
btree_indexRANGEstring value as inclusive minimum; optional max:"", limit:100Map of key to sorted IDs; limit counts keys
hash_indexADDstring value, idtrue
hash_indexREMOVEstring value, idRemoved boolean
hash_indexLOOKUPstring valueSorted IDs
radix_tree, trieINSERTstring value, idtrue
bothEXACTstring valueSorted IDs
bothPREFIXstring prefix, optional limit:100Lexically traversed map of matching strings to IDs
inverted_indexINDEXid, string texttrue; replaces previous terms for ID
inverted_indexREMOVEidtrue even if absent
inverted_indexSEARCHstring query, optional limit:20Hits sorted by descending TF×IDF-like score, then ID
secondary_indexADDfield, string value, idtrue
secondary_indexLOOKUPfield, string valueSorted IDs
full_text_documentADD_TEXTname, string value, optional weight:1true; appends a field
full_text_documentADD_TAGname, values string arraytrue; appends a field
full_text_documentADD_NUMERICname, numeric valuetrue; appends a field
full_text_documentGET, SNAPSHOTnoneComplete document snapshot
tag_fieldSEToptional name, optional valuestrue; replaces supplied properties
tag_fieldGETnoneField object
numeric_fieldSEToptional name, optional numeric valuetrue
numeric_fieldGETnoneField object
text_fieldSEToptional name, value, weighttrue
text_fieldGETnoneField object

The B-tree uses minimum degree t, at most 2t-1 keys per node, and rebuilds the tree after deletion. Radix-tree/trie traversal is byte-oriented UTF-8, not Unicode-code-point compressed. The inverted index lowercases and tokenizes Unicode letter/digit runs, records term frequency, and ranks query terms with an IDF-like natural-log approximation. full_text_document is a field container; it does not automatically update an inverted_index.

Graph, synchronization, and network operations

Section titled “Graph, synchronization, and network operations”

These operations manage relationships and coordinate concurrent clients through synchronization and rate-limit values.

TypeOperationArgumentsResult and behavior
adjacency_setADDfrom, to, optional numeric weight:1true; directed edge
adjacency_setREMOVEfrom, toRemoved boolean; directed edge
adjacency_setNEIGHBORSfromMap of outgoing neighbor to weight
atomic_counterADDsigned deltaNew value
atomic_counterLOADnoneCurrent value
atomic_counterCASsigned old, signed newSwap-success boolean
leaseACQUIREowner, token, optional ttl_ms:30000Boolean; only when absent/expired and TTL positive
leaseRENEW, RELEASEtoken; renew accepts ttl_ms:30000Boolean token-checked result
leaseHELDnoneWhether a non-expired token exists
lockTRY_LOCKowner, token, optional ttl_ms:30000Boolean; implemented by a lease
lockRENEW, UNLOCKtoken; renew accepts ttl_ms:30000Boolean
barrierWAITnonetrue when the target arrives; reusable across generations, and cancellation removes an arrival only from its still-current generation
semaphoreACQUIREnonetrue after a permit is obtained; context-aware wait
semaphoreTRY_ACQUIREnoneImmediate boolean
semaphoreRELEASEnoneBoolean; false when no permit is held
semaphoreSTATSnone{limit,in_use}
rate_limit_bucketALLOWoptional numeric cost:1Boolean; non-positive cost is allowed without consuming tokens
rate_limit_bucketREMAININGnoneCurrent tokens after time-based refill

Lease/lock ownership is enforced by caller-supplied tokens, not by the authenticated actor automatically. Barrier and semaphore waits are bounded by request cancellation and limits.command_timeout_ms. Lease, lock, barrier, semaphore, Pub/Sub, and rate-limit-bucket mutations are deliberately excluded from AOF journaling because restoring live coordination state can recreate stale ownership.

cidr_network and url are direct values; their operations are in the scalar table above.

All SET, CREATE, CAS, DEL, EXPIRE, PERSIST, and blob-upload mutations are journaled when AOF is enabled. Mutating OP calls are journaled except for the process-local coordination types just listed. The dispatcher resolves generated IDs, timestamps, and relative TTLs before writing the prepare record so replay uses the historical value rather than the restart clock.

See Persistence and recovery for the transaction and recovery format.