当前位置: 首页>>代码示例>>Java>>正文


Java UserType类代码示例

本文整理汇总了Java中org.apache.cassandra.db.marshal.UserType的典型用法代码示例。如果您正苦于以下问题:Java UserType类的具体用法?Java UserType怎么用?Java UserType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UserType类属于org.apache.cassandra.db.marshal包,在下文中一共展示了UserType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateCell

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
public void validateCell(Cell cell)
{
    if (cell.isTombstone())
    {
        if (cell.value().hasRemaining())
            throw new MarshalException("A tombstone should not have a value");
        if (cell.path() != null)
            validateCellPath(cell.path());
    }
    else if(type.isUDT())
    {
        // To validate a non-frozen UDT field, both the path and the value
        // are needed, the path being an index into an array of value types.
        ((UserType)type).validateCell(cell);
    }
    else
    {
        type.validateCellValue(cell.value());
        if (cell.path() != null)
            validateCellPath(cell.path());
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:23,代码来源:ColumnDefinition.java

示例2: validateAssignableTo

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException
{
    if (!(receiver.type instanceof UserType))
        throw new InvalidRequestException(String.format("Invalid user type literal for %s of type %s", receiver, receiver.type.asCQL3Type()));

    UserType ut = (UserType)receiver.type;
    for (int i = 0; i < ut.size(); i++)
    {
        ColumnIdentifier field = new ColumnIdentifier(ut.fieldName(i), UTF8Type.instance);
        Term.Raw value = entries.get(field);
        if (value == null)
            continue;

        ColumnSpecification fieldSpec = fieldSpecOf(receiver, i);
        if (!value.isAssignableTo(keyspace, fieldSpec))
            throw new InvalidRequestException(String.format("Invalid user type literal for %s: field %s is not of type %s", receiver, field, fieldSpec.type.asCQL3Type()));
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:19,代码来源:UserTypes.java

示例3: newSelectorFactory

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
public Selector.Factory newSelectorFactory(CFMetaData cfm,
                                           List<ColumnDefinition> defs) throws InvalidRequestException
{
    Selector.Factory factory = selected.newSelectorFactory(cfm, defs);
    AbstractType<?> type = factory.newInstance().getType();
    if (!(type instanceof UserType))
        throw new InvalidRequestException(
                String.format("Invalid field selection: %s of type %s is not a user type",
                              selected,
                              type.asCQL3Type()));

    UserType ut = (UserType) type;
    for (int i = 0; i < ut.size(); i++)
    {
        if (!ut.fieldName(i).equals(field.bytes))
            continue;
        return FieldSelector.newFactory(ut, i, factory);
    }
    throw new InvalidRequestException(String.format("%s of type %s has no field %s",
                                                    selected,
                                                    type.asCQL3Type(),
                                                    field));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:24,代码来源:Selectable.java

示例4: validateAssignableTo

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException
{
    if (!(receiver.type instanceof UserType))
        throw new InvalidRequestException(String.format("Invalid user type literal for %s of type %s", receiver, receiver.type.asCQL3Type()));

    UserType ut = (UserType)receiver.type;
    for (int i = 0; i < ut.size(); i++)
    {
        ColumnIdentifier field = new ColumnIdentifier(ut.fieldName(i), UTF8Type.instance);
        Term.Raw value = entries.get(field);
        if (value == null)
            continue;

        ColumnSpecification fieldSpec = fieldSpecOf(receiver, i);
        if (!value.testAssignment(keyspace, fieldSpec).isAssignable())
            throw new InvalidRequestException(String.format("Invalid user type literal for %s: field %s is not of type %s", receiver, field, fieldSpec.type.asCQL3Type()));
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:19,代码来源:UserTypes.java

示例5: validateAssignableTo

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException
{
    if (!(receiver.type instanceof UserType))
        throw new InvalidRequestException(String.format("Invalid user type literal for %s of type %s", receiver, receiver.type.asCQL3Type()));

    UserType ut = (UserType)receiver.type;
    for (int i = 0; i < ut.types.size(); i++)
    {
        ColumnIdentifier field = new ColumnIdentifier(ut.columnNames.get(i), UTF8Type.instance);
        Term.Raw value = entries.get(field);
        if (value == null)
            throw new InvalidRequestException(String.format("Invalid user type literal for %s: missing field %s", receiver, field));

        ColumnSpecification fieldSpec = fieldSpecOf(receiver, i);
        if (!value.isAssignableTo(keyspace, fieldSpec))
            throw new InvalidRequestException(String.format("Invalid user type literal for %s: field %s is not of type %s", receiver, field, fieldSpec.type.asCQL3Type()));
    }
}
 
开发者ID:mafernandez-stratio,项目名称:cassandra-cqlMod,代码行数:19,代码来源:UserTypes.java

示例6: with

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
/**
 * Create a Types instance with the provided type added
 */
public Types with(UserType type)
{
    if (get(type.name).isPresent())
        throw new IllegalStateException(format("Type %s already exists", type.name));

    return builder().add(this).add(type).build();
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:11,代码来源:Types.java

示例7: without

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
/**
 * Creates a Types instance with the type with the provided name removed
 */
public Types without(ByteBuffer name)
{
    UserType type =
        get(name).orElseThrow(() -> new IllegalStateException(format("Type %s doesn't exists", name)));

    return builder().add(filter(this, t -> t != type)).build();
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:11,代码来源:Types.java

示例8: equals

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
@Override
public boolean equals(Object o)
{
    if (this == o)
        return true;

    if (!(o instanceof Types))
        return false;

    Types other = (Types) o;

    if (types.size() != other.types.size())
        return false;

    Iterator<Map.Entry<ByteBuffer, UserType>> thisIter = this.types.entrySet().iterator();
    Iterator<Map.Entry<ByteBuffer, UserType>> otherIter = other.types.entrySet().iterator();
    while (thisIter.hasNext())
    {
        Map.Entry<ByteBuffer, UserType> thisNext = thisIter.next();
        Map.Entry<ByteBuffer, UserType> otherNext = otherIter.next();
        if (!thisNext.getKey().equals(otherNext.getKey()))
            return false;

        if (!thisNext.getValue().equals(otherNext.getValue(), true))  // ignore freezing
            return false;
    }
    return true;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:29,代码来源:Types.java

示例9: prepare

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
UserType prepare(String keyspace, Types types)
{
    List<FieldIdentifier> preparedFieldNames =
        fieldNames.stream()
                  .map(t -> FieldIdentifier.forInternalString(t))
                  .collect(toList());

    List<AbstractType<?>> preparedFieldTypes =
        fieldTypes.stream()
                  .map(t -> t.prepareInternal(keyspace, types).getType())
                  .collect(toList());

    return new UserType(keyspace, bytes(name), preparedFieldNames, preparedFieldTypes, true);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:15,代码来源:Types.java

示例10: parse

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
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();
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:16,代码来源:CQLTypeParser.java

示例11: getTypes

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
private static Types getTypes() {
    if (knownTypes.isEmpty()) {
        return Types.none();
    } else {
        return Types.of(knownTypes.values().toArray(new UserType[0]));
    }
}
 
开发者ID:tolbertam,项目名称:sstable-tools,代码行数:8,代码来源:CassandraUtils.java

示例12: fieldSpecOf

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
public static ColumnSpecification fieldSpecOf(ColumnSpecification column, int field)
{
    UserType ut = (UserType)column.type;
    return new ColumnSpecification(column.ksName,
                                   column.cfName,
                                   new ColumnIdentifier(column.name + "." + UTF8Type.instance.compose(ut.fieldName(field)), true),
                                   ut.fieldType(field));
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:9,代码来源:UserTypes.java

示例13: checkForDuplicateNames

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
public static void checkForDuplicateNames(UserType type) throws InvalidRequestException
{
    for (int i = 0; i < type.size() - 1; i++)
    {
        ByteBuffer fieldName = type.fieldName(i);
        for (int j = i+1; j < type.size(); j++)
        {
            if (fieldName.equals(type.fieldName(j)))
                throw new InvalidRequestException(String.format("Duplicate field name %s in type %s",
                                                                UTF8Type.instance.getString(fieldName),
                                                                UTF8Type.instance.getString(type.name)));
        }
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:15,代码来源:CreateTypeStatement.java

示例14: createType

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
private UserType createType() throws InvalidRequestException
{
    List<ByteBuffer> names = new ArrayList<>(columnNames.size());
    for (ColumnIdentifier name : columnNames)
        names.add(name.bytes);

    List<AbstractType<?>> types = new ArrayList<>(columnTypes.size());
    for (CQL3Type.Raw type : columnTypes)
        types.add(type.prepare(keyspace()).getType());

    return new UserType(name.getKeyspace(), name.getUserTypeName(), names, types);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:13,代码来源:CreateTypeStatement.java

示例15: addType

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
private static void addType(UserType ut)
{
    KSMetaData ksm = Schema.instance.getKSMetaData(ut.keyspace);
    assert ksm != null;

    logger.info("Loading {}", ut);

    ksm.userTypes.addType(ut);

    if (!StorageService.instance.isClientMode())
        MigrationManager.instance.notifyCreateUserType(ut);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:13,代码来源:DefsTables.java


注:本文中的org.apache.cassandra.db.marshal.UserType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。