Search in sources :

Example 11 with LongArrayList

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;
}
Also used : LongArrayList(it.unimi.dsi.fastutil.longs.LongArrayList) LongOpenHashSet(it.unimi.dsi.fastutil.longs.LongOpenHashSet)

Example 12 with LongArrayList

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));
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) RangeSet(com.google.common.collect.RangeSet) Comparators(org.apache.druid.java.util.common.guava.Comparators) SortedSet(java.util.SortedSet) ExtractionFn(org.apache.druid.query.extraction.ExtractionFn) LongArrayList(it.unimi.dsi.fastutil.longs.LongArrayList) DimensionHandlerUtils(org.apache.druid.segment.DimensionHandlerUtils) ImmutableBitmap(org.apache.druid.collections.bitmap.ImmutableBitmap) CacheKeyBuilder(org.apache.druid.query.cache.CacheKeyBuilder) ColumnProcessors(org.apache.druid.segment.ColumnProcessors) ColumnSelectorFactory(org.apache.druid.segment.ColumnSelectorFactory) Map(java.util.Map) IAE(org.apache.druid.java.util.common.IAE) ImmutableSet(com.google.common.collect.ImmutableSet) VectorValueMatcherColumnProcessorFactory(org.apache.druid.query.filter.vector.VectorValueMatcherColumnProcessorFactory) Collection(java.util.Collection) Range(com.google.common.collect.Range) StringUtils(org.apache.druid.java.util.common.StringUtils) Set(java.util.Set) Sets(com.google.common.collect.Sets) VectorColumnSelectorFactory(org.apache.druid.segment.vector.VectorColumnSelectorFactory) StandardCharsets(java.nio.charset.StandardCharsets) Objects(java.util.Objects) List(java.util.List) Predicate(com.google.common.base.Predicate) IntArrayList(it.unimi.dsi.fastutil.ints.IntArrayList) Joiner(com.google.common.base.Joiner) Iterables(com.google.common.collect.Iterables) Supplier(com.google.common.base.Supplier) Hashing(com.google.common.hash.Hashing) BitmapIndex(org.apache.druid.segment.column.BitmapIndex) TreeRangeSet(com.google.common.collect.TreeRangeSet) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) IntIterator(it.unimi.dsi.fastutil.ints.IntIterator) LookupExtractionFn(org.apache.druid.query.lookup.LookupExtractionFn) IntIterable(it.unimi.dsi.fastutil.ints.IntIterable) VectorValueMatcher(org.apache.druid.query.filter.vector.VectorValueMatcher) JsonIgnore(com.fasterxml.jackson.annotation.JsonIgnore) Suppliers(com.google.common.base.Suppliers) Hasher(com.google.common.hash.Hasher) Nullable(javax.annotation.Nullable) BitmapResultFactory(org.apache.druid.query.BitmapResultFactory) ColumnInspector(org.apache.druid.segment.ColumnInspector) IntIteratorUtils(org.apache.druid.segment.IntIteratorUtils) Iterator(java.util.Iterator) ColumnSelector(org.apache.druid.segment.ColumnSelector) LongOpenHashSet(it.unimi.dsi.fastutil.longs.LongOpenHashSet) IntOpenHashSet(it.unimi.dsi.fastutil.ints.IntOpenHashSet) NullHandling(org.apache.druid.common.config.NullHandling) LookupExtractor(org.apache.druid.query.lookup.LookupExtractor) JsonCreator(com.fasterxml.jackson.annotation.JsonCreator) JsonInclude(com.fasterxml.jackson.annotation.JsonInclude) Preconditions(com.google.common.base.Preconditions) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Comparator(java.util.Comparator) Filters(org.apache.druid.segment.filter.Filters) LongArrayList(it.unimi.dsi.fastutil.longs.LongArrayList) LongOpenHashSet(it.unimi.dsi.fastutil.longs.LongOpenHashSet)

Example 13 with LongArrayList

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;
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LongArrayList(it.unimi.dsi.fastutil.longs.LongArrayList) PartitionKey(com.tencent.angel.PartitionKey) TreeMap(java.util.TreeMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap) Map(java.util.Map) SortedMap(java.util.SortedMap)

Example 14 with LongArrayList

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());
}
Also used : IndexPartGetLongResult(com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult) Entry(it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry) LongArrayList(it.unimi.dsi.fastutil.longs.LongArrayList) Entry(it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry) Long2ObjectMap(it.unimi.dsi.fastutil.longs.Long2ObjectMap) GraphNode(com.tencent.angel.graph.data.GraphNode) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow)

Example 15 with LongArrayList

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());
}
Also used : IndexPartGetLongResult(com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult) IElement(com.tencent.angel.ps.storage.vector.element.IElement) LongArrayList(it.unimi.dsi.fastutil.longs.LongArrayList) Long2ObjectMap(it.unimi.dsi.fastutil.longs.Long2ObjectMap) ServerLongAnyRow(com.tencent.angel.ps.storage.vector.ServerLongAnyRow) ServerPartition(com.tencent.angel.ps.storage.partition.ServerPartition)

Aggregations

LongArrayList (it.unimi.dsi.fastutil.longs.LongArrayList)37 IntArrayList (it.unimi.dsi.fastutil.ints.IntArrayList)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 IndexPartGetLongResult (com.tencent.angel.ml.matrix.psf.get.indexed.IndexPartGetLongResult)3 ServerLongAnyRow (com.tencent.angel.ps.storage.vector.ServerLongAnyRow)3 Long2ObjectMap (it.unimi.dsi.fastutil.longs.Long2ObjectMap)3 LongList (it.unimi.dsi.fastutil.longs.LongList)3 LongOpenHashSet (it.unimi.dsi.fastutil.longs.LongOpenHashSet)3 IOException (java.io.IOException)3 List (java.util.List)3 Block (com.facebook.presto.spi.block.Block)2 Type (com.facebook.presto.spi.type.Type)2 Supplier (com.google.common.base.Supplier)2 LongFloatSparseVectorStorage (com.tencent.angel.ml.math2.storage.LongFloatSparseVectorStorage)2 LongFloatVector (com.tencent.angel.ml.math2.vector.LongFloatVector)2 FloatArrayList (it.unimi.dsi.fastutil.floats.FloatArrayList)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 BinaryDecoder (co.cask.cdap.common.io.BinaryDecoder)1