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


Java ByteBufferUtil.readShortLength方法代码示例

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


在下文中一共展示了ByteBufferUtil.readShortLength方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: validate

import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
@Override
public void validate(ByteBuffer bytes) throws MarshalException
{
    ByteBuffer bb = bytes.duplicate();
    readIsStatic(bb);

    int i = 0;
    ByteBuffer previous = null;
    while (bb.remaining() > 0)
    {
        AbstractType<?> comparator = validateComparator(i, bb);

        if (bb.remaining() < 2)
            throw new MarshalException("Not enough bytes to read value size of component " + i);
        int length = ByteBufferUtil.readShortLength(bb);

        if (bb.remaining() < length)
            throw new MarshalException("Not enough bytes to read value of component " + i);
        ByteBuffer value = ByteBufferUtil.readBytes(bb, length);

        comparator.validateCollectionMember(value, previous);

        if (bb.remaining() == 0)
            throw new MarshalException("Not enough bytes to read the end-of-component byte of component" + i);
        byte b = bb.get();
        if (b != 0 && bb.remaining() != 0)
            throw new MarshalException("Invalid bytes remaining after an end-of-component at component" + i);

        previous = value;
        ++i;
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:33,代码来源:AbstractCompositeType.java

示例4: readStatic

import org.apache.cassandra.utils.ByteBufferUtil; //导入方法依赖的package包/类
private static boolean readStatic(ByteBuffer bb)
{
    if (bb.remaining() < 2)
        return false;

    int header = ByteBufferUtil.getShortLength(bb, bb.position());
    if ((header & 0xFFFF) != STATIC_MARKER)
        return false;

    ByteBufferUtil.readShortLength(bb); // Skip header
    return true;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:13,代码来源:CompositeType.java

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