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


Java SetType类代码示例

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


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

示例1: validateAssignableTo

import org.apache.cassandra.db.marshal.SetType; //导入依赖的package包/类
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException
{
    if (!(receiver.type instanceof SetType))
    {
        // We've parsed empty maps as a set literal to break the ambiguity so
        // handle that case now
        if ((receiver.type instanceof MapType) && elements.isEmpty())
            return;

        throw new InvalidRequestException(String.format("Invalid set literal for %s of type %s", receiver.name, receiver.type.asCQL3Type()));
    }

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

示例2: fromSerialized

import org.apache.cassandra.db.marshal.SetType; //导入依赖的package包/类
public static Value fromSerialized(ByteBuffer value, SetType 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).
        Set<?> s = (Set<?>)type.getSerializer().deserializeForNativeProtocol(value, version);
        SortedSet<ByteBuffer> elements = new TreeSet<ByteBuffer>(type.getElementsType());
        for (Object element : s)
            elements.add(type.getElementsType().decompose(element));
        return new Value(elements);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:18,代码来源:Sets.java

示例3: validateAssignableTo

import org.apache.cassandra.db.marshal.SetType; //导入依赖的package包/类
private void validateAssignableTo(ColumnSpecification receiver) throws InvalidRequestException
{
    if (!(receiver.type instanceof SetType))
    {
        // We've parsed empty maps as a set literal to break the ambiguity so
        // handle that case now
        if (receiver.type instanceof MapType && elements.isEmpty())
            return;

        throw new InvalidRequestException(String.format("Invalid set literal for %s of type %s", receiver, receiver.type.asCQL3Type()));
    }

    ColumnSpecification valueSpec = Sets.valueSpecOf(receiver);
    for (Term.Raw rt : elements)
    {
        if (!rt.isAssignableTo(valueSpec))
            throw new InvalidRequestException(String.format("Invalid set literal for %s: value %s is not of type %s", receiver, rt, valueSpec.type.asCQL3Type()));
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:20,代码来源:Sets.java

示例4: fromSerialized

import org.apache.cassandra.db.marshal.SetType; //导入依赖的package包/类
public static Value fromSerialized(ByteBuffer value, SetType 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).
        Set<?> s = (Set<?>)type.compose(value);
        Set<ByteBuffer> elements = new LinkedHashSet<ByteBuffer>(s.size());
        for (Object element : s)
            elements.add(type.elements.decompose(element));
        return new Value(elements);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:18,代码来源:Sets.java

示例5: validateAssignableTo

import org.apache.cassandra.db.marshal.SetType; //导入依赖的package包/类
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException
{
    if (!(receiver.type instanceof SetType))
    {
        // We've parsed empty maps as a set literal to break the ambiguity so
        // handle that case now
        if (receiver.type instanceof MapType && elements.isEmpty())
            return;

        throw new InvalidRequestException(String.format("Invalid set literal for %s of type %s", receiver.name, receiver.type.asCQL3Type()));
    }

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

示例6: testAssignment

import org.apache.cassandra.db.marshal.SetType; //导入依赖的package包/类
public AssignmentTestable.TestResult testAssignment(String keyspace, ColumnSpecification receiver)
{
    if (!(receiver.type instanceof SetType))
    {
        // We've parsed empty maps as a set literal to break the ambiguity so handle that case now
        if (receiver.type instanceof MapType && elements.isEmpty())
            return AssignmentTestable.TestResult.WEAKLY_ASSIGNABLE;

        return AssignmentTestable.TestResult.NOT_ASSIGNABLE;
    }

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

    ColumnSpecification valueSpec = Sets.valueSpecOf(receiver);
    return AssignmentTestable.TestResult.testAll(keyspace, valueSpec, elements);
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:19,代码来源:Sets.java

示例7: fromSerialized

import org.apache.cassandra.db.marshal.SetType; //导入依赖的package包/类
public static Value fromSerialized(ByteBuffer value, SetType 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).
        Set<?> s = (Set<?>)type.getSerializer().deserializeForNativeProtocol(value, version);
        Set<ByteBuffer> elements = new LinkedHashSet<ByteBuffer>(s.size());
        for (Object element : s)
            elements.add(type.elements.decompose(element));
        return new Value(elements);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:18,代码来源:Sets.java

示例8: testDataTypeSetInstantiation

import org.apache.cassandra.db.marshal.SetType; //导入依赖的package包/类
public void testDataTypeSetInstantiation() {
    DataType type = DataType.set(DataType.text());

    CellValidator cv = cellValidator(type);
    assertNotNull(cv);
    assertEquals(cv.getValidatorClassName(), SetType.class.getName());
    assertNotNull(cv.getValidatorTypes());
    assertEquals(cv.validatorKind(), Kind.SET);
    assertEquals(cv.getValidatorTypes().size(), 1);
    assertEquals(cv.getValidatorTypes().iterator().next(), "text");
    assertEquals(DataType.Name.SET, cv.getCqlTypeName());

    try {
        Collection<String> types = cv.getValidatorTypes();
        types.add("test");
        fail("Validator types collection must be inmutable");
    } catch (Exception ex) {
        // ok
    }

    //        assertNotNull(cv.getAbstractType());
    //        assertEquals(cv.getAbstractType(), SetType.getInstance(UTF8Type.instance));
}
 
开发者ID:Stratio,项目名称:deep-spark,代码行数:24,代码来源:CellValidatorTest.java

示例9: testValidatorClassToKind

import org.apache.cassandra.db.marshal.SetType; //导入依赖的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

示例10: fromSerialized

import org.apache.cassandra.db.marshal.SetType; //导入依赖的package包/类
public static Value fromSerialized(ByteBuffer value, SetType 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).
        Set<?> s = type.compose(value);
        Set<ByteBuffer> elements = new LinkedHashSet<ByteBuffer>(s.size());
        for (Object element : s)
            elements.add(type.elements.decompose(element));
        return new Value(elements);
    }
    catch (MarshalException e)
    {
        throw new InvalidRequestException(e.getMessage());
    }
}
 
开发者ID:dprguiuc,项目名称:Cassandra-Wasef,代码行数:18,代码来源:Sets.java

示例11: supports

import org.apache.cassandra.db.marshal.SetType; //导入依赖的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

示例12: validateAssignableTo

import org.apache.cassandra.db.marshal.SetType; //导入依赖的package包/类
private void validateAssignableTo(String keyspace, ColumnSpecification receiver) throws InvalidRequestException
{
    if (!(receiver.type instanceof SetType))
    {
        // We've parsed empty maps as a set literal to break the ambiguity so
        // handle that case now
        if (receiver.type instanceof MapType && elements.isEmpty())
            return;

        throw new InvalidRequestException(String.format("Invalid set literal for %s of type %s", receiver, receiver.type.asCQL3Type()));
    }

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

示例13: prepare

import org.apache.cassandra.db.marshal.SetType; //导入依赖的package包/类
public Term prepare(String keyspace, ColumnSpecification receiver) throws InvalidRequestException
{
    validateAssignableTo(keyspace, receiver);

    // We've parsed empty maps as a set literal to break the ambiguity so
    // handle that case now
    if (receiver.type instanceof MapType && elements.isEmpty())
        return new Maps.Value(Collections.<ByteBuffer, ByteBuffer>emptyMap());

    ColumnSpecification valueSpec = Sets.valueSpecOf(receiver);
    Set<Term> values = new HashSet<Term>(elements.size());
    boolean allTerminal = true;
    for (Term.Raw rt : elements)
    {
        Term t = rt.prepare(keyspace, valueSpec);

        if (t.containsBindMarker())
            throw new InvalidRequestException(String.format("Invalid set literal for %s: bind variables are not supported inside collection literals", receiver.name));

        if (t instanceof Term.NonTerminal)
            allTerminal = false;

        values.add(t);
    }
    DelayedValue value = new DelayedValue(((SetType)receiver.type).getElementsType(), values);
    return allTerminal ? value.bind(QueryOptions.DEFAULT) : value;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:28,代码来源:Sets.java

示例14: equals

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

    Iterator<ByteBuffer> thisIter = elements.iterator();
    Iterator<ByteBuffer> thatIter = v.elements.iterator();
    AbstractType elementsType = st.getElementsType();
    while (thisIter.hasNext())
        if (elementsType.compare(thisIter.next(), thatIter.next()) != 0)
            return false;

    return true;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:15,代码来源:Sets.java

示例15: makeTerminal

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