Search in sources :

Example 1 with UserType

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);
}
Also used : KeyspaceMetadata(org.apache.cassandra.schema.KeyspaceMetadata) UserType(org.apache.cassandra.db.marshal.UserType)

Example 2 with 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();
}
Also used : UserType(org.apache.cassandra.db.marshal.UserType)

Example 3 with UserType

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);
}
Also used : KeyspaceMetadata(org.apache.cassandra.schema.KeyspaceMetadata) UserType(org.apache.cassandra.db.marshal.UserType)

Example 4 with 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);
}
Also used : UserType(org.apache.cassandra.db.marshal.UserType) ByteBuffer(java.nio.ByteBuffer)

Example 5 with UserType

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());
}
Also used : KeyspaceMetadata(org.apache.cassandra.schema.KeyspaceMetadata) UserType(org.apache.cassandra.db.marshal.UserType)

Aggregations

UserType (org.apache.cassandra.db.marshal.UserType)6 KeyspaceMetadata (org.apache.cassandra.schema.KeyspaceMetadata)3 ByteBuffer (java.nio.ByteBuffer)2 Iterables (com.google.common.collect.Iterables)1 MessageDigest (java.security.MessageDigest)1 AbstractCollection (java.util.AbstractCollection)1 Objects (java.util.Objects)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 StreamSupport (java.util.stream.StreamSupport)1 org.apache.cassandra.db (org.apache.cassandra.db)1 CollectionType (org.apache.cassandra.db.marshal.CollectionType)1 TableMetadata (org.apache.cassandra.schema.TableMetadata)1 MarshalException (org.apache.cassandra.serializers.MarshalException)1 FBUtilities (org.apache.cassandra.utils.FBUtilities)1