ArrayOfDoublesUnion(final ArrayOfDoublesQuickSelectSketch sketch) { nomEntries_ = sketch.getNominalEntries(); numValues_ = sketch.getNumValues(); seed_ = sketch.getSeed(); seedHash_ = Util.computeSeedHash(seed_); sketch_ = sketch; theta_ = sketch.getThetaLong(); }
@Override void insertOrIgnore(final long key, final double[] values) { if (values.length != getNumValues()) { throw new SketchesArgumentException("input array of values must have " + getNumValues() + " elements, but has " + values.length); } setNotEmpty(); if (key == 0 || key >= theta_) { return; } final int index = findOrInsertKey(key); if (index < 0) { incrementCount(); setValues(~index, values); } else { updateValues(index, values); } rebuildIfNeeded(); }
/** * Updates the union by adding a set of entries from a given sketch * @param sketchIn sketch to add to the union */ public void update(final ArrayOfDoublesSketch sketchIn) { if (sketchIn == null) { return; } Util.checkSeedHashes(seedHash_, sketchIn.getSeedHash()); if (sketch_.getNumValues() != sketchIn.getNumValues()) { throw new SketchesArgumentException("Incompatible sketches: number of values mismatch " + sketch_.getNumValues() + " and " + sketchIn.getNumValues()); } if (sketchIn.isEmpty()) { return; } if (sketchIn.getThetaLong() < theta_) { theta_ = sketchIn.getThetaLong(); } final ArrayOfDoublesSketchIterator it = sketchIn.iterator(); while (it.next()) { sketch_.merge(it.getKey(), it.getValues()); } }
ArrayOfDoublesUnion(final ArrayOfDoublesQuickSelectSketch sketch) { nomEntries_ = sketch.getNominalEntries(); numValues_ = sketch.getNumValues(); seed_ = sketch.getSeed(); seedHash_ = Util.computeSeedHash(seed_); sketch_ = sketch; theta_ = sketch.getThetaLong(); }
@Override void insertOrIgnore(final long key, final double[] values) { if (values.length != getNumValues()) { throw new SketchesArgumentException("input array of values must have " + getNumValues() + " elements, but has " + values.length); } setNotEmpty(); if (key == 0 || key >= theta_) { return; } final int index = findOrInsertKey(key); if (index < 0) { incrementCount(); setValues(~index, values); } else { updateValues(index, values); } rebuildIfNeeded(); }
/** * Updates the union by adding a set of entries from a given sketch * @param sketchIn sketch to add to the union */ public void update(final ArrayOfDoublesSketch sketchIn) { if (sketchIn == null) { return; } Util.checkSeedHashes(seedHash_, sketchIn.getSeedHash()); if (sketch_.getNumValues() != sketchIn.getNumValues()) { throw new SketchesArgumentException("Incompatible sketches: number of values mismatch " + sketch_.getNumValues() + " and " + sketchIn.getNumValues()); } if (sketchIn.isEmpty()) { return; } if (sketchIn.getThetaLong() < theta_) { theta_ = sketchIn.getThetaLong(); } final ArrayOfDoublesSketchIterator it = sketchIn.iterator(); while (it.next()) { sketch_.merge(it.getKey(), it.getValues()); } }