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


Java U.safeAbs方法代码示例

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


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

示例1: partition

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public int partition(Object key) {
    Integer regionId;

    if (key instanceof RegionKey)
        regionId = ((RegionKey)key).regionId;
    else if (key instanceof BinaryObject) {
        BinaryObject bo = (BinaryObject)key;

        regionId = bo.field("regionId");
    }
    else
        throw new IgniteException("Unsupported key for region aware affinity");

    List<Integer> range = REGION_TO_PART_MAP.get(regionId);

    Integer cnt = range.get(1);

    return U.safeAbs(key.hashCode() % cnt) + range.get(0); // Assign partition in region's range.
}
 
开发者ID:apache,项目名称:ignite,代码行数:21,代码来源:IgniteCacheDistributedPartitionQueryAbstractSelfTest.java

示例2: segmentIndex

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @param pageId Page ID.
 * @return Segment index.
 */
public static int segmentIndex(int grpId, long pageId, int segments) {
    pageId = PageIdUtils.effectivePageId(pageId);

    // Take a prime number larger than total number of partitions.
    int hash = U.hash(pageId * 65537 + grpId);

    return U.safeAbs(hash) % segments;
}
 
开发者ID:apache,项目名称:ignite,代码行数:13,代码来源:PageMemoryImpl.java

示例3: partition

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public int partition(Object key) {
    if (key == null)
        throw new IllegalArgumentException("Null key is passed for a partition calculation. " +
            "Make sure that an affinity key that is used is initialized properly.");

    if (mask >= 0) {
        int h;

        return ((h = key.hashCode()) ^ (h >>> 16)) & mask;
    }

    return U.safeAbs(key.hashCode() % parts);
}
 
开发者ID:apache,项目名称:ignite,代码行数:15,代码来源:RendezvousAffinityFunction.java

示例4: partition

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public int partition(Object key) {
    if (key instanceof Number)
        return ((Number)key).intValue() % 2;

    return key == null ? 0 : U.safeAbs(key.hashCode() % 2);
}
 
开发者ID:apache,项目名称:ignite,代码行数:8,代码来源:GridCacheReplicatedPreloadSelfTest.java

示例5: partition

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public int partition(Object key) {
    if (key instanceof Number)
        return ((Number)key).intValue() % parts;

    return key == null ? 0 : U.safeAbs(key.hashCode() % parts);
}
 
开发者ID:apache,项目名称:ignite,代码行数:8,代码来源:GridCacheModuloAffinityFunction.java

示例6: partition

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public int partition(Object key) {
    if (key == null)
        throw new IllegalArgumentException("Null key is passed for a partition calculation. " +
            "Make sure that an affinity key that is used is initialized properly.");

    return U.safeAbs(key.hashCode() % parts);
}
 
开发者ID:apache,项目名称:ignite,代码行数:9,代码来源:RendezvousAffinityFunctionSimpleBenchmark.java

示例7: dhtAtomicUpdateIndex

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @param ver Version.
 * @return Index.
 */
private int dhtAtomicUpdateIndex(GridCacheVersion ver) {
    return U.safeAbs(ver.hashCode()) % dhtAtomicUpdCnt.length();
}
 
开发者ID:apache,项目名称:ignite,代码行数:8,代码来源:GridCacheSharedContext.java

示例8: getLock

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Returns {@link Lock} object for the given key.
 * @param key Key.
 * @return Lock.
 */
public Lock getLock(int key) {
    return locks[U.safeAbs(key) % locks.length];
}
 
开发者ID:apache,项目名称:ignite,代码行数:9,代码来源:GridStripedLock.java

示例9: lockIndex

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Returns index of lock object corresponding to the stripe of this lock address.
 *
 * @param lock Lock address.
 * @return Lock monitor object that corresponds to the stripe for this lock address.
 */
private int lockIndex(long lock) {
    return U.safeAbs(U.hash(lock)) & monitorsMask;
}
 
开发者ID:apache,项目名称:ignite,代码行数:10,代码来源:OffheapReadWriteLock.java

示例10: getLock

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Returns {@link Lock} object for the given key.
 * @param key Key.
 * @return Lock.
 */
public ReadWriteLock getLock(int key) {
    return locks[U.safeAbs(key) % locks.length];
}
 
开发者ID:apache,项目名称:ignite,代码行数:9,代码来源:GridStripedReadWriteLock.java

示例11: partition

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * @param mapper IGFS blocks mapper.
 * @param fileId IGFS file ID.
 * @param blockId File block ID.
 * @param partCnt Total partitions count.
 * @return Partition index.
 */
private int partition(IgfsGroupDataBlocksKeyMapper mapper, IgniteUuid fileId, long blockId, int partCnt) {
    return U.safeAbs((Integer) mapper.affinityKey(new IgfsBlockKey(fileId, null, false, blockId)) % partCnt);
}
 
开发者ID:apache,项目名称:ignite,代码行数:11,代码来源:IgfsGroupDataBlockKeyMapperHashSelfTest.java

示例12: checkPartition

import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
 * Check correct partition shift.
 *
 * @param prevPart Previous partition.
 * @param part Current partition.
 * @param totalParts Total partitions.
 * @return {@code true} if previous and current partitions have correct values.
 */
private boolean checkPartition(int prevPart, int part, int totalParts) {
    return U.safeAbs(prevPart - part) == 1 ||
        (part == 0 && prevPart == totalParts - 1) ||
        (prevPart == 0 && part == totalParts - 1);
}
 
开发者ID:apache,项目名称:ignite,代码行数:14,代码来源:IgfsGroupDataBlockKeyMapperHashSelfTest.java


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