Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/commands/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,13 +507,20 @@ impl Buffer {
| Operation {
op: OperationType::HllRead,
..
}
| Operation {
op: OperationType::ExpRead,
..
} => read_attr |= INFO1_READ,
_ => write_attr |= INFO2_WRITE,
}

let each_op = matches!(
operation.data,
OperationData::CdtMapOp(_) | OperationData::CdtBitOp(_)
OperationData::CdtMapOp(_)
| OperationData::CdtBitOp(_)
| OperationData::HLLOp(_)
| OperationData::EXPOp(_)
);

if policy.respond_per_each_op || each_op {
Expand Down Expand Up @@ -556,7 +563,6 @@ impl Buffer {
for operation in operations {
operation.write_to(self)?;
}

self.end()
}

Expand Down
28 changes: 28 additions & 0 deletions src/expressions/hll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const MODULE: i64 = 2;

#[doc(hidden)]
pub enum HllExpOp {
Init = 0,
Add = 1,
Count = 50,
Union = 51,
Expand All @@ -33,6 +34,33 @@ pub enum HllExpOp {
MayContain = 56,
}

/// Create expression that creates a new HLL or resets an existing HLL.
pub fn init(
policy: HLLPolicy,
index_bit_count: FilterExpression,
bin: FilterExpression,
) -> FilterExpression {
init_with_min_hash(policy, index_bit_count, int_val(-1), bin)
}

/// Create expression that creates a new HLL or resets an existing HLL with minhash bits.
pub fn init_with_min_hash(
policy: HLLPolicy,
index_bit_count: FilterExpression,
min_hash_count: FilterExpression,
bin: FilterExpression,
) -> FilterExpression {
add_write(
bin,
vec![
ExpressionArgument::Value(Value::from(HllExpOp::Init as i64)),
ExpressionArgument::FilterExpression(index_bit_count),
ExpressionArgument::FilterExpression(min_hash_count),
ExpressionArgument::Value(Value::from(policy.flags as i64)),
],
)
}

/// Create expression that adds list values to a HLL set and returns HLL set.
/// The function assumes HLL bin already exists.
/// ```
Expand Down
Loading