public static List<ColumnDefinition> getIndexMetadata( String indexes ) { if ( indexes == null ) { return null; } String[] index_entries = split( indexes, ',' ); List<ColumnDef> columns = new ArrayList<ColumnDef>(); for ( String index_entry : index_entries ) { String column_name = stringOrSubstringBeforeFirst( index_entry, ':' ).trim(); String comparer = substringAfterLast( index_entry, ":" ).trim(); if ( StringUtils.isBlank( comparer ) ) { comparer = "UUIDType"; } if ( StringUtils.isNotBlank( column_name ) ) { ColumnDef cd = new ColumnDef( bytebuffer( column_name ), comparer ); cd.setIndex_name( column_name ); cd.setIndex_type( IndexType.KEYS ); columns.add( cd ); } } return ThriftColumnDef.fromThriftList( columns ); }
private ColumnDef toThrift() { ColumnDef d = new ColumnDef(); if ( indexName != null ) { d.setIndex_name(indexName); d.setIndex_type(indexTypeToThrift(indexType)); } d.setName(name); d.setValidation_class(validationClass); return d; }
ColumnDef newIndexedColumnDef(String column_name, String comparer) { ColumnDef cd = new ColumnDef(se.toByteBuffer(column_name), comparer); cd.setIndex_name(column_name); cd.setIndex_type(IndexType.KEYS); return cd; }
@Override public ColumnDefinition setKeysIndex(String name) { this.columnDef.setIndex_name(name); this.columnDef.setIndex_type(IndexType.KEYS); return this; }
@Override public ColumnDefinition setKeysIndex(String name) { this.columnDef.setIndex_name(name); this.columnDef.setIndex_type(IndexType.KEYS); return this; }
@Override public ColumnDefinition setIndex(String name, String type) { this.columnDef.setIndex_name(name); this.columnDef.setIndex_type(IndexType.valueOf(type)); return this; }
@Override public ColumnDefinition setIndex(String name, String type) { this.columnDef.setIndex_name(name); this.columnDef.setIndex_type(IndexType.valueOf(type)); return this; }
private ColumnDef toThrift() { ColumnDef d = new ColumnDef(); if ( indexName != null ) { d.setIndex_name(indexName); d.setIndex_type(indexTypeToThrift(indexType)); } d.setName(name); d.setValidation_class(validationClass); return d; }
private ColumnDef toThrift() { ColumnDef d = new ColumnDef(); if ( indexName != null ) { d.setIndex_name(indexName); d.setIndex_type(indexTypeToThrift(indexType)); } d.setName(name); d.setValidation_class(validationClass); return d; }
private void executeDropIndex(Tree statement) throws TException, SchemaDisagreementException, InvalidRequestException, NotFoundException { if (!CliMain.isConnected() || !hasKeySpace()) return; // getColumnFamily will check if CF exists for us String columnFamily = CliCompiler.getColumnFamily(statement, currentCfDefs()); String rawColumName = CliUtils.unescapeSQLString(statement.getChild(1).getText()); CfDef cfDef = getCfDef(columnFamily); ByteBuffer columnName = columnNameAsBytes(rawColumName, cfDef); boolean foundColumn = false; for (ColumnDef column : cfDef.getColumn_metadata()) { if (column.name.equals(columnName)) { foundColumn = true; if (column.getIndex_type() == null) throw new RuntimeException(String.format("Column '%s' does not have an index.", rawColumName)); column.setIndex_name(null); column.setIndex_type(null); } } if (!foundColumn) throw new RuntimeException(String.format("Column '%s' definition was not found in ColumnFamily '%s'.", rawColumName, columnFamily)); String mySchemaVersion = thriftClient.system_update_column_family(cfDef); sessionState.out.println(mySchemaVersion); keyspacesMap.put(keySpace, thriftClient.describe_keyspace(keySpace)); }
/** * Private helper that adds a c olumn to a column family definition * * @param colAnnotation the column annotation * @param property the property * @param indexed if this property should be indexed in the datastore */ private void addColumnToColumnFamilyDefinition(Column colAnnotation, String property, boolean indexed) throws ClassNotFoundException { if (!property.equals(keyProperty)) { boolean defaults = colAnnotation == null; ColumnDef columnDef = new ColumnDef(); columnDef.setName(StringSerializer.get().toByteBuffer(property)); columnDef.setValidation_class(defaults ? org.firebrandocm.dao.annotations.Column.DEFAULTS.VALIDATION_CLASS.getName() : colAnnotation.validationClass().getName()); indexed = indexed || isMappedContainer(property); if (!indexed) { indexed = defaults ? org.firebrandocm.dao.annotations.Column.DEFAULTS.INDEXED : colAnnotation.indexed(); } if (indexed) { columnDef.setIndex_name(String.format("%s_%s_%s", keySpace, columnFamily, property)); columnDef.setIndex_type(defaults ? org.firebrandocm.dao.annotations.Column.DEFAULTS.INDEX_TYPE : colAnnotation.indexType()); } columnFamilyDefinition.addToColumn_metadata(columnDef); } }
cd.setIndex_name(matchedIndex.name); Map<String, String> filteredOptions = Maps.filterKeys(matchedIndex.options, s -> !IndexTarget.TARGET_OPTION_NAME.equals(s));
cd.setIndex_name(matchedIndex.name); Map<String, String> filteredOptions = Maps.filterKeys(matchedIndex.options, s -> !IndexTarget.TARGET_OPTION_NAME.equals(s));
columnDefinition.setIndex_name(metaVal);
colDef.setName(indexedColumnStr.getBytes()); colDef.index_type = IndexType.KEYS; colDef.setIndex_name(keyspace + "_" + this.columnFamily + "_" + indexedColumnStr + "_INDEX"); columnMetadata.add(colDef);
public ColumnDef toThrift() { ColumnDef cd = new ColumnDef(); cd.setName(ByteBufferUtil.clone(name.bytes)); cd.setValidation_class(type.toString()); cd.setIndex_type(indexType == null ? null : org.apache.cassandra.thrift.IndexType.valueOf(indexType.name())); cd.setIndex_name(indexName == null ? null : indexName); cd.setIndex_options(indexOptions == null ? null : Maps.newHashMap(indexOptions)); return cd; }
unsetIndex_name(); } else { setIndex_name((String)value);
unsetIndex_name(); } else { setIndex_name((String)value);
unsetIndex_name(); } else { setIndex_name((String)value);