public DoubleColumnPreIndexStatsCollector(String column, StatsCollectorConfig statsCollectorConfig) { super(column, statsCollectorConfig); rawDoubleSet = new DoubleOpenHashSet(INITIAL_HASH_SET_SIZE); aggregatedDoubleSet = new DoubleOpenHashSet(INITIAL_HASH_SET_SIZE); }
DoubleRawValueBasedNotInPredicateEvaluator(NotInPredicate notInPredicate) { String[] values = notInPredicate.getValues(); _nonMatchingValues = new DoubleOpenHashSet(HashUtil.getMinHashSetSize(values.length)); for (String value : values) { _nonMatchingValues.add(Double.parseDouble(value)); } }
DoubleRawValueBasedInPredicateEvaluator(InPredicate inPredicate) { String[] values = inPredicate.getValues(); _matchingValues = new DoubleOpenHashSet(HashUtil.getMinHashSetSize(values.length)); for (String value : values) { _matchingValues.add(Double.parseDouble(value)); } }
@Override public double[][] transformToDoubleValuesMV(@Nonnull ProjectionBlock projectionBlock) { if (getResultMetadata().getDataType() != FieldSpec.DataType.DOUBLE) { return super.transformToDoubleValuesMV(projectionBlock); } if (_doubleValueSet == null) { _doubleValueSet = new DoubleOpenHashSet(); for (String inValue : _stringValueSet) { _doubleValueSet.add(Double.parseDouble(inValue)); } _doubleValues = new double[DocIdSetPlanNode.MAX_DOC_PER_CALL][]; } double[][] unFilteredDoubleValues = _mainTransformFunction.transformToDoubleValuesMV(projectionBlock); int length = projectionBlock.getNumDocs(); for (int i = 0; i < length; i++) { _doubleValues[i] = filterDoubles(_doubleValueSet, unFilteredDoubleValues[i]); } return _doubleValues; }
@Override public int countUnique() { DoubleSet uniqueElements = new DoubleOpenHashSet(); for (int i = 0; i < size(); i++) { if (!isMissing(i)) { uniqueElements.add(getDouble(i)); } } return uniqueElements.size(); }
@Override public DoubleColumn unique() { final DoubleSet doubles = new DoubleOpenHashSet(); for (int i = 0; i < size(); i++) { if (!isMissing(i)) { doubles.add(getDouble(i)); } } final DoubleColumn column = DoubleColumn.create(name() + " Unique values"); doubles.forEach((DoubleConsumer) column::append); return column; }
@Test public void testDoublePredicateEvaluators() { List<String> stringValues = new ArrayList<>(NUM_PREDICATE_VALUES); DoubleSet valueSet = new DoubleOpenHashSet();
Arrays.sort(_floatValues); DoubleOpenHashSet doubleSet = new DoubleOpenHashSet(); while (doubleSet.size() < NUM_VALUES) { doubleSet.add(RANDOM.nextDouble());
DoubleSet asSet() { return new DoubleOpenHashSet(data); }
return new FloatOpenHashSet(set); } else if (oCls.equals(Double.class)) { return new DoubleOpenHashSet(set); } else if (oCls.equals(Short.class)) { return new ShortOpenHashSet(set);
return new FloatOpenHashSet(set); } else if (oCls.equals(Double.class)) { return new DoubleOpenHashSet(set); } else if (oCls.equals(Short.class)) { return new ShortOpenHashSet(set);
@Override public int countUnique() { DoubleSet floats = new DoubleOpenHashSet(); for (int i = 0; i < size(); i++) { floats.add(data.getDouble(i)); } return floats.size(); }
private Set deserializeSet(final DataInput is) throws IOException, ClassNotFoundException { Object h = deserialize(is); Class oCls = h.getClass(); if (oCls.equals(Integer.class)) { int size = (Integer) h; ObjectOpenHashSet set = new ObjectOpenHashSet(size); for (int i = 0; i < size; i++) { set.add(deserialize(is)); } return set; } else if (oCls.equals(int[].class)) { return new IntOpenHashSet((int[]) h); } else if (oCls.equals(float[].class)) { return new FloatOpenHashSet((float[]) h); } else if (oCls.equals(double[].class)) { return new DoubleOpenHashSet((double[]) h); } else if (oCls.equals(short[].class)) { return new ShortOpenHashSet((short[]) h); } else if (oCls.equals(byte[].class)) { return new ByteOpenHashSet((byte[]) h); } else if (oCls.equals(long[].class)) { return new LongOpenHashSet((long[]) h); } else if (oCls.equals(boolean[].class)) { return new BooleanOpenHashSet((boolean[]) h); } else if (oCls.equals(char[].class)) { return new CharOpenHashSet((char[]) h); } throw new EOFException(); }
private Set deserializeSet(final DataInput is) throws IOException, ClassNotFoundException { Object h = deserialize(is); Class oCls = h.getClass(); if (oCls.equals(Integer.class)) { int size = (Integer) h; ObjectOpenHashSet set = new ObjectOpenHashSet(size); for (int i = 0; i < size; i++) { set.add(deserialize(is)); } return set; } else if (oCls.equals(int[].class)) { return new IntOpenHashSet((int[]) h); } else if (oCls.equals(float[].class)) { return new FloatOpenHashSet((float[]) h); } else if (oCls.equals(double[].class)) { return new DoubleOpenHashSet((double[]) h); } else if (oCls.equals(short[].class)) { return new ShortOpenHashSet((short[]) h); } else if (oCls.equals(byte[].class)) { return new ByteOpenHashSet((byte[]) h); } else if (oCls.equals(long[].class)) { return new LongOpenHashSet((long[]) h); } else if (oCls.equals(boolean[].class)) { return new BooleanOpenHashSet((boolean[]) h); } else if (oCls.equals(char[].class)) { return new CharOpenHashSet((char[]) h); } throw new EOFException(); }
@Override public int countUnique() { DoubleSet uniqueElements = new DoubleOpenHashSet(); for (int i = 0; i < size(); i++) { if (!isMissing(i)) { uniqueElements.add(getDouble(i)); } } return uniqueElements.size(); }
@Override public DoubleColumn unique() { DoubleSet floats = new DoubleOpenHashSet(); for (int i = 0; i < size(); i++) { floats.add(data.getDouble(i)); } DoubleColumn column = new DoubleColumn(name() + " Unique values", floats.size()); floats.forEach(column::add); return column; }
@Override public DoubleColumn unique() { final DoubleSet doubles = new DoubleOpenHashSet(); for (int i = 0; i < size(); i++) { if (!isMissing(i)) { doubles.add(getDouble(i)); } } final DoubleColumn column = DoubleColumn.create(name() + " Unique values"); doubles.forEach((DoubleConsumer) column::append); return column; }
hs = new DoubleOpenHashSet(); for (int k = 0; k < values.length(); k++) { hs.add(values.getDouble(k));
private UniqueDouble(Var var, boolean sorted) { super(sorted); DoubleOpenHashSet keySet = new DoubleOpenHashSet(); for (int i = 0; i < var.rowCount(); i++) { keySet.add(var.getDouble(i)); } double[] elements = keySet.toDoubleArray(); if (sorted) { DoubleArrays.quickSort(elements, new UniqueDoubleComparator()); } Double2IntOpenHashMap uniqueKeys = new Double2IntOpenHashMap(); values = new DoubleArrayList(elements); for (int i = 0; i < elements.length; i++) { uniqueKeys.put(elements[i], i); } rowLists = new Int2ObjectOpenHashMap<>(); for (int i = 0; i < var.rowCount(); i++) { double key = var.getDouble(i); int id = uniqueKeys.get(key); if (!rowLists.containsKey(id)) { rowLists.put(id, new IntArrayList()); } rowLists.get(id).add(i); } updateIdsByRow(var.rowCount()); }