use of org.apache.cassandra.db.marshal.UserType in project cassandra by apache.
the class CQLSSTableWriter method getUDType.
/**
* Returns the User Defined type, used in this SSTable Writer, that can
* be used to create UDTValue instances.
*
* @param dataType name of the User Defined type
* @return user defined type
*/
public com.datastax.driver.core.UserType getUDType(String dataType) {
KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(insert.keyspace());
UserType userType = ksm.types.getNullable(ByteBufferUtil.bytes(dataType));
return (com.datastax.driver.core.UserType) UDHelper.driverType(userType);
}
use of org.apache.cassandra.db.marshal.UserType in project cassandra by apache.
the class CQLTypeParser method parse.
public static AbstractType<?> parse(String keyspace, String unparsed, Types userTypes) {
String lowercased = unparsed.toLowerCase();
// fast path for the common case of a primitive type
if (PRIMITIVE_TYPES.contains(lowercased))
return CQL3Type.Native.valueOf(unparsed.toUpperCase()).getType();
// special-case top-level UDTs
UserType udt = userTypes.getNullable(bytes(lowercased));
if (udt != null)
return udt;
return parseRaw(unparsed).prepareInternal(keyspace, userTypes).getType();
}
use of org.apache.cassandra.db.marshal.UserType in project cassandra by apache.
the class StressCQLSSTableWriter method getUDType.
/**
* Returns the User Defined type, used in this SSTable Writer, that can
* be used to create UDTValue instances.
*
* @param dataType name of the User Defined type
* @return user defined type
*/
public com.datastax.driver.core.UserType getUDType(String dataType) {
KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(insert.keyspace());
UserType userType = ksm.types.getNullable(ByteBufferUtil.bytes(dataType));
return (com.datastax.driver.core.UserType) UDHelper.driverType(userType);
}
use of org.apache.cassandra.db.marshal.UserType in project cassandra by apache.
the class UserTypeSelector method getOutput.
public ByteBuffer getOutput(ProtocolVersion protocolVersion) throws InvalidRequestException {
UserType userType = (UserType) type;
ByteBuffer[] buffers = new ByteBuffer[userType.size()];
for (int i = 0, m = userType.size(); i < m; i++) {
Selector selector = fields.get(userType.fieldName(i));
if (selector != null)
buffers[i] = selector.getOutput(protocolVersion);
}
return TupleType.buildValue(buffers);
}
use of org.apache.cassandra.db.marshal.UserType in project cassandra by apache.
the class CreateTypeStatement method announceMigration.
public Event.SchemaChange announceMigration(QueryState queryState, boolean isLocalOnly) throws InvalidRequestException, ConfigurationException {
KeyspaceMetadata ksm = Schema.instance.getKeyspaceMetadata(name.getKeyspace());
// should haven't validate otherwise
assert ksm != null;
// Can happen with ifNotExists
if (ksm.types.get(name.getUserTypeName()).isPresent())
return null;
UserType type = createType();
checkForDuplicateNames(type);
MigrationManager.announceNewType(type, isLocalOnly);
return new Event.SchemaChange(Event.SchemaChange.Change.CREATED, Event.SchemaChange.Target.TYPE, keyspace(), name.getStringTypeName());
}
Aggregations