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


Java ByteBufferUtil.string方法代码示例

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


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

示例1: getComparator

import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
private AbstractType<?> getComparator(ByteBuffer bb)
{
    try
    {
        int header = ByteBufferUtil.readShortLength(bb);
        if ((header & 0x8000) == 0)
        {
            String name = ByteBufferUtil.string(ByteBufferUtil.readBytes(bb, header));
            return TypeParser.parse(name);
        }
        else
        {
            return aliases.get((byte)(header & 0xFF));
        }
    }
    catch (CharacterCodingException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:21,代码来源:DynamicCompositeType.java

示例2: getAndAppendComparator

import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
protected AbstractType<?> getAndAppendComparator(int i, ByteBuffer bb, StringBuilder sb)
{
    try
    {
        int header = ByteBufferUtil.readShortLength(bb);
        if ((header & 0x8000) == 0)
        {
            String name = ByteBufferUtil.string(ByteBufferUtil.readBytes(bb, header));
            sb.append(name).append("@");
            return TypeParser.parse(name);
        }
        else
        {
            sb.append((char)(header & 0xFF)).append("@");
            return aliases.get((byte)(header & 0xFF));
        }
    }
    catch (CharacterCodingException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:23,代码来源:DynamicCompositeType.java

示例3: deserialize

import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
public String deserialize(ByteBuffer bytes)
{
    try
    {
        return ByteBufferUtil.string(bytes, charset);
    }
    catch (CharacterCodingException e)
    {
        throw new MarshalException("Invalid " + charset + " bytes " + ByteBufferUtil.bytesToHex(bytes));
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:12,代码来源:AbstractTextSerializer.java

示例4: validateComparator

import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
protected AbstractType<?> validateComparator(int i, ByteBuffer bb) throws MarshalException
{
    AbstractType<?> comparator = null;
    if (bb.remaining() < 2)
        throw new MarshalException("Not enough bytes to header of the comparator part of component " + i);
    int header = ByteBufferUtil.readShortLength(bb);
    if ((header & 0x8000) == 0)
    {
        if (bb.remaining() < header)
            throw new MarshalException("Not enough bytes to read comparator name of component " + i);

        ByteBuffer value = ByteBufferUtil.readBytes(bb, header);
        String valueStr = null;
        try
        {
            valueStr = ByteBufferUtil.string(value);
            comparator = TypeParser.parse(valueStr);
        }
        catch (CharacterCodingException ce) 
        {
            // ByteBufferUtil.string failed. 
            // Log it here and we'll further throw an exception below since comparator == null
            logger.error("Failed with [{}] when decoding the byte buffer in ByteBufferUtil.string()", 
               ce.toString());
        }
        catch (Exception e)
        {
            // parse failed. 
            // Log it here and we'll further throw an exception below since comparator == null
            logger.error("Failed to parse value string \"{}\" with exception: [{}]", 
               valueStr, e.toString());
        }
    }
    else
    {
        comparator = aliases.get((byte)(header & 0xFF));
    }

    if (comparator == null)
        throw new MarshalException("Cannot find comparator for component " + i);
    else
        return comparator;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:44,代码来源:DynamicCompositeType.java


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