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