@Override public String toString() { return this.name(); } }
/** * Deserializes a <code>Operator</code> instance from the specified input. * * @param input the input to read from * @return the <code>Operator</code> instance deserialized * @throws IOException if a problem occurs while deserializing the <code>Type</code> instance. */ public static Operator readFrom(DataInput input) throws IOException { int b = input.readInt(); for (Operator operator : values()) if (operator.b == b) return operator; throw new IOException(String.format("Cannot resolve Relation.Type from binary representation: %s", b)); }
/** * Write the serialized version of this <code>IndexExpression</code> to the specified output. * * @param output the output to write to * @throws IOException if an I/O problem occurs while writing to the specified output */ public void writeTo(DataOutputPlus output) throws IOException { ByteBufferUtil.writeWithShortLength(column, output); operator.writeTo(output); ByteBufferUtil.writeWithShortLength(value, output); }
/** Returns true if the operator is satisfied (i.e. "otherValue operator value == true"), false otherwise. */ protected boolean compareWithOperator(Operator operator, AbstractType<?> type, ByteBuffer value, ByteBuffer otherValue) throws InvalidRequestException { if (value == ByteBufferUtil.UNSET_BYTE_BUFFER) throw new InvalidRequestException("Invalid 'unset' value in condition"); if (value == null) { switch (operator) { case EQ: return otherValue == null; case NEQ: return otherValue != null; default: throw new InvalidRequestException(String.format("Invalid comparison with null for operator \"%s\"", operator)); } } else if (otherValue == null) { // the condition value is not null, so only NEQ can return true return operator == Operator.NEQ; } return operator.isSatisfiedBy(type, otherValue, value); } }
/** * Deserializes an <code>IndexExpression</code> instance from the specified input. * * @param input the input to read from * @return the <code>IndexExpression</code> instance deserialized * @throws IOException if a problem occurs while deserializing the <code>IndexExpression</code> instance. */ public static IndexExpression readFrom(DataInput input) throws IOException { return new IndexExpression(ByteBufferUtil.readWithShortLength(input), Operator.readFrom(input), ByteBufferUtil.readWithShortLength(input)); } }
size += TypeSizes.NATIVE.sizeof(expr.operator.ordinal()); size += TypeSizes.NATIVE.sizeofWithShortLength(expr.value);
public static List<org.apache.cassandra.db.IndexExpression> fromThrift(List<IndexExpression> exprs) { if (exprs == null) return null; if (exprs.isEmpty()) return Collections.emptyList(); List<org.apache.cassandra.db.IndexExpression> converted = new ArrayList<>(exprs.size()); for (IndexExpression expr : exprs) { converted.add(new org.apache.cassandra.db.IndexExpression(expr.column_name, Operator.valueOf(expr.op.name()), expr.value)); } return converted; } }
@Override public String toString() { return operator.toString(); }
private void validateOperationOnDurations(AbstractType<?> type) { if (type.referencesDuration() && operator.isSlice()) { checkFalse(type.isCollection(), "Slice conditions are not supported on collections containing durations"); checkFalse(type.isTuple(), "Slice conditions are not supported on tuples containing durations"); checkFalse(type.isUDT(), "Slice conditions are not supported on UDTs containing durations"); throw invalidRequest("Slice conditions are not supported on durations", operator); } } }
+ expression.operator.serializedSize();
/** Returns true if the operator is satisfied (i.e. "otherValue operator value == true"), false otherwise. */ protected boolean compareWithOperator(Operator operator, AbstractType<?> type, ByteBuffer value, ByteBuffer otherValue) throws InvalidRequestException { if (value == ByteBufferUtil.UNSET_BYTE_BUFFER) throw new InvalidRequestException("Invalid 'unset' value in condition"); if (value == null) { switch (operator) { case EQ: return otherValue == null; case NEQ: return otherValue != null; default: throw new InvalidRequestException(String.format("Invalid comparison with null for operator \"%s\"", operator)); } } else if (otherValue == null) { // the condition value is not null, so only NEQ can return true return operator == Operator.NEQ; } return operator.isSatisfiedBy(type, otherValue, value); } }
static RowFilter deserializeRowFilter(DataInputPlus in, CFMetaData metadata) throws IOException { int numRowFilters = in.readInt(); if (numRowFilters == 0) return RowFilter.NONE; RowFilter rowFilter = RowFilter.create(numRowFilters); for (int i = 0; i < numRowFilters; i++) { ByteBuffer columnName = ByteBufferUtil.readWithShortLength(in); ColumnDefinition column = metadata.getColumnDefinition(columnName); Operator op = Operator.readFrom(in); ByteBuffer indexValue = ByteBufferUtil.readWithShortLength(in); rowFilter.add(column, op, indexValue); } return rowFilter; }
public long serializedSize(PagedRangeCommand cmd, int version) { long size = 0; size += TypeSizes.NATIVE.sizeof(cmd.keyspace); size += TypeSizes.NATIVE.sizeof(cmd.columnFamily); size += TypeSizes.NATIVE.sizeof(cmd.timestamp); size += AbstractBounds.serializer.serializedSize(cmd.keyRange, version); CFMetaData metadata = Schema.instance.getCFMetaData(cmd.keyspace, cmd.columnFamily); size += metadata.comparator.sliceQueryFilterSerializer().serializedSize((SliceQueryFilter)cmd.predicate, version); size += metadata.comparator.serializer().serializedSize(cmd.start, TypeSizes.NATIVE); size += metadata.comparator.serializer().serializedSize(cmd.stop, TypeSizes.NATIVE); size += TypeSizes.NATIVE.sizeof(cmd.rowFilter.size()); for (IndexExpression expr : cmd.rowFilter) { size += TypeSizes.NATIVE.sizeofWithShortLength(expr.column); size += TypeSizes.NATIVE.sizeof(expr.operator.ordinal()); size += TypeSizes.NATIVE.sizeofWithShortLength(expr.value); } size += TypeSizes.NATIVE.sizeof(cmd.limit); if (version >= MessagingService.VERSION_21) size += TypeSizes.NATIVE.sizeof(cmd.countCQL3Rows); return size; } }
public static RowFilter rowFilterFromThrift(CFMetaData metadata, List<IndexExpression> exprs) { if (exprs == null || exprs.isEmpty()) return RowFilter.NONE; RowFilter converted = RowFilter.forThrift(exprs.size()); for (IndexExpression expr : exprs) converted.addThriftExpression(metadata, expr.column_name, Operator.valueOf(expr.op.name()), expr.value); return converted; }
@Override public String toString() { return operator.toString(); }
private void validateOperationOnDurations(AbstractType<?> type) { if (type.referencesDuration() && operator.isSlice()) { checkFalse(type.isCollection(), "Slice conditions are not supported on collections containing durations"); checkFalse(type.isTuple(), "Slice conditions are not supported on tuples containing durations"); checkFalse(type.isUDT(), "Slice conditions are not supported on UDTs containing durations"); throw invalidRequest("Slice conditions are not supported on durations", operator); } } }
+ expression.operator.serializedSize();
/** Returns true if the operator is satisfied (i.e. "otherValue operator value == true"), false otherwise. */ protected boolean compareWithOperator(Operator operator, AbstractType<?> type, ByteBuffer value, ByteBuffer otherValue) throws InvalidRequestException { if (value == ByteBufferUtil.UNSET_BYTE_BUFFER) throw new InvalidRequestException("Invalid 'unset' value in condition"); if (value == null) { switch (operator) { case EQ: return otherValue == null; case NEQ: return otherValue != null; default: throw new InvalidRequestException(String.format("Invalid comparison with null for operator \"%s\"", operator)); } } else if (otherValue == null) { // the condition value is not null, so only NEQ can return true return operator == Operator.NEQ; } return operator.isSatisfiedBy(type, otherValue, value); } }
@Override public String toString() { return this.name(); } }
/** * Deserializes a <code>Operator</code> instance from the specified input. * * @param input the input to read from * @return the <code>Operator</code> instance deserialized * @throws IOException if a problem occurs while deserializing the <code>Type</code> instance. */ public static Operator readFrom(DataInput input) throws IOException { int b = input.readInt(); for (Operator operator : values()) if (operator.b == b) return operator; throw new IOException(String.format("Cannot resolve Relation.Type from binary representation: %s", b)); }