本文整理汇总了Java中org.apache.cassandra.db.marshal.AbstractType.compare方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractType.compare方法的具体用法?Java AbstractType.compare怎么用?Java AbstractType.compare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.db.marshal.AbstractType
的用法示例。
在下文中一共展示了AbstractType.compare方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSerializedValue
import org.apache.cassandra.db.marshal.AbstractType; //导入方法依赖的package包/类
/**
* Given a serialized map, gets the value associated with a given key.
* @param serializedMap a serialized map
* @param serializedKey a serialized key
* @param keyType the key type for the map
* @return the value associated with the key if one exists, null otherwise
*/
public ByteBuffer getSerializedValue(ByteBuffer serializedMap, ByteBuffer serializedKey, AbstractType keyType)
{
try
{
ByteBuffer input = serializedMap.duplicate();
int n = readCollectionSize(input, ProtocolVersion.V3);
for (int i = 0; i < n; i++)
{
ByteBuffer kbb = readValue(input, ProtocolVersion.V3);
ByteBuffer vbb = readValue(input, ProtocolVersion.V3);
int comparison = keyType.compare(kbb, serializedKey);
if (comparison == 0)
return vbb;
else if (comparison > 0)
// since the map is in sorted order, we know we've gone too far and the element doesn't exist
return null;
}
return null;
}
catch (BufferUnderflowException e)
{
throw new MarshalException("Not enough bytes to read a map");
}
}
示例2: min
import org.apache.cassandra.db.marshal.AbstractType; //导入方法依赖的package包/类
private static ByteBuffer min(ByteBuffer b1, ByteBuffer b2, AbstractType<?> comparator)
{
if (b1 == null)
return b2;
if (b2 == null)
return b1;
if (comparator.compare(b1, b2) >= 0)
return b2;
return b1;
}
示例3: max
import org.apache.cassandra.db.marshal.AbstractType; //导入方法依赖的package包/类
private static ByteBuffer max(ByteBuffer b1, ByteBuffer b2, AbstractType<?> comparator)
{
if (b1 == null)
return b2;
if (b2 == null)
return b1;
if (comparator.compare(b1, b2) >= 0)
return b1;
return b2;
}