本文整理汇总了Java中org.apache.cassandra.thrift.ThriftValidation.validateColumnFamily方法的典型用法代码示例。如果您正苦于以下问题:Java ThriftValidation.validateColumnFamily方法的具体用法?Java ThriftValidation.validateColumnFamily怎么用?Java ThriftValidation.validateColumnFamily使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.thrift.ThriftValidation
的用法示例。
在下文中一共展示了ThriftValidation.validateColumnFamily方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepare
import org.apache.cassandra.thrift.ThriftValidation; //导入方法依赖的package包/类
public ParsedStatement.Prepared prepare(ColumnSpecification[] boundNames) throws InvalidRequestException
{
CFMetaData metadata = ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
type = metadata.getDefaultValidator().isCommutative() ? Type.COUNTER : Type.LOGGED;
cfDef = metadata.getCfDef();
UpdateStatement.processKeys(cfDef, whereClause, processedKeys, boundNames);
for (Operation.RawDeletion deletion : deletions)
{
CFDefinition.Name name = cfDef.get(deletion.affectedColumn());
if (name == null)
throw new InvalidRequestException(String.format("Unknown identifier %s", deletion.affectedColumn()));
// For compact, we only have one value except the key, so the only form of DELETE that make sense is without a column
// list. However, we support having the value name for coherence with the static/sparse case
if (name.kind != CFDefinition.Name.Kind.COLUMN_METADATA && name.kind != CFDefinition.Name.Kind.VALUE_ALIAS)
throw new InvalidRequestException(String.format("Invalid identifier %s for deletion (should not be a PRIMARY KEY part)", name));
Operation op = deletion.prepare(name);
op.collectMarkerSpecification(boundNames);
toRemove.add(op);
}
return new ParsedStatement.Prepared(this, Arrays.<ColumnSpecification>asList(boundNames));
}
示例2: validate
import org.apache.cassandra.thrift.ThriftValidation; //导入方法依赖的package包/类
public void validate(ClientState state) throws RequestValidationException
{
ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
try
{
TriggerExecutor.instance.loadTriggerInstance(triggerClass);
}
catch (Exception e)
{
throw new ConfigurationException(String.format("Trigger class '%s' doesn't exist", triggerClass));
}
}
示例3: validate
import org.apache.cassandra.thrift.ThriftValidation; //导入方法依赖的package包/类
public void validate(ClientState state) throws RequestValidationException
{
CFMetaData cfm = ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
ColumnDefinition cd = cfm.getColumnDefinition(columnName.key);
if (cd == null)
throw new InvalidRequestException("No column definition found for column " + columnName);
if (cd.getIndexType() != null)
{
if (ifNotExists)
return;
else
throw new InvalidRequestException("Index already exists");
}
if (isCustom && indexClass == null)
throw new InvalidRequestException("CUSTOM index requires specifiying the index class");
if (!isCustom && indexClass != null)
throw new InvalidRequestException("Cannot specify index class for a non-CUSTOM index");
// TODO: we could lift that limitation
if (cfm.getCfDef().isCompact && cd.type != ColumnDefinition.Type.REGULAR)
throw new InvalidRequestException(String.format("Secondary index on %s column %s is not yet supported for compact table", cd.type, columnName));
if (cd.getValidator().isCollection() && !isCustom)
throw new InvalidRequestException("Indexes on collections are no yet supported");
if (cd.type == ColumnDefinition.Type.PARTITION_KEY && cd.componentIndex == null)
throw new InvalidRequestException(String.format("Cannot add secondary index to already primarily indexed column %s", columnName));
}
示例4: prepare
import org.apache.cassandra.thrift.ThriftValidation; //导入方法依赖的package包/类
public ParsedStatement.Prepared prepare()
{
VariableSpecifications boundNames = getBoundVariables();
ModificationStatement statement = prepare(boundNames);
CFMetaData cfm = ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
return new ParsedStatement.Prepared(statement, boundNames, boundNames.getPartitionKeyBindIndexes(cfm));
}
示例5: validate
import org.apache.cassandra.thrift.ThriftValidation; //导入方法依赖的package包/类
public void validate(ClientState state) throws RequestValidationException
{
CFMetaData cfm = ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
if (cfm.isView())
throw new InvalidRequestException("Cannot CREATE TRIGGER against a materialized view");
try
{
TriggerExecutor.instance.loadTriggerInstance(triggerClass);
}
catch (Exception e)
{
throw new ConfigurationException(String.format("Trigger class '%s' doesn't exist", triggerClass));
}
}
示例6: validate
import org.apache.cassandra.thrift.ThriftValidation; //导入方法依赖的package包/类
@Override
public void validate(ClientState state) throws RequestValidationException
{
CFMetaData cfm = ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
CFDefinition.Name name = cfm.getCfDef().get(columnName);
if (name == null)
throw new InvalidRequestException("No column definition found for column " + columnName);
switch (name.kind)
{
case KEY_ALIAS:
case COLUMN_ALIAS:
throw new InvalidRequestException(String.format("Cannot create index on PRIMARY KEY part %s", columnName));
case VALUE_ALIAS:
throw new InvalidRequestException(String.format("Cannot create index on column %s of compact CF", columnName));
case COLUMN_METADATA:
ColumnDefinition cd = cfm.getColumnDefinition(columnName.key);
if (cd.getIndexType() != null)
throw new InvalidRequestException("Index already exists");
if (isCustom && indexClass == null)
throw new InvalidRequestException("CUSTOM index requires specifiying the index class");
if (!isCustom && indexClass != null)
throw new InvalidRequestException("Cannot specify index class for a non-CUSTOM index");
if (cd.getValidator().isCollection() && !isCustom)
throw new InvalidRequestException("Indexes on collections are no yet supported");
break;
default:
throw new AssertionError();
}
}
示例7: validate
import org.apache.cassandra.thrift.ThriftValidation; //导入方法依赖的package包/类
@Override
public void validate(ClientState state) throws RequestValidationException
{
CFMetaData cfm = ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
if (cfm.getDefaultValidator().isCommutative())
throw new InvalidRequestException("Secondary indexes are not supported on counter tables");
CFDefinition.Name name = cfm.getCfDef().get(columnName);
if (name == null)
throw new InvalidRequestException("No column definition found for column " + columnName);
switch (name.kind)
{
case KEY_ALIAS:
case COLUMN_ALIAS:
throw new InvalidRequestException(String.format("Cannot create index on PRIMARY KEY part %s", columnName));
case VALUE_ALIAS:
throw new InvalidRequestException(String.format("Cannot create index on column %s of compact CF", columnName));
case COLUMN_METADATA:
ColumnDefinition cd = cfm.getColumnDefinition(columnName.key);
if (cd.getIndexType() != null)
throw new InvalidRequestException("Index already exists");
if (isCustom && indexClass == null)
throw new InvalidRequestException("CUSTOM index requires specifiying the index class");
if (!isCustom && indexClass != null)
throw new InvalidRequestException("Cannot specify index class for a non-CUSTOM index");
if (cd.getValidator().isCollection() && !isCustom)
throw new InvalidRequestException("Indexes on collections are no yet supported");
break;
default:
throw new AssertionError();
}
}
示例8: validate
import org.apache.cassandra.thrift.ThriftValidation; //导入方法依赖的package包/类
public void validate(ClientState state) throws RequestValidationException
{
CFMetaData cfm = ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
if (cfm.isCounter())
throw new InvalidRequestException("Secondary indexes are not supported on counter tables");
IndexTarget target = rawTarget.prepare(cfm);
ColumnDefinition cd = cfm.getColumnDefinition(target.column);
if (cd == null)
throw new InvalidRequestException("No column definition found for column " + target.column);
boolean isMap = cd.type instanceof MapType;
boolean isFrozenCollection = cd.type.isCollection() && !cd.type.isMultiCell();
if (target.isCollectionKeys)
{
if (!isMap)
throw new InvalidRequestException("Cannot create index on keys of column " + target + " with non-map type");
if (!cd.type.isMultiCell())
throw new InvalidRequestException("Cannot create index on keys of frozen<map> column " + target);
}
else if (target.isFullCollection)
{
if (!isFrozenCollection)
throw new InvalidRequestException("full() indexes can only be created on frozen collections");
}
else if (isFrozenCollection)
{
throw new InvalidRequestException("Frozen collections currently only support full-collection indexes. " +
"For example, 'CREATE INDEX ON <table>(full(<columnName>))'.");
}
if (cd.getIndexType() != null)
{
boolean previousIsKeys = cd.hasIndexOption(SecondaryIndex.INDEX_KEYS_OPTION_NAME);
if (isMap && target.isCollectionKeys != previousIsKeys)
{
String msg = "Cannot create index on %s %s, an index on %s %s already exists and indexing "
+ "a map on both keys and values at the same time is not currently supported";
throw new InvalidRequestException(String.format(msg,
target.column, target.isCollectionKeys ? "keys" : "values",
target.column, previousIsKeys ? "keys" : "values"));
}
if (ifNotExists)
return;
else
throw new InvalidRequestException("Index already exists");
}
properties.validate();
// TODO: we could lift that limitation
if ((cfm.comparator.isDense() || !cfm.comparator.isCompound()) && cd.kind != ColumnDefinition.Kind.REGULAR)
throw new InvalidRequestException("Secondary indexes are not supported on PRIMARY KEY columns in COMPACT STORAGE tables");
// It would be possible to support 2ndary index on static columns (but not without modifications of at least ExtendedFilter and
// CompositesIndex) and maybe we should, but that means a query like:
// SELECT * FROM foo WHERE static_column = 'bar'
// would pull the full partition every time the static column of partition is 'bar', which sounds like offering a
// fair potential for foot-shooting, so I prefer leaving that to a follow up ticket once we have identified cases where
// such indexing is actually useful.
if (cd.isStatic())
throw new InvalidRequestException("Secondary indexes are not allowed on static columns");
if (cd.kind == ColumnDefinition.Kind.PARTITION_KEY && cd.isOnAllComponents())
throw new InvalidRequestException(String.format("Cannot create secondary index on partition key column %s", target.column));
}
示例9: validate
import org.apache.cassandra.thrift.ThriftValidation; //导入方法依赖的package包/类
public void validate(ClientState state) throws RequestValidationException
{
ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
}
示例10: validate
import org.apache.cassandra.thrift.ThriftValidation; //导入方法依赖的package包/类
public void validate(ClientState state) throws InvalidRequestException
{
ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
}
示例11: hasColumnFamilyAccess
import org.apache.cassandra.thrift.ThriftValidation; //导入方法依赖的package包/类
public void hasColumnFamilyAccess(String keyspace, String columnFamily, Permission perm)
throws UnauthorizedException, InvalidRequestException
{
ThriftValidation.validateColumnFamily(keyspace, columnFamily);
hasAccess(keyspace, perm, DataResource.columnFamily(keyspace, columnFamily));
}
示例12: validate
import org.apache.cassandra.thrift.ThriftValidation; //导入方法依赖的package包/类
public void validate(ClientState state) throws RequestValidationException
{
CFMetaData cfm = ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
if (cfm.isCounter())
throw new InvalidRequestException("Secondary indexes are not supported on counter tables");
if (cfm.isView())
throw new InvalidRequestException("Secondary indexes are not supported on materialized views");
if (cfm.isCompactTable() && !cfm.isStaticCompactTable())
throw new InvalidRequestException("Secondary indexes are not supported on COMPACT STORAGE tables that have clustering columns");
List<IndexTarget> targets = new ArrayList<>(rawTargets.size());
for (IndexTarget.Raw rawTarget : rawTargets)
targets.add(rawTarget.prepare(cfm));
if (targets.isEmpty() && !properties.isCustom)
throw new InvalidRequestException("Only CUSTOM indexes can be created without specifying a target column");
if (targets.size() > 1)
validateTargetsForMultiColumnIndex(targets);
for (IndexTarget target : targets)
{
ColumnDefinition cd = cfm.getColumnDefinition(target.column);
if (cd == null)
throw new InvalidRequestException("No column definition found for column " + target.column);
// TODO: we could lift that limitation
if (cfm.isCompactTable() && cd.isPrimaryKeyColumn())
throw new InvalidRequestException("Secondary indexes are not supported on PRIMARY KEY columns in COMPACT STORAGE tables");
// It would be possible to support 2ndary index on static columns (but not without modifications of at least ExtendedFilter and
// CompositesIndex) and maybe we should, but that means a query like:
// SELECT * FROM foo WHERE static_column = 'bar'
// would pull the full partition every time the static column of partition is 'bar', which sounds like offering a
// fair potential for foot-shooting, so I prefer leaving that to a follow up ticket once we have identified cases where
// such indexing is actually useful.
if (!cfm.isCompactTable() && cd.isStatic())
throw new InvalidRequestException("Secondary indexes are not allowed on static columns");
if (cd.kind == ColumnDefinition.Kind.PARTITION_KEY && cfm.getKeyValidatorAsClusteringComparator().size() == 1)
throw new InvalidRequestException(String.format("Cannot create secondary index on partition key column %s", target.column));
boolean isMap = cd.type instanceof MapType;
boolean isFrozenCollection = cd.type.isCollection() && !cd.type.isMultiCell();
if (isFrozenCollection)
{
validateForFrozenCollection(target);
}
else
{
validateNotFullIndex(target);
validateIsSimpleIndexIfTargetColumnNotCollection(cd, target);
validateTargetColumnIsMapIfIndexInvolvesKeys(isMap, target);
}
}
if (!Strings.isNullOrEmpty(indexName))
{
if (Schema.instance.getKSMetaData(keyspace()).existingIndexNames(null).contains(indexName))
{
if (ifNotExists)
return;
else
throw new InvalidRequestException(String.format("Index %s already exists", indexName));
}
}
properties.validate();
}
示例13: hasColumnFamilyAccess
import org.apache.cassandra.thrift.ThriftValidation; //导入方法依赖的package包/类
public void hasColumnFamilyAccess(String keyspace, String columnFamily, Permission perm)
throws UnauthorizedException, InvalidRequestException
{
ThriftValidation.validateColumnFamily(keyspace, columnFamily);
hasAccess(keyspace, perm, DataResource.table(keyspace, columnFamily));
}
示例14: validate
import org.apache.cassandra.thrift.ThriftValidation; //导入方法依赖的package包/类
public void validate(ClientState state) throws RequestValidationException
{
CFMetaData cfm = ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
if (cfm.isCounter())
throw new InvalidRequestException("Secondary indexes are not supported on counter tables");
ColumnDefinition cd = cfm.getColumnDefinition(target.column);
if (cd == null)
throw new InvalidRequestException("No column definition found for column " + target.column);
boolean isMap = cd.type instanceof MapType;
if (target.isCollectionKeys && !isMap)
throw new InvalidRequestException("Cannot create index on keys of column " + target + " with non map type");
if (cd.getIndexType() != null)
{
boolean previousIsKeys = cd.getIndexOptions().containsKey("index_keys");
if (isMap && target.isCollectionKeys != previousIsKeys)
{
String msg = "Cannot create index on %s %s, an index on %s %s already exists and indexing "
+ "a map on both keys and values at the same time is not currently supported";
throw new InvalidRequestException(String.format(msg,
target.column, target.isCollectionKeys ? "keys" : "values",
target.column, previousIsKeys ? "keys" : "values"));
}
if (ifNotExists)
return;
else
throw new InvalidRequestException("Index already exists");
}
properties.validate();
// TODO: we could lift that limitation
if (cfm.comparator.isDense() && cd.kind != ColumnDefinition.Kind.REGULAR)
throw new InvalidRequestException(String.format("Secondary index on %s column %s is not yet supported for compact table", cd.kind, target.column));
// It would be possible to support 2ndary index on static columns (but not without modifications of at least ExtendedFilter and
// CompositesIndex) and maybe we should, but that means a query like:
// SELECT * FROM foo WHERE static_column = 'bar'
// would pull the full partition every time the static column of partition is 'bar', which sounds like offering a
// fair potential for foot-shooting, so I prefer leaving that to a follow up ticket once we have identified cases where
// such indexing is actually useful.
if (cd.isStatic())
throw new InvalidRequestException("Secondary indexes are not allowed on static columns");
if (cd.kind == ColumnDefinition.Kind.PARTITION_KEY && cd.isOnAllComponents())
throw new InvalidRequestException(String.format("Cannot add secondary index to already primarily indexed column %s", target.column));
}
示例15: validate
import org.apache.cassandra.thrift.ThriftValidation; //导入方法依赖的package包/类
public void validate(ClientState state) throws RequestValidationException
{
CFMetaData cfm = ThriftValidation.validateColumnFamily(keyspace(), columnFamily());
if (cfm.isCounter())
throw new InvalidRequestException("Secondary indexes are not supported on counter tables");
IndexTarget target = rawTarget.prepare(cfm);
ColumnDefinition cd = cfm.getColumnDefinition(target.column);
if (cd == null)
throw new InvalidRequestException("No column definition found for column " + target.column);
boolean isMap = cd.type instanceof MapType;
boolean isFrozenCollection = cd.type.isCollection() && !cd.type.isMultiCell();
if (target.isCollectionKeys)
{
if (!isMap)
throw new InvalidRequestException("Cannot create index on keys of column " + target + " with non-map type");
if (!cd.type.isMultiCell())
throw new InvalidRequestException("Cannot create index on keys of frozen<map> column " + target);
}
else if (target.isFullCollection)
{
if (!isFrozenCollection)
throw new InvalidRequestException("full() indexes can only be created on frozen collections");
}
else if (isFrozenCollection)
{
throw new InvalidRequestException("Frozen collections currently only support full-collection indexes. " +
"For example, 'CREATE INDEX ON <table>(full(<columnName>))'.");
}
if (cd.getIndexType() != null)
{
boolean previousIsKeys = cd.hasIndexOption(SecondaryIndex.INDEX_KEYS_OPTION_NAME);
if (isMap && target.isCollectionKeys != previousIsKeys)
{
String msg = "Cannot create index on %s %s, an index on %s %s already exists and indexing "
+ "a map on both keys and values at the same time is not currently supported";
throw new InvalidRequestException(String.format(msg,
target.column, target.isCollectionKeys ? "keys" : "values",
target.column, previousIsKeys ? "keys" : "values"));
}
if (ifNotExists)
return;
else
throw new InvalidRequestException("Index already exists");
}
properties.validate(cfm);
// TODO: we could lift that limitation
if ((cfm.comparator.isDense() || !cfm.comparator.isCompound()) && cd.kind != ColumnDefinition.Kind.REGULAR)
throw new InvalidRequestException("Secondary indexes are not supported on PRIMARY KEY columns in COMPACT STORAGE tables");
// It would be possible to support 2ndary index on static columns (but not without modifications of at least ExtendedFilter and
// CompositesIndex) and maybe we should, but that means a query like:
// SELECT * FROM foo WHERE static_column = 'bar'
// would pull the full partition every time the static column of partition is 'bar', which sounds like offering a
// fair potential for foot-shooting, so I prefer leaving that to a follow up ticket once we have identified cases where
// such indexing is actually useful.
if (cd.isStatic())
throw new InvalidRequestException("Secondary indexes are not allowed on static columns");
if (cd.kind == ColumnDefinition.Kind.PARTITION_KEY && cd.isOnAllComponents())
throw new InvalidRequestException(String.format("Cannot create secondary index on partition key column %s", target.column));
}