use of it.unimi.dsi.fastutil.longs.LongArrayList in project druid by druid-io.
the class InDimFilter method createLongPredicate.
private static DruidLongPredicate createLongPredicate(final Set<String> values) {
LongArrayList longs = new LongArrayList(values.size());
for (String value : values) {
final Long longValue = DimensionHandlerUtils.convertObjectToLong(value);
if (longValue != null) {
longs.add((long) longValue);
}
}
final LongOpenHashSet longHashSet = new LongOpenHashSet(longs);
return longHashSet::contains;
}
use of it.unimi.dsi.fastutil.longs.LongArrayList in project druid by druid-io.
the class InDimFilter method createDoublePredicate.
private static DruidDoublePredicate createDoublePredicate(final Set<String> values) {
LongArrayList doubleBits = new LongArrayList(values.size());
for (String value : values) {
Double doubleValue = DimensionHandlerUtils.convertObjectToDouble(value);
if (doubleValue != null) {
doubleBits.add(Double.doubleToLongBits((doubleValue)));
}
}
final LongOpenHashSet doubleBitsHashSet = new LongOpenHashSet(doubleBits);
return input -> doubleBitsHashSet.contains(Double.doubleToLongBits(input));
}
use of it.unimi.dsi.fastutil.longs.LongArrayList in project angel by Tencent.
the class RowUpdateSplitUtils method split.
public static Map<PartitionKey, HashIndicesView> split(long[] indices, List<PartitionKey> parts) {
Map<PartitionKey, HashIndicesView> ret = new HashMap<>();
Map<Integer, LongArrayList> partIndex2Indices = new HashMap<>();
SortedMap<Integer, Integer> key2partIndex = new TreeMap<>();
for (int i = 0; i < parts.size(); i++) {
key2partIndex.put((int) parts.get(i).getEndCol(), parts.get(i).getPartitionId());
}
for (int j = 0; j < indices.length; j++) {
int hash = HashUtils.getFNV1_32_HashCode(indices[j]);
SortedMap<Integer, Integer> subMap = key2partIndex.tailMap(hash);
int key = subMap.firstKey();
int partIndex = subMap.get(key);
if (partIndex2Indices.containsKey(partIndex)) {
partIndex2Indices.get(partIndex).add(indices[j]);
} else {
LongArrayList splitIndices = new LongArrayList();
splitIndices.add(indices[j]);
partIndex2Indices.put(partIndex, splitIndices);
}
}
for (Map.Entry<Integer, LongArrayList> entry : partIndex2Indices.entrySet()) {
ret.put(parts.get(entry.getKey()), new HashIndicesView(entry.getValue().toLongArray()));
}
return ret;
}
use of it.unimi.dsi.fastutil.longs.LongArrayList in project angel by Tencent.
the class GetNodes method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam param) {
ServerLongAnyRow row = GraphMatrixUtils.getPSLongKeyRow(psContext, param);
ObjectIterator<Entry<IElement>> it = row.iterator();
LongArrayList nodes = new LongArrayList();
Boolean isHash = ((PartGetNodesParam) param).getHash();
long start = isHash ? 0 : param.getPartKey().getStartCol();
while (it.hasNext()) {
Long2ObjectMap.Entry entry = it.next();
GraphNode node = (GraphNode) entry.getValue();
if (node.getFeats() != null && node.getNeighbors() == null) {
nodes.add(entry.getLongKey() + start);
}
}
return new IndexPartGetLongResult(param.getPartKey(), nodes.toLongArray());
}
use of it.unimi.dsi.fastutil.longs.LongArrayList in project angel by Tencent.
the class GetNodes method partitionGet.
@Override
public PartitionGetResult partitionGet(PartitionGetParam partParam) {
ServerPartition part = psContext.getMatrixStorageManager().getPart(partParam.getPartKey());
ServerLongAnyRow row = (ServerLongAnyRow) psContext.getMatrixStorageManager().getRow(partParam.getPartKey(), 0);
LongArrayList ret = new LongArrayList();
row.startRead();
try {
ObjectIterator<Long2ObjectMap.Entry<IElement>> it = row.iterator();
while (it.hasNext()) {
Long2ObjectMap.Entry<IElement> entry = it.next();
ret.add(entry.getLongKey() + partParam.getPartKey().getStartCol());
}
} finally {
row.endRead();
}
return new IndexPartGetLongResult(part.getPartitionKey(), ret.toLongArray());
}
Aggregations