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


Java BytesType.instance方法代码示例

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


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

示例1: makeFromBlobFunction

import org.apache.cassandra.db.marshal.BytesType; //导入方法依赖的package包/类
public static Function makeFromBlobFunction(final AbstractType<?> toType)
{
    final String name = "blobas" + toType.asCQL3Type();
    return new AbstractFunction(name, toType, BytesType.instance)
    {
        public ByteBuffer execute(List<ByteBuffer> parameters) throws InvalidRequestException
        {
            ByteBuffer val = parameters.get(0);
            try
            {
                if (val != null)
                    toType.validate(val);
                return val;
            }
            catch (MarshalException e)
            {
                throw new InvalidRequestException(String.format("In call to function %s, value 0x%s is not a valid binary representation for type %s",
                                                                name, ByteBufferUtil.bytesToHex(val), toType.asCQL3Type()));
            }
        }
    };
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:23,代码来源:BytesConversionFcts.java

示例2: testComparisonMethod

import org.apache.cassandra.db.marshal.BytesType; //导入方法依赖的package包/类
@Test
public void testComparisonMethod()
{
    ThreadLocalRandom random = ThreadLocalRandom.current();
    byte[] commonBytes = new byte[10];
    byte[] aBytes = new byte[16];
    byte[] bBytes = new byte[16];
    for (int i = 0 ; i < 100000 ; i++)
    {
        int commonLength = random.nextInt(0, 10);
        random.nextBytes(commonBytes);
        random.nextBytes(aBytes);
        random.nextBytes(bBytes);
        System.arraycopy(commonBytes, 0, aBytes, 0, commonLength);
        System.arraycopy(commonBytes, 0, bBytes, 0, commonLength);
        int aLength = random.nextInt(commonLength, 16);
        int bLength = random.nextInt(commonLength, 16);
        ColumnIdentifier a = new ColumnIdentifier(ByteBuffer.wrap(aBytes, 0, aLength), BytesType.instance);
        ColumnIdentifier b = new ColumnIdentifier(ByteBuffer.wrap(bBytes, 0, bLength), BytesType.instance);
        Assert.assertEquals("" + i, compareResult(a.compareTo(b)), compareResult(ByteBufferUtil.compareUnsigned(a.bytes, b.bytes)));
    }
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:23,代码来源:ColumnIdentifierTest.java

示例3: Writer

import org.apache.cassandra.db.marshal.BytesType; //导入方法依赖的package包/类
protected Writer(int keysToSave)
{
    if (keysToSave >= getKeySet().size())
        keys = getKeySet();
    else
        keys = hotKeySet(keysToSave);

    OperationType type;
    if (cacheType == CacheService.CacheType.KEY_CACHE)
        type = OperationType.KEY_CACHE_SAVE;
    else if (cacheType == CacheService.CacheType.ROW_CACHE)
        type = OperationType.ROW_CACHE_SAVE;
    else
        type = OperationType.UNKNOWN;

    info = new CompactionInfo(new CFMetaData(Keyspace.SYSTEM_KS, cacheType.toString(), ColumnFamilyType.Standard, BytesType.instance, null),
                              type,
                              0,
                              keys.size(),
                              "keys");
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:22,代码来源:AutoSavingCache.java

示例4: makeFromBlobFunction

import org.apache.cassandra.db.marshal.BytesType; //导入方法依赖的package包/类
public static Function makeFromBlobFunction(final AbstractType<?> toType)
{
    final String name = "blobas" + toType.asCQL3Type();
    return new NativeScalarFunction(name, toType, BytesType.instance)
    {
        public ByteBuffer execute(int protocolVersion, List<ByteBuffer> parameters) throws InvalidRequestException
        {
            ByteBuffer val = parameters.get(0);
            try
            {
                if (val != null)
                    toType.validate(val);
                return val;
            }
            catch (MarshalException e)
            {
                throw new InvalidRequestException(String.format("In call to function %s, value 0x%s is not a valid binary representation for type %s",
                                                                name, ByteBufferUtil.bytesToHex(val), toType.asCQL3Type()));
            }
        }
    };
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:23,代码来源:BytesConversionFcts.java

示例5: testEmptyVariableLengthTypes

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

示例6: makeFromBlobFunction

import org.apache.cassandra.db.marshal.BytesType; //导入方法依赖的package包/类
public static Function makeFromBlobFunction(final AbstractType<?> toType)
{
    final String name = "blobas" + toType.asCQL3Type();
    return new NativeFunction(name, toType, BytesType.instance)
    {
        public ByteBuffer execute(List<ByteBuffer> parameters) throws InvalidRequestException
        {
            ByteBuffer val = parameters.get(0);
            try
            {
                if (val != null)
                    toType.validate(val);
                return val;
            }
            catch (MarshalException e)
            {
                throw new InvalidRequestException(String.format("In call to function %s, value 0x%s is not a valid binary representation for type %s",
                                                                name, ByteBufferUtil.bytesToHex(val), toType.asCQL3Type()));
            }
        }
    };
}
 
开发者ID:daidong,项目名称:GraphTrek,代码行数:23,代码来源:BytesConversionFcts.java

示例7: testSerializeDeserialize

import org.apache.cassandra.db.marshal.BytesType; //导入方法依赖的package包/类
@Test
public void testSerializeDeserialize() throws Exception
{
    ColumnDefinition cd0 = new ColumnDefinition(ByteBufferUtil.bytes("TestColumnDefinitionName0"),
                                                BytesType.instance,
                                                IndexType.KEYS,
                                                null,
                                                "random index name 0",
                                                null);

    ColumnDefinition cd1 = new ColumnDefinition(ByteBufferUtil.bytes("TestColumnDefinition1"),
                                                LongType.instance,
                                                null,
                                                null,
                                                null,
                                                null);

    testSerializeDeserialize(cd0);
    testSerializeDeserialize(cd1);
}
 
开发者ID:jackliu8722,项目名称:cassandra-1.2.16,代码行数:21,代码来源:ColumnDefinitionTest.java

示例8: getCassandraType

import org.apache.cassandra.db.marshal.BytesType; //导入方法依赖的package包/类
public static AbstractType getCassandraType(PrimitiveObjectInspector oi) {
  switch (oi.getPrimitiveCategory()) {
  case BOOLEAN:
    return BooleanType.instance;
  case INT:
    return Int32Type.instance;
  case LONG:
    return LongType.instance;
  case FLOAT:
    return FloatType.instance;
  case DOUBLE:
    return DoubleType.instance;
  case STRING:
    return UTF8Type.instance;
  case BYTE:
  case SHORT:
  case BINARY:
    return BytesType.instance;
  case TIMESTAMP:
    return DateType.instance;
  default:
    throw new RuntimeException("Hive internal error.");

  }
}
 
开发者ID:dvasilen,项目名称:Hive-Cassandra,代码行数:26,代码来源:LazyCassandraUtils.java

示例9: testSerializeDeserialize

import org.apache.cassandra.db.marshal.BytesType; //导入方法依赖的package包/类
@Test
public void testSerializeDeserialize() throws Exception
{
    ColumnDefinition cd0 = new ColumnDefinition(ByteBufferUtil.bytes("TestColumnDefinitionName0"),
                                                BytesType.instance,
                                                IndexType.KEYS,
                                                "random index name 0");

    ColumnDefinition cd1 = new ColumnDefinition(ByteBufferUtil.bytes("TestColumnDefinition1"),
                                                LongType.instance,
                                                null,
                                                null);

    testSerializeDeserialize(cd0);
    testSerializeDeserialize(cd1);
}
 
开发者ID:devdattakulkarni,项目名称:Cassandra-KVPM,代码行数:17,代码来源:ColumnDefinitionTest.java

示例10: getDroppedColumnDefinition

import org.apache.cassandra.db.marshal.BytesType; //导入方法依赖的package包/类
/**
 * Returns a "fake" ColumnDefinition corresponding to the dropped column {@code name}
 * of {@code null} if there is no such dropped column.
 *
 * @param name - the column name
 * @param isStatic - whether the column was a static column, if known
 */
public ColumnDefinition getDroppedColumnDefinition(ByteBuffer name, boolean isStatic)
{
    DroppedColumn dropped = droppedColumns.get(name);
    if (dropped == null)
        return null;

    // We need the type for deserialization purpose. If we don't have the type however,
    // it means that it's a dropped column from before 3.0, and in that case using
    // BytesType is fine for what we'll be using it for, even if that's a hack.
    AbstractType<?> type = dropped.type == null ? BytesType.instance : dropped.type;
    return isStatic
            ? ColumnDefinition.staticDef(this, name, type)
            : ColumnDefinition.regularDef(this, name, type);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:22,代码来源:CFMetaData.java

示例11: makeToBlobFunction

import org.apache.cassandra.db.marshal.BytesType; //导入方法依赖的package包/类
public static Function makeToBlobFunction(AbstractType<?> fromType)
{
    String name = fromType.asCQL3Type() + "asblob";
    return new AbstractFunction(name, BytesType.instance, fromType)
    {
        public ByteBuffer execute(List<ByteBuffer> parameters)
        {
            return parameters.get(0);
        }
    };
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:12,代码来源:BytesConversionFcts.java

示例12: test6791

import org.apache.cassandra.db.marshal.BytesType; //导入方法依赖的package包/类
@Test
public void test6791() throws IOException, ConfigurationException
{
    File f = File.createTempFile("compressed6791_", "3");
    String filename = f.getAbsolutePath();
    try
    {

        MetadataCollector sstableMetadataCollector = new MetadataCollector(new SimpleDenseCellNameType(BytesType.instance));
        CompressedSequentialWriter writer = new CompressedSequentialWriter(f, filename + ".metadata", new CompressionParameters(SnappyCompressor.instance, 32, Collections.<String, String>emptyMap()), sstableMetadataCollector);

        for (int i = 0; i < 20; i++)
            writer.write("x".getBytes());

        FileMark mark = writer.mark();
        // write enough garbage to create new chunks:
        for (int i = 0; i < 40; ++i)
            writer.write("y".getBytes());

        writer.resetAndTruncate(mark);

        for (int i = 0; i < 20; i++)
            writer.write("x".getBytes());
        writer.close();

        CompressedRandomAccessReader reader = CompressedRandomAccessReader.open(filename, new CompressionMetadata(filename + ".metadata", f.length(), true));
        String res = reader.readLine();
        assertEquals(res, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
        assertEquals(40, res.length());
    }
    finally
    {
        // cleanup
        if (f.exists())
            f.delete();
        File metadata = new File(filename+ ".metadata");
            if (metadata.exists())
                metadata.delete();
    }
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:41,代码来源:CompressedRandomAccessReaderTest.java

示例13: makeFromBlobFunction

import org.apache.cassandra.db.marshal.BytesType; //导入方法依赖的package包/类
public static Function makeFromBlobFunction(AbstractType<?> toType)
{
    String name = "blobas" + toType.asCQL3Type();
    return new AbstractFunction(name, toType, BytesType.instance)
    {
        public ByteBuffer execute(List<ByteBuffer> parameters)
        {
            return parameters.get(0);
        }
    };
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:12,代码来源:BytesConversionFcts.java

示例14: prepareWriter

import org.apache.cassandra.db.marshal.BytesType; //导入方法依赖的package包/类
private void prepareWriter() throws IOException
{
    if (outputdir == null)
    {
        String keyspace = ConfigHelper.getOutputKeyspace(conf);
        //dir must be named by ks/cf for the loader
        outputdir = new File(getOutputLocation() + File.separator + keyspace + File.separator + ConfigHelper.getOutputColumnFamily(conf));
        outputdir.mkdirs();
    }
    
    if (writer == null)
    {
        AbstractType<?> subcomparator = null;
        ExternalClient externalClient = null;
        String username = ConfigHelper.getOutputKeyspaceUserName(conf);
        String password = ConfigHelper.getOutputKeyspacePassword(conf);

        if (cfType == CFType.SUPER)
            subcomparator = BytesType.instance;

        this.writer = new SSTableSimpleUnsortedWriter(
                outputdir,
                ConfigHelper.getOutputPartitioner(conf),
                ConfigHelper.getOutputKeyspace(conf),
                ConfigHelper.getOutputColumnFamily(conf),
                BytesType.instance,
                subcomparator,
                Integer.parseInt(conf.get(BUFFER_SIZE_IN_MB, "64")),
                ConfigHelper.getOutputCompressionParamaters(conf));

        externalClient = new ExternalClient(ConfigHelper.getOutputInitialAddress(conf),
                                            ConfigHelper.getOutputRpcPort(conf),
                                            username,
                                            password);

        this.loader = new SSTableLoader(outputdir, externalClient, new NullOutputHandler());
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:39,代码来源:BulkRecordWriter.java

示例15: stringAsType

import org.apache.cassandra.db.marshal.BytesType; //导入方法依赖的package包/类
/**
 * Convert a string to bytes (ByteBuffer) according to type
 * @param content string to convert
 * @param type type to use for conversion
 * @return byte buffer representation of the given string
 */
private static ByteBuffer stringAsType(String content, AbstractType<?> type)
{
    try
    {
        return (type == BytesType.instance) ? hexToBytes(content) : type.fromString(content);
    }
    catch (MarshalException e)
    {
        throw new RuntimeException(e.getMessage());
    }
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:18,代码来源:SSTableImport.java


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