private static ColumnDefinition makeDefinition(CFMetaData cfm, IndexMetadata index) { // Similarly to how we handle non-defined columns in thift, we create a fake column definition to // represent the target index. This is definitely something that can be improved though. return ColumnDefinition.regularDef(cfm, ByteBuffer.wrap(index.name.getBytes()), BytesType.instance); }
private static ColumnDefinition makeDefinition(CFMetaData cfm, IndexMetadata index) { // Similarly to how we handle non-defined columns in thift, we create a fake column definition to // represent the target index. This is definitely something that can be improved though. return ColumnDefinition.regularDef(cfm, ByteBuffer.wrap(index.name.getBytes()), BytesType.instance); }
private static ColumnDefinition makeDefinition(CFMetaData cfm, IndexMetadata index) { // Similarly to how we handle non-defined columns in thift, we create a fake column definition to // represent the target index. This is definitely something that can be improved though. return ColumnDefinition.regularDef(cfm, ByteBuffer.wrap(index.name.getBytes()), BytesType.instance); }
@VisibleForTesting public Expression(String name, AbstractType<?> validator) { this(null, new ColumnIndex(UTF8Type.instance, ColumnDefinition.regularDef("sasi", "internal", name, validator), null)); }
@VisibleForTesting public Expression(String name, AbstractType<?> validator) { this(null, new ColumnIndex(UTF8Type.instance, ColumnDefinition.regularDef("sasi", "internal", name, validator), null)); }
@VisibleForTesting public Expression(String name, AbstractType<?> validator) { this(null, new ColumnIndex(UTF8Type.instance, ColumnDefinition.regularDef("sasi", "internal", name, validator), null)); }
/** * Returns a "fake" ColumnDefinition corresponding to the dropped column {@code name} * of {@code null} if there is no such dropped column. * * @param name - the column name * @param isStatic - whether the column was a static column, if known */ public ColumnDefinition getDroppedColumnDefinition(ByteBuffer name, boolean isStatic) { DroppedColumn dropped = droppedColumns.get(name); if (dropped == null) return null; // We need the type for deserialization purpose. If we don't have the type however, // it means that it's a dropped column from before 3.0, and in that case using // BytesType is fine for what we'll be using it for, even if that's a hack. AbstractType<?> type = dropped.type == null ? BytesType.instance : dropped.type; return isStatic ? ColumnDefinition.staticDef(this, name, type) : ColumnDefinition.regularDef(this, name, type); }
/** * Returns a "fake" ColumnDefinition corresponding to the dropped column {@code name} * of {@code null} if there is no such dropped column. * * @param name - the column name * @param isStatic - whether the column was a static column, if known */ public ColumnDefinition getDroppedColumnDefinition(ByteBuffer name, boolean isStatic) { DroppedColumn dropped = droppedColumns.get(name); if (dropped == null) return null; // We need the type for deserialization purpose. If we don't have the type however, // it means that it's a dropped column from before 3.0, and in that case using // BytesType is fine for what we'll be using it for, even if that's a hack. AbstractType<?> type = dropped.type == null ? BytesType.instance : dropped.type; return isStatic ? ColumnDefinition.staticDef(this, name, type) : ColumnDefinition.regularDef(this, name, type); }
private List<ColumnDefinition> getColumns(CFMetaData cfm) { List<ColumnDefinition> columnDefs = new ArrayList<>(columns.size()); Integer componentIndex = comparator.isCompound() ? comparator.clusteringPrefixSize() : null; for (Map.Entry<ColumnIdentifier, AbstractType> col : columns.entrySet()) { ColumnIdentifier id = col.getKey(); columnDefs.add(staticColumns.contains(id) ? ColumnDefinition.staticDef(cfm, col.getKey().bytes, col.getValue(), componentIndex) : ColumnDefinition.regularDef(cfm, col.getKey().bytes, col.getValue(), componentIndex)); } return columnDefs; }
/** * Returns a "fake" ColumnDefinition corresponding to the dropped column {@code name} * of {@code null} if there is no such dropped column. * * @param name - the column name * @param isStatic - whether the column was a static column, if known */ public ColumnDefinition getDroppedColumnDefinition(ByteBuffer name, boolean isStatic) { DroppedColumn dropped = droppedColumns.get(name); if (dropped == null) return null; // We need the type for deserialization purpose. If we don't have the type however, // it means that it's a dropped column from before 3.0, and in that case using // BytesType is fine for what we'll be using it for, even if that's a hack. AbstractType<?> type = dropped.type == null ? BytesType.instance : dropped.type; return isStatic ? ColumnDefinition.staticDef(this, name, type) : ColumnDefinition.regularDef(this, name, type); }
/** * Returns a "fake" ColumnDefinition corresponding to the dropped column {@code name} * of {@code null} if there is no such dropped column. * * @param name - the column name * @param isStatic - whether the column was a static column, if known */ public ColumnDefinition getDroppedColumnDefinition(ByteBuffer name, boolean isStatic) { DroppedColumn dropped = droppedColumns.get(name); if (dropped == null) return null; // We need the type for deserialization purpose. If we don't have the type however, // it means that it's a dropped column from before 3.0, and in that case using // BytesType is fine for what we'll be using it for, even if that's a hack. AbstractType<?> type = dropped.type == null ? BytesType.instance : dropped.type; return isStatic ? ColumnDefinition.staticDef(this, name, type) : ColumnDefinition.regularDef(this, name, type); }
private static ColumnDefinition makeDefinition(CFMetaData metadata, ByteBuffer name) { ColumnDefinition def = metadata.getColumnDefinition(name); if (def != null) return def; // In thrift, we actually allow expression on non-defined columns for the sake of filtering. To accomodate // this we create a "fake" definition. This is messy but it works so is probably good enough. return ColumnDefinition.regularDef(metadata, name, metadata.compactValueColumn().type); }
private static ColumnDefinition makeDefinition(CFMetaData metadata, ByteBuffer name) { ColumnDefinition def = metadata.getColumnDefinition(name); if (def != null) return def; // In thrift, we actually allow expression on non-defined columns for the sake of filtering. To accomodate // this we create a "fake" definition. This is messy but it works so is probably good enough. return ColumnDefinition.regularDef(metadata, name, metadata.compactValueColumn().type); }
private static ColumnDefinition makeDefinition(CFMetaData metadata, ByteBuffer name) { ColumnDefinition def = metadata.getColumnDefinition(name); if (def != null) return def; // In thrift, we actually allow expression on non-defined columns for the sake of filtering. To accomodate // this we create a "fake" definition. This is messy but it works so is probably good enough. return ColumnDefinition.regularDef(metadata, name, metadata.compactValueColumn().type); }
private static void addDefinitionForUpgrade(List<ColumnDefinition> defs, String ksName, String cfName, boolean isStaticCompactTable, boolean isSuper, AbstractType<?> rawComparator, AbstractType<?> subComparator, AbstractType<?> defaultValidator) { CompactTables.DefaultNames names = CompactTables.defaultNameGenerator(defs); if (isSuper) { defs.add(ColumnDefinition.regularDef(ksName, cfName, SuperColumnCompatibility.SUPER_COLUMN_MAP_COLUMN_STR, MapType.getInstance(subComparator, defaultValidator, true))); } else if (isStaticCompactTable) { defs.add(ColumnDefinition.clusteringDef(ksName, cfName, names.defaultClusteringName(), rawComparator, 0)); defs.add(ColumnDefinition.regularDef(ksName, cfName, names.defaultCompactValueName(), defaultValidator)); } else { // For dense compact tables, we get here if we don't have a compact value column, in which case we should add it // (we use EmptyType to recognize that the compact value was not declared by the use (see CreateTableStatement too)) defs.add(ColumnDefinition.regularDef(ksName, cfName, names.defaultCompactValueName(), EmptyType.instance)); } }
private static void addDefinitionForUpgrade(List<ColumnDefinition> defs, String ksName, String cfName, boolean isStaticCompactTable, boolean isSuper, AbstractType<?> rawComparator, AbstractType<?> subComparator, AbstractType<?> defaultValidator) { CompactTables.DefaultNames names = CompactTables.defaultNameGenerator(defs); if (isSuper) { defs.add(ColumnDefinition.regularDef(ksName, cfName, SuperColumnCompatibility.SUPER_COLUMN_MAP_COLUMN_STR, MapType.getInstance(subComparator, defaultValidator, true))); } else if (isStaticCompactTable) { defs.add(ColumnDefinition.clusteringDef(ksName, cfName, names.defaultClusteringName(), rawComparator, 0)); defs.add(ColumnDefinition.regularDef(ksName, cfName, names.defaultCompactValueName(), defaultValidator)); } else { // For dense compact tables, we get here if we don't have a compact value column, in which case we should add it // (we use EmptyType to recognize that the compact value was not declared by the use (see CreateTableStatement too)) defs.add(ColumnDefinition.regularDef(ksName, cfName, names.defaultCompactValueName(), EmptyType.instance)); } }
private static void addDefinitionForUpgrade(List<ColumnDefinition> defs, String ksName, String cfName, boolean isStaticCompactTable, boolean isSuper, AbstractType<?> rawComparator, AbstractType<?> subComparator, AbstractType<?> defaultValidator) { CompactTables.DefaultNames names = CompactTables.defaultNameGenerator(defs); if (isSuper) { defs.add(ColumnDefinition.regularDef(ksName, cfName, SuperColumnCompatibility.SUPER_COLUMN_MAP_COLUMN_STR, MapType.getInstance(subComparator, defaultValidator, true))); } else if (isStaticCompactTable) { defs.add(ColumnDefinition.clusteringDef(ksName, cfName, names.defaultClusteringName(), rawComparator, 0)); defs.add(ColumnDefinition.regularDef(ksName, cfName, names.defaultCompactValueName(), defaultValidator)); } else { // For dense compact tables, we get here if we don't have a compact value column, in which case we should add it // (we use EmptyType to recognize that the compact value was not declared by the use (see CreateTableStatement too)) defs.add(ColumnDefinition.regularDef(ksName, cfName, names.defaultCompactValueName(), EmptyType.instance)); } }
defs.add(ColumnDefinition.regularDef(ks, cf, SuperColumnCompatibility.SUPER_COLUMN_MAP_COLUMN_STR, MapType.getInstance(subComparator, defaultValidator, true))); if (isDense) defs.add(ColumnDefinition.regularDef(ks, cf, names.defaultCompactValueName(), defaultValidator)); defs.add(ColumnDefinition.clusteringDef(ks, cf, names.defaultClusteringName(), subTypes.get(i), i)); defs.add(ColumnDefinition.regularDef(ks, cf, names.defaultCompactValueName(), defaultValidator));
private List<ColumnDefinition> getColumns(CFMetaData cfm) throws InvalidRequestException { List<ColumnDefinition> columnDefs = new ArrayList<>(columns.size()); for (Map.Entry<Term, String> col : columns.entrySet()) { try { ByteBuffer columnName = cfm.comparator.asAbstractType().fromStringCQL2(col.getKey().getText()); String validatorClassName = CFPropDefs.comparators.containsKey(col.getValue()) ? CFPropDefs.comparators.get(col.getValue()) : col.getValue(); AbstractType<?> validator = TypeParser.parse(validatorClassName); columnDefs.add(ColumnDefinition.regularDef(cfm, columnName, validator, null)); } catch (ConfigurationException e) { InvalidRequestException ex = new InvalidRequestException(e.toString()); ex.initCause(e); throw ex; } catch (SyntaxException e) { InvalidRequestException ex = new InvalidRequestException(e.toString()); ex.initCause(e); throw ex; } } return columnDefs; }
defs.add(ColumnDefinition.regularDef(ks, cf, SuperColumnCompatibility.SUPER_COLUMN_MAP_COLUMN_STR, MapType.getInstance(subComparator, defaultValidator, true))); if (isDense) defs.add(ColumnDefinition.regularDef(ks, cf, names.defaultCompactValueName(), defaultValidator)); defs.add(ColumnDefinition.clusteringDef(ks, cf, names.defaultClusteringName(), subTypes.get(i), i)); defs.add(ColumnDefinition.regularDef(ks, cf, names.defaultCompactValueName(), defaultValidator));