本文整理汇总了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);
}
}
示例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);
}
}
示例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));
}
}
示例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;
}