@Override public boolean isCompatibleWith(AbstractType<?> previous) { if (this == previous) return true; if (!getClass().equals(previous.getClass())) return false; CollectionType tprev = (CollectionType) previous; if (this.isMultiCell() != tprev.isMultiCell()) return false; // subclasses should handle compatibility checks for frozen collections if (!this.isMultiCell()) return isCompatibleWithFrozen(tprev); if (!this.nameComparator().isCompatibleWith(tprev.nameComparator())) return false; // the value comparator is only used for Cell values, so sorting doesn't matter return this.valueComparator().isValueCompatibleWith(tprev.valueComparator()); }
@Override public String toString() { return this.toString(false); }
@Override public boolean isValueCompatibleWithInternal(AbstractType<?> previous) { // for multi-cell collections, compatibility and value-compatibility are the same if (this.isMultiCell()) return isCompatibleWith(previous); if (this == previous) return true; if (!getClass().equals(previous.getClass())) return false; CollectionType tprev = (CollectionType) previous; if (this.isMultiCell() != tprev.isMultiCell()) return false; // subclasses should handle compatibility checks for frozen collections return isValueCompatibleWithFrozen(tprev); }
private AbstractType<?> forValues(AbstractType<?> collectionType) { assert collectionType instanceof CollectionType; CollectionType ct = (CollectionType)collectionType; switch (ct.kind) { case LIST: case MAP: return ct.valueComparator(); case SET: return ct.nameComparator(); } throw new AssertionError(); }
public ByteBuffer serializeForNativeProtocol(Iterator<Cell> cells, ProtocolVersion version) { assert isMultiCell(); List<ByteBuffer> values = serializedValues(cells); int size = collectionSize(values); return CollectionSerializer.pack(values, size, version); }
@Override public boolean equals(Object o, boolean ignoreFreezing) { if (this == o) return true; if (!(o instanceof CollectionType)) return false; CollectionType other = (CollectionType)o; if (kind != other.kind) return false; if (!ignoreFreezing && isMultiCell() != other.isMultiCell()) return false; return nameComparator().equals(other.nameComparator(), ignoreFreezing) && valueComparator().equals(other.valueComparator(), ignoreFreezing); }
public AbstractType<?> getIndexedValueType(ColumnDefinition indexedColumn) { return ((CollectionType) indexedColumn.type).nameComparator(); } };
@Override protected AbstractType<?> getIndexKeyComparator() { return ((CollectionType)columnDef.type).valueComparator(); }
@Override public void validateCellValue(ByteBuffer cellValue) throws MarshalException { if (isMultiCell()) valueComparator().validateCellValue(cellValue); else super.validateCellValue(cellValue); }
public boolean appliesTo(Row row) throws InvalidRequestException if (type.isMultiCell()) return true; else if (type.compare(value.get(ProtocolVersion.V3), cell.value()) == 0)
public ByteBuffer serializeForNativeProtocol(ColumnDefinition def, List<Cell> cells, int version) { assert isMultiCell(); cells = enforceLimit(def, cells, version); List<ByteBuffer> values = serializedValues(cells); return CollectionSerializer.pack(values, cells.size(), version); }
public List<Cell> enforceLimit(ColumnDefinition def, List<Cell> cells, int version) { assert isMultiCell(); if (version >= Server.VERSION_3 || cells.size() <= MAX_ELEMENTS) return cells; logger.error("Detected collection for table {}.{} with {} elements, more than the {} limit. Only the first {}" + " elements will be returned to the client. Please see " + "http://cassandra.apache.org/doc/cql3/CQL.html#collections for more details.", def.ksName, def.cfName, cells.size(), MAX_ELEMENTS, MAX_ELEMENTS); return cells.subList(0, MAX_ELEMENTS); }
@Override public boolean isCompatibleWith(AbstractType<?> previous) { if (!(previous instanceof ColumnToCollectionType)) return false; ColumnToCollectionType prev = (ColumnToCollectionType)previous; // We are compatible if we have all the definitions previous have (but we can have more). for (Map.Entry<ByteBuffer, CollectionType> entry : prev.defined.entrySet()) { CollectionType newType = defined.get(entry.getKey()); if (newType == null || !newType.isCompatibleWith(entry.getValue())) return false; } return true; }
@Override public boolean equals(Object o, boolean ignoreFreezing) { if (this == o) return true; if (!(o instanceof CollectionType)) return false; CollectionType other = (CollectionType)o; if (kind != other.kind) return false; if (!ignoreFreezing && isMultiCell() != other.isMultiCell()) return false; return nameComparator().equals(other.nameComparator(), ignoreFreezing) && valueComparator().equals(other.valueComparator(), ignoreFreezing); }
public AbstractType<?> getIndexedValueType(ColumnDefinition indexedColumn) { return ((CollectionType) indexedColumn.type).nameComparator(); } };
private AbstractType<?> forValues(AbstractType<?> collectionType) { assert collectionType instanceof CollectionType; CollectionType ct = (CollectionType)collectionType; switch (ct.kind) { case LIST: case MAP: return ct.valueComparator(); case SET: return ct.nameComparator(); } throw new AssertionError(); }
public ByteBuffer serializeForNativeProtocol(Iterator<Cell> cells, ProtocolVersion version) { assert isMultiCell(); List<ByteBuffer> values = serializedValues(cells); int size = collectionSize(values); return CollectionSerializer.pack(values, size, version); }
/** * The type of the cell values for cell belonging to this column. * * This is the same than the column type, except for collections where it's the 'valueComparator' * of the collection. */ public AbstractType<?> cellValueType() { return type instanceof CollectionType ? ((CollectionType)type).valueComparator() : type; }
@Override public void validateCellValue(ByteBuffer cellValue) throws MarshalException { if (isMultiCell()) valueComparator().validateCellValue(cellValue); else super.validateCellValue(cellValue); }
public boolean appliesTo(Row row) throws InvalidRequestException if (type.isMultiCell()) return true; else if (type.compare(value.get(ProtocolVersion.V3), cell.value()) == 0)