• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java UserType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: updateType

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

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

    ksm.userTypes.addType(ut);

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


示例17: dropType

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

    ksm.userTypes.removeType(ut);

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


示例18: newFactory

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
public static Factory newFactory(final UserType type, final int field, final Selector.Factory factory)
{
    return new Factory()
    {
        protected String getColumnName()
        {
            return String.format("%s.%s",
                                 factory.getColumnName(),
                                 UTF8Type.instance.getString(type.fieldName(field)));
        }

        protected AbstractType<?> getReturnType()
        {
            return type.fieldType(field);
        }

        protected void addColumnMapping(SelectionColumnMapping mapping, ColumnSpecification resultsColumn)
        {
            factory.addColumnMapping(mapping, resultsColumn);
        }

        public Selector newInstance() throws InvalidRequestException
        {
            return new FieldSelector(type, field, factory.newInstance());
        }

        public boolean isAggregateSelectorFactory()
        {
            return factory.isAggregateSelectorFactory();
        }
    };
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:33,代码来源:FieldSelector.java


示例19: notifyUpdateUserType

import org.apache.cassandra.db.marshal.UserType; //导入依赖的package包/类
public void notifyUpdateUserType(UserType ut)
{
    for (MigrationListener listener : listeners)
        listener.onUpdateUserType(ut.keyspace, ut.getNameAsString());

    // FIXME: remove when we get rid of AbstractType in metadata. Doesn't really belong anywhere.
    Schema.instance.getKSMetaData(ut.keyspace).functions.udfs().forEach(f -> f.userTypeUpdated(ut.keyspace, ut.getNameAsString()));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:9,代码来源:MigrationManager.java


示例20: prepare

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

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

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java LogContainerCmd类代码示例发布时间:2022-05-23
下一篇:
Java SaajSoapMessage类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap