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


Java AbstractType.compare方法代码示例

本文整理汇总了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");
    }
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:32,代码来源:MapSerializer.java

示例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;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:12,代码来源:MetadataCollector.java

示例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;
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:12,代码来源:MetadataCollector.java


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