/** * Compose column value. * * @param cqlMetadata * the cql metadata * @param thriftColumnValue * the thrift column value * @param thriftColumnName * the thrift column name * @return the object */ private Object composeColumnValue(CqlMetadata cqlMetadata, byte[] thriftColumnValue, byte[] thriftColumnName) { Map<ByteBuffer, String> schemaTypes = cqlMetadata.getValue_types(); AbstractType<?> type = null; try { type = TypeParser.parse(schemaTypes.get(ByteBuffer.wrap(thriftColumnName))); } catch (SyntaxException | ConfigurationException ex) { log.error(ex.getMessage()); throw new KunderaException("Error while deserializing column value " + ex); } if (type.isCollection()) { return ((CollectionSerializer) type.getSerializer()) .deserializeForNativeProtocol(ByteBuffer.wrap(thriftColumnValue), ProtocolVersion.V2); } return type.compose(ByteBuffer.wrap(thriftColumnValue)); }
public Marker(int bindIndex, ColumnSpecification receiver) { super(bindIndex, receiver); assert !receiver.type.isCollection(); }
public Marker(int bindIndex, ColumnSpecification receiver) { super(bindIndex, receiver); assert !receiver.type.isCollection(); }
private CollectionBound(ColumnCondition condition, QueryOptions options) throws InvalidRequestException { super(condition.column, condition.operator); assert column.type.isCollection() && condition.collectionElement == null; assert condition.operator != Operator.IN; this.value = condition.value.bind(options); }
private CollectionBound(ColumnCondition condition, QueryOptions options) throws InvalidRequestException { super(condition.column, condition.operator); assert column.type.isCollection() && condition.collectionElement == null; assert condition.operator != Operator.IN; this.value = condition.value.bind(options); }
public boolean isFrozenCollection() { return isCollection() && !isMultiCell(); }
private CollectionBound(ColumnCondition condition, QueryOptions options) throws InvalidRequestException { super(condition.column, condition.operator); assert column.type.isCollection() && condition.collectionElement == null; assert condition.operator != Operator.IN; this.value = condition.value.bind(options); }
private void validateIsSimpleIndexIfTargetColumnNotCollection(ColumnDefinition cd, IndexTarget target) throws InvalidRequestException { if (!cd.type.isCollection() && target.type != IndexTarget.Type.SIMPLE) throw new InvalidRequestException(String.format("Cannot create %s() index on %s. " + "Non-collection columns support only simple indexes", target.type.toString(), target.column)); }
private void validateIsSimpleIndexIfTargetColumnNotCollection(ColumnDefinition cd, IndexTarget target) throws InvalidRequestException { if (!cd.type.isCollection() && target.type != IndexTarget.Type.SIMPLE) throw new InvalidRequestException(String.format("Cannot create %s() index on %s. " + "Non-collection columns support only simple indexes", target.type.toString(), target.column)); }
public IndexTarget prepare(CFMetaData cfm) { // Until we've prepared the target column, we can't be certain about the target type // because (for backwards compatibility) an index on a collection's values uses the // same syntax as an index on a regular column (i.e. the 'values' in // 'CREATE INDEX on table(values(collection));' is optional). So we correct the target type // when the target column is a collection & the target type is SIMPLE. ColumnDefinition columnDef = column.prepare(cfm); Type actualType = (type == Type.SIMPLE && columnDef.type.isCollection()) ? Type.VALUES : type; return new IndexTarget(columnDef.name, actualType); } }
public IndexTarget prepare(CFMetaData cfm) { // Until we've prepared the target column, we can't be certain about the target type // because (for backwards compatibility) an index on a collection's values uses the // same syntax as an index on a regular column (i.e. the 'values' in // 'CREATE INDEX on table(values(collection));' is optional). So we correct the target type // when the target column is a collection & the target type is SIMPLE. ColumnDefinition columnDef = column.prepare(cfm); Type actualType = (type == Type.SIMPLE && columnDef.type.isCollection()) ? Type.VALUES : type; return new IndexTarget(columnDef.name, actualType); } }
public String asCqlString(CFMetaData cfm) { if (!cfm.getColumnDefinition(column).type.isCollection()) return column.toCQLString(); return String.format("%s(%s)", type.toString(), column.toCQLString()); }
public String asCqlString(CFMetaData cfm) { if (!cfm.getColumnDefinition(column).type.isCollection()) return column.toCQLString(); return String.format("%s(%s)", type.toString(), column.toCQLString()); }
public String asCqlString(CFMetaData cfm) { if (!cfm.getColumnDefinition(column).type.isCollection()) return column.toCQLString(); return String.format("%s(%s)", type.toString(), column.toCQLString()); }
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); } } }
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); } } }
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); } } }
private void validateCellPath(CellPath path) { if (!isComplex()) throw new MarshalException("Only complex cells should have a cell path"); assert type.isMultiCell(); if (type.isCollection()) ((CollectionType)type).nameComparator().validate(path.get(0)); else ((UserType)type).nameComparator().validate(path.get(0)); }
private void validateCellPath(CellPath path) { if (!isComplex()) throw new MarshalException("Only complex cells should have a cell path"); assert type.isMultiCell(); if (type.isCollection()) ((CollectionType)type).nameComparator().validate(path.get(0)); else ((UserType)type).nameComparator().validate(path.get(0)); }
private void validateCellPath(CellPath path) { if (!isComplex()) throw new MarshalException("Only complex cells should have a cell path"); assert type.isMultiCell(); if (type.isCollection()) ((CollectionType)type).nameComparator().validate(path.get(0)); else ((UserType)type).nameComparator().validate(path.get(0)); }