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


Java UTF8Type.instance方法代码示例

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


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

示例1: testEmptyVariableLengthTypes

import org.apache.cassandra.db.marshal.UTF8Type; //导入方法依赖的package包/类
@Test
public void testEmptyVariableLengthTypes()
{
    AbstractType<?>[] types = new AbstractType<?>[]{
                                                   AsciiType.instance,
                                                   BytesType.instance,
                                                   UTF8Type.instance,
                                                   new UFTestCustomType()
    };

    for (AbstractType<?> type : types)
    {
        Assert.assertFalse("type " + type.getClass().getName(),
                           UDHelper.isNullOrEmpty(type, ByteBufferUtil.EMPTY_BYTE_BUFFER));
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:UDHelperTest.java

示例2: validateAssignableTo

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

示例3: testSuperBlockRetrieval

import org.apache.cassandra.db.marshal.UTF8Type; //导入方法依赖的package包/类
@Test
public void testSuperBlockRetrieval() throws Exception
{
    OnDiskIndexBuilder builder = new OnDiskIndexBuilder(UTF8Type.instance, LongType.instance, OnDiskIndexBuilder.Mode.SPARSE);
    for (long i = 0; i < 100000; i++)
        builder.add(LongType.instance.decompose(i), keyAt(i), i);

    File index = File.createTempFile("on-disk-sa-multi-superblock-match", ".db");
    index.deleteOnExit();

    builder.finish(index);

    OnDiskIndex onDiskIndex = new OnDiskIndex(index, LongType.instance, new KeyConverter());

    testSearchRangeWithSuperBlocks(onDiskIndex, 0, 500);
    testSearchRangeWithSuperBlocks(onDiskIndex, 300, 93456);
    testSearchRangeWithSuperBlocks(onDiskIndex, 210, 1700);
    testSearchRangeWithSuperBlocks(onDiskIndex, 530, 3200);

    Random random = new Random(0xdeadbeef);
    for (int i = 0; i < 100000; i += random.nextInt(1500)) // random steps with max of 1500 elements
    {
        for (int j = 0; j < 3; j++)
            testSearchRangeWithSuperBlocks(onDiskIndex, i, ThreadLocalRandom.current().nextInt(i, 100000));
    }
}
 
开发者ID:xedin,项目名称:sasi,代码行数:27,代码来源:OnDiskIndexTest.java

示例4: validateAssignableTo

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

示例5: addTestCF

import org.apache.cassandra.db.marshal.UTF8Type; //导入方法依赖的package包/类
private CFMetaData addTestCF(String ks, String cf, String comment)
{
    CFMetaData newCFMD = new CFMetaData(ks, cf, ColumnFamilyType.Standard, new SimpleDenseCellNameType(UTF8Type.instance));
    newCFMD.comment(comment)
           .readRepairChance(0.0);

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

示例6: TestableCSW

import org.apache.cassandra.db.marshal.UTF8Type; //导入方法依赖的package包/类
private TestableCSW(File file, File offsetsFile) throws IOException
{
    this(file, offsetsFile, new CompressedSequentialWriter(file,
                                                           offsetsFile.getPath(),
                                                           CompressionParams.lz4(BUFFER_SIZE),
                                                           new MetadataCollector(new ClusteringComparator(UTF8Type.instance))));
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:8,代码来源:CompressedSequentialWriterTest.java

示例7: addTestCF

import org.apache.cassandra.db.marshal.UTF8Type; //导入方法依赖的package包/类
private CFMetaData addTestCF(String ks, String cf, String comment)
{
    CFMetaData newCFMD = new CFMetaData(ks, cf, ColumnFamilyType.Standard, UTF8Type.instance);
    newCFMD.comment(comment)
           .readRepairChance(0.0);

    return newCFMD;
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:9,代码来源:DefsTest.java

示例8: testMultiSuffixMatches

import org.apache.cassandra.db.marshal.UTF8Type; //导入方法依赖的package包/类
@Test
public void testMultiSuffixMatches() throws Exception
{
    OnDiskIndexBuilder builder = new OnDiskIndexBuilder(UTF8Type.instance, UTF8Type.instance, OnDiskIndexBuilder.Mode.SUFFIX)
    {{
            addAll(this, UTF8Type.instance.decompose("Eliza"), keyBuilder(1L, 2L));
            addAll(this, UTF8Type.instance.decompose("Elizabeth"), keyBuilder(3L, 4L));
            addAll(this, UTF8Type.instance.decompose("Aliza"), keyBuilder(5L, 6L));
            addAll(this, UTF8Type.instance.decompose("Taylor"), keyBuilder(7L, 8L));
            addAll(this, UTF8Type.instance.decompose("Pavel"), keyBuilder(9L, 10L));
    }};

    File index = File.createTempFile("on-disk-sa-multi-suffix-match", ".db");
    index.deleteOnExit();

    builder.finish(index);

    OnDiskIndex onDisk = new OnDiskIndex(index, UTF8Type.instance, new KeyConverter());

    Assert.assertEquals(convert(1, 2, 3, 4, 5, 6), convert(onDisk.search(expressionFor("liz"))));
    Assert.assertEquals(convert(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), convert(onDisk.search(expressionFor("a"))));
    Assert.assertEquals(convert(5, 6), convert(onDisk.search(expressionFor("A"))));
    Assert.assertEquals(convert(1, 2, 3, 4), convert(onDisk.search(expressionFor("E"))));
    Assert.assertEquals(convert(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), convert(onDisk.search(expressionFor("l"))));
    Assert.assertEquals(convert(3, 4), convert(onDisk.search(expressionFor("bet"))));
    Assert.assertEquals(convert(3, 4, 9, 10), convert(onDisk.search(expressionFor("e"))));
    Assert.assertEquals(convert(7, 8), convert(onDisk.search(expressionFor("yl"))));
    Assert.assertEquals(convert(7, 8), convert(onDisk.search(expressionFor("T"))));
    Assert.assertEquals(convert(1, 2, 3, 4, 5, 6), convert(onDisk.search(expressionFor("za"))));
    Assert.assertEquals(convert(3, 4), convert(onDisk.search(expressionFor("ab"))));

    Assert.assertEquals(Collections.<DecoratedKey>emptySet(), convert(onDisk.search(expressionFor("Pi"))));
    Assert.assertEquals(Collections.<DecoratedKey>emptySet(), convert(onDisk.search(expressionFor("ethz"))));
    Assert.assertEquals(Collections.<DecoratedKey>emptySet(), convert(onDisk.search(expressionFor("liw"))));
    Assert.assertEquals(Collections.<DecoratedKey>emptySet(), convert(onDisk.search(expressionFor("Taw"))));
    Assert.assertEquals(Collections.<DecoratedKey>emptySet(), convert(onDisk.search(expressionFor("Av"))));

    onDisk.close();
}
 
开发者ID:xedin,项目名称:sasi,代码行数:40,代码来源:OnDiskIndexTest.java

示例9: testNotEqualsQueryForNumbers

import org.apache.cassandra.db.marshal.UTF8Type; //导入方法依赖的package包/类
@Test
public void testNotEqualsQueryForNumbers() throws Exception
{
    final Map<ByteBuffer, TokenTreeBuilder> data = new HashMap<ByteBuffer, TokenTreeBuilder>()
    {{
            put(Int32Type.instance.decompose(5),  keyBuilder(1L));
            put(Int32Type.instance.decompose(7),  keyBuilder(2L));
            put(Int32Type.instance.decompose(1),  keyBuilder(3L));
            put(Int32Type.instance.decompose(3),  keyBuilder(1L, 4L));
            put(Int32Type.instance.decompose(8),  keyBuilder(8L, 6L));
            put(Int32Type.instance.decompose(10), keyBuilder(5L));
            put(Int32Type.instance.decompose(6),  keyBuilder(7L));
            put(Int32Type.instance.decompose(4),  keyBuilder(9L, 10L));
            put(Int32Type.instance.decompose(0),  keyBuilder(11L, 12L, 1L));
    }};

    OnDiskIndexBuilder builder = new OnDiskIndexBuilder(UTF8Type.instance, Int32Type.instance, OnDiskIndexBuilder.Mode.ORIGINAL);
    for (Map.Entry<ByteBuffer, TokenTreeBuilder> e : data.entrySet())
        addAll(builder, e.getKey(), e.getValue());

    File index = File.createTempFile("on-disk-sa-except-int-test", "db");
    index.deleteOnExit();

    builder.finish(index);

    OnDiskIndex onDisk = new OnDiskIndex(index, Int32Type.instance, new KeyConverter());

    Assert.assertEquals(convert(1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12), convert(onDisk.search(expressionForNot(0, 10, 1))));
    Assert.assertEquals(convert(1, 2, 4, 5, 7, 9, 10, 11, 12), convert(onDisk.search(expressionForNot(0, 10, 1, 8))));
    Assert.assertEquals(convert(1, 2, 4, 5, 7, 11, 12), convert(onDisk.search(expressionForNot(0, 10, 1, 8, 4))));

    onDisk.close();
}
 
开发者ID:xedin,项目名称:sasi,代码行数:34,代码来源:OnDiskIndexTest.java

示例10: testSuperBlocks

import org.apache.cassandra.db.marshal.UTF8Type; //导入方法依赖的package包/类
@Test
public void testSuperBlocks() throws Exception
{
    Map<ByteBuffer, TokenTreeBuilder> terms = new HashMap<>();
    terms.put(UTF8Type.instance.decompose("1234"), keyBuilder(1L, 2L));
    terms.put(UTF8Type.instance.decompose("2345"), keyBuilder(3L, 4L));
    terms.put(UTF8Type.instance.decompose("3456"), keyBuilder(5L, 6L));
    terms.put(UTF8Type.instance.decompose("4567"), keyBuilder(7L, 8L));
    terms.put(UTF8Type.instance.decompose("5678"), keyBuilder(9L, 10L));

    OnDiskIndexBuilder builder = new OnDiskIndexBuilder(UTF8Type.instance, Int32Type.instance, OnDiskIndexBuilder.Mode.SPARSE);
    for (Map.Entry<ByteBuffer, TokenTreeBuilder> entry : terms.entrySet())
        addAll(builder, entry.getKey(), entry.getValue());

    File index = File.createTempFile("on-disk-sa-try-superblocks", ".db");
    index.deleteOnExit();

    builder.finish(index);

    OnDiskIndex onDisk = new OnDiskIndex(index, Int32Type.instance, new KeyConverter());
    OnDiskIndex.OnDiskSuperBlock superBlock = onDisk.dataLevel.getSuperBlock(0);
    Iterator<Token> iter = superBlock.iterator();

    Long lastToken = null;
    while (iter.hasNext())
    {
        Token token = iter.next();

        if (lastToken != null)
            Assert.assertTrue(lastToken.compareTo(token.get()) < 0);

        lastToken = token.get();
    }
}
 
开发者ID:xedin,项目名称:sasi,代码行数:35,代码来源:OnDiskIndexTest.java

示例11: addTestCF

import org.apache.cassandra.db.marshal.UTF8Type; //导入方法依赖的package包/类
private CFMetaData addTestCF(String ks, String cf, String comment)
{
    CFMetaData newCFMD = new CFMetaData(ks, cf, ColumnFamilyType.Standard, UTF8Type.instance, null);
    newCFMD.comment(comment)
           .readRepairChance(0.0);

    return newCFMD;
}
 
开发者ID:wso2,项目名称:wso2-cassandra,代码行数:9,代码来源:DefsTest.java

示例12: testSerializeDeserialize

import org.apache.cassandra.db.marshal.UTF8Type; //导入方法依赖的package包/类
@Test
public void testSerializeDeserialize() throws IOException
{
    CounterContext.ContextState state = CounterContext.ContextState.allocate(0, 2, 2);
    state.writeRemote(CounterId.fromInt(1), 4L, 4L);
    state.writeLocal(CounterId.fromInt(2), 4L, 4L);
    state.writeRemote(CounterId.fromInt(3), 4L, 4L);
    state.writeLocal(CounterId.fromInt(4), 4L, 4L);

    CellNameType type = new SimpleDenseCellNameType(UTF8Type.instance);
    CounterCell original = new CounterCell(cellname("x"), state.context, 1L);
    byte[] serialized;
    try (DataOutputBuffer bufOut = new DataOutputBuffer())
    {
        type.columnSerializer().serialize(original, bufOut);
        serialized = bufOut.getData();
    }


    ByteArrayInputStream bufIn = new ByteArrayInputStream(serialized, 0, serialized.length);
    CounterCell deserialized = (CounterCell) type.columnSerializer().deserialize(new DataInputStream(bufIn));
    Assert.assertEquals(original, deserialized);

    bufIn = new ByteArrayInputStream(serialized, 0, serialized.length);
    CounterCell deserializedOnRemote = (CounterCell) type.columnSerializer().deserialize(new DataInputStream(bufIn), ColumnSerializer.Flag.FROM_REMOTE);
    Assert.assertEquals(deserializedOnRemote.name(), original.name());
    Assert.assertEquals(deserializedOnRemote.total(), original.total());
    Assert.assertEquals(deserializedOnRemote.value(), cc.clearAllLocal(original.value()));
    Assert.assertEquals(deserializedOnRemote.timestamp(), deserialized.timestamp());
    Assert.assertEquals(deserializedOnRemote.timestampOfLastDelete(), deserialized.timestampOfLastDelete());
}
 
开发者ID:rajath26,项目名称:cassandra-trunk,代码行数:32,代码来源:CounterCellTest.java

示例13: GeoShapeMapper

import org.apache.cassandra.db.marshal.UTF8Type; //导入方法依赖的package包/类
/**
 * Builds a new {@link GeoShapeMapper}.
 */
@JsonCreator
public GeoShapeMapper(@JsonProperty("max_levels") Integer maxLevels) {
    super(new AbstractType<?>[]{AsciiType.instance, UTF8Type.instance});
    this.maxLevels = maxLevels == null ? DEFAULT_MAX_LEVELS : maxLevels;
    this.grid = new GeohashPrefixTree(spatialContext, this.maxLevels);
}
 
开发者ID:Stratio,项目名称:stratio-cassandra,代码行数:10,代码来源:GeoShapeMapper.java

示例14: makeReceiver

import org.apache.cassandra.db.marshal.UTF8Type; //导入方法依赖的package包/类
private ColumnSpecification makeReceiver(CFMetaData metadata)
{
    return new ColumnSpecification(metadata.ksName, metadata.cfName, JSON_COLUMN_ID, UTF8Type.instance);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:5,代码来源:Json.java

示例15: getColumnDefinitionNameComparator

import org.apache.cassandra.db.marshal.UTF8Type; //导入方法依赖的package包/类
public AbstractType<?> getColumnDefinitionNameComparator(ColumnDefinition.Kind kind)
{
    return (isSuper() && kind == ColumnDefinition.Kind.REGULAR) || (isStaticCompactTable() && kind == ColumnDefinition.Kind.STATIC)
            ? thriftColumnNameType()
            : UTF8Type.instance;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:7,代码来源:CFMetaData.java


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