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


Java ListType类代码示例

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


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

示例1: fromSerialized

import org.apache.cassandra.db.marshal.ListType; //导入依赖的package包/类
public static Value fromSerialized(ByteBuffer value, ListType type, ProtocolVersion version) throws InvalidRequestException
{
    try
    {
        // Collections have this small hack that validate cannot be called on a serialized object,
        // but compose does the validation (so we're fine).
        List<?> l = type.getSerializer().deserializeForNativeProtocol(value, version);
        List<ByteBuffer> elements = new ArrayList<>(l.size());
        for (Object element : l)
            // elements can be null in lists that represent a set of IN values
            elements.add(element == null ? null : type.getElementsType().decompose(element));
        return new Value(elements);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:19,代码来源:Lists.java

示例2: fromSerialized

import org.apache.cassandra.db.marshal.ListType; //导入依赖的package包/类
public static Value fromSerialized(ByteBuffer value, ListType type, int version) throws InvalidRequestException
{
    try
    {
        // Collections have this small hack that validate cannot be called on a serialized object,
        // but compose does the validation (so we're fine).
        List<?> l = (List<?>)type.getSerializer().deserializeForNativeProtocol(value, version);
        List<ByteBuffer> elements = new ArrayList<ByteBuffer>(l.size());
        for (Object element : l)
            // elements can be null in lists that represent a set of IN values
            elements.add(element == null ? null : type.getElementsType().decompose(element));
        return new Value(elements);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:19,代码来源:Lists.java

示例3: fromSerialized

import org.apache.cassandra.db.marshal.ListType; //导入依赖的package包/类
public static Value fromSerialized(ByteBuffer value, ListType type) throws InvalidRequestException
{
    try
    {
        // Collections have this small hack that validate cannot be called on a serialized object,
        // but compose does the validation (so we're fine).
        List<?> l = (List<?>)type.compose(value);
        List<ByteBuffer> elements = new ArrayList<ByteBuffer>(l.size());
        for (Object element : l)
            elements.add(type.elements.decompose(element));
        return new Value(elements);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:18,代码来源:Lists.java

示例4: fromSerialized

import org.apache.cassandra.db.marshal.ListType; //导入依赖的package包/类
public static Value fromSerialized(ByteBuffer value, ListType type, int version) throws InvalidRequestException
{
    try
    {
        // Collections have this small hack that validate cannot be called on a serialized object,
        // but compose does the validation (so we're fine).
        List<?> l = type.getSerializer().deserializeForNativeProtocol(value, version);
        List<ByteBuffer> elements = new ArrayList<>(l.size());
        for (Object element : l)
            // elements can be null in lists that represent a set of IN values
            elements.add(element == null ? null : type.getElementsType().decompose(element));
        return new Value(elements);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:19,代码来源:Lists.java

示例5: fromSerialized

import org.apache.cassandra.db.marshal.ListType; //导入依赖的package包/类
public static Value fromSerialized(ByteBuffer value, ListType type, int version) throws InvalidRequestException
{
    try
    {
        // Collections have this small hack that validate cannot be called on a serialized object,
        // but compose does the validation (so we're fine).
        List<?> l = (List<?>)type.getSerializer().deserializeForNativeProtocol(value, version);
        List<ByteBuffer> elements = new ArrayList<ByteBuffer>(l.size());
        for (Object element : l)
            // elements can be null in lists that represent a set of IN values
            elements.add(element == null ? null : type.elements.decompose(element));
        return new Value(elements);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:19,代码来源:Lists.java

示例6: testValidatorClassToKind

import org.apache.cassandra.db.marshal.ListType; //导入依赖的package包/类
public void testValidatorClassToKind() {
    assertEquals(Kind.validatorClassToKind(null), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(TimeUUIDType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(UTF8Type.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(Int32Type.class), Kind.NOT_A_COLLECTION);

    assertEquals(Kind.validatorClassToKind(BooleanType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(TimestampType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(DecimalType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(LongType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(DoubleType.class), Kind.NOT_A_COLLECTION);

    assertEquals(Kind.validatorClassToKind(FloatType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(InetAddressType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(IntegerType.class), Kind.NOT_A_COLLECTION);
    assertEquals(Kind.validatorClassToKind(UUIDType.class), Kind.NOT_A_COLLECTION);

    assertEquals(Kind.validatorClassToKind(SetType.class), Kind.SET);
    assertEquals(Kind.validatorClassToKind(ListType.class), Kind.LIST);
    assertEquals(Kind.validatorClassToKind(MapType.class), Kind.MAP);
}
 
开发者ID:Stratio,项目名称:deep-spark,代码行数:22,代码来源:CellValidatorTest.java

示例7: fromSerialized

import org.apache.cassandra.db.marshal.ListType; //导入依赖的package包/类
public static Value fromSerialized(ByteBuffer value, ListType type) throws InvalidRequestException
{
    try
    {
        // Collections have this small hack that validate cannot be called on a serialized object,
        // but compose does the validation (so we're fine).
        List<?> l = type.compose(value);
        List<ByteBuffer> elements = new ArrayList<ByteBuffer>(l.size());
        for (Object element : l)
            elements.add(type.elements.decompose(element));
        return new Value(elements);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:18,代码来源:Lists.java

示例8: supports

import org.apache.cassandra.db.marshal.ListType; //导入依赖的package包/类
/**
 * Returns {@code true} if the specified Cassandra type/marshaller is supported, {@code false} otherwise.
 *
 * @param type A Cassandra type/marshaller.
 * @return {@code true} if the specified Cassandra type/marshaller is supported, {@code false} otherwise.
 */
public boolean supports(final AbstractType<?> type) {
    AbstractType<?> checkedType = type;
    if (type.isCollection()) {
        if (type instanceof MapType<?, ?>) {
            checkedType = ((MapType<?, ?>) type).getValuesType();
        } else if (type instanceof ListType<?>) {
            checkedType = ((ListType<?>) type).getElementsType();
        } else if (type instanceof SetType) {
            checkedType = ((SetType<?>) type).getElementsType();
        }
    }

    if (type instanceof ReversedType) {
        ReversedType reversedType = (ReversedType) type;
        checkedType = reversedType.baseType;
    }

    for (AbstractType<?> n : supportedTypes) {
        if (checkedType.getClass() == n.getClass()) {
            return true;
        }
    }
    return false;
}
 
开发者ID:Stratio,项目名称:stratio-cassandra,代码行数:31,代码来源:ColumnMapper.java

示例9: validateAssignableTo

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

    ColumnSpecification valueSpec = Lists.valueSpecOf(receiver);
    for (Term.Raw rt : elements)
    {
        if (!rt.testAssignment(keyspace, valueSpec).isAssignable())
            throw new InvalidRequestException(String.format("Invalid list literal for %s: value %s is not of type %s", receiver.name, rt, valueSpec.type.asCQL3Type()));
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:13,代码来源:Lists.java

示例10: testAssignment

import org.apache.cassandra.db.marshal.ListType; //导入依赖的package包/类
public AssignmentTestable.TestResult testAssignment(String keyspace, ColumnSpecification receiver)
{
    if (!(receiver.type instanceof ListType))
        return AssignmentTestable.TestResult.NOT_ASSIGNABLE;

    // If there is no elements, we can't say it's an exact match (an empty list if fundamentally polymorphic).
    if (elements.isEmpty())
        return AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE;

    ColumnSpecification valueSpec = Lists.valueSpecOf(receiver);
    return AssignmentTestable.TestResult.testAll(keyspace, valueSpec, elements);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:13,代码来源:Lists.java

示例11: getExactTypeIfKnown

import org.apache.cassandra.db.marshal.ListType; //导入依赖的package包/类
@Override
public AbstractType<?> getExactTypeIfKnown(String keyspace)
{
    for (Term.Raw term : elements)
    {
        AbstractType<?> type = term.getExactTypeIfKnown(keyspace);
        if (type != null)
            return ListType.getInstance(type, false);
    }
    return null;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:12,代码来源:Lists.java

示例12: equals

import org.apache.cassandra.db.marshal.ListType; //导入依赖的package包/类
public boolean equals(ListType lt, Value v)
{
    if (elements.size() != v.elements.size())
        return false;

    for (int i = 0; i < elements.size(); i++)
        if (lt.getElementsType().compare(elements.get(i), v.elements.get(i)) != 0)
            return false;

    return true;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:12,代码来源:Lists.java

示例13: bind

import org.apache.cassandra.db.marshal.ListType; //导入依赖的package包/类
public Terminal bind(QueryOptions options) throws InvalidRequestException
{
    ByteBuffer value = options.getValues().get(bindIndex);
    if (value == null)
        return null;
    if (value == ByteBufferUtil.UNSET_BYTE_BUFFER)
        return UNSET_VALUE;
    return Value.fromSerialized(value, (ListType)receiver.type, options.getProtocolVersion());
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:10,代码来源:Lists.java

示例14: validateAssignableTo

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

    ColumnSpecification valueSpec = Lists.valueSpecOf(receiver);
    for (Term.Raw rt : elements)
    {
        if (!rt.isAssignableTo(keyspace, valueSpec))
            throw new InvalidRequestException(String.format("Invalid list literal for %s: value %s is not of type %s", receiver.name, rt, valueSpec.type.asCQL3Type()));
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:13,代码来源:Lists.java

示例15: makeTerminal

import org.apache.cassandra.db.marshal.ListType; //导入依赖的package包/类
private static Term.Terminal makeTerminal(Function fun, ByteBuffer result, int version) throws InvalidRequestException
{
    if (!(fun.returnType() instanceof CollectionType))
        return new Constants.Value(result);

    switch (((CollectionType)fun.returnType()).kind)
    {
        case LIST: return Lists.Value.fromSerialized(result, (ListType)fun.returnType(), version);
        case SET:  return Sets.Value.fromSerialized(result, (SetType)fun.returnType(), version);
        case MAP:  return Maps.Value.fromSerialized(result, (MapType)fun.returnType(), version);
    }
    throw new AssertionError();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:14,代码来源:FunctionCall.java


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