Copies histogram h into the current histogram.

@param h ApproximateHistogram to copy

@return this histogram
184739
public ApproximateHistogram copy(ApproximateHistogram h)
  {
    if (h.size > this.size) {
      this.size = h.size;
      this.positions = new float[size];
      this.bins = new long[size];
    }

    System.arraycopy(h.positions, 0, this.positions, 0, h.binCount);
    System.arraycopy(h.bins, 0, this.bins, 0, h.binCount);
    this.min = h.min;
    this.max = h.max;
    this.binCount = h.binCount;
    this.count = h.count;
    return this;
  }
98987
public ZMatrixRMaj getH(ZMatrixRMaj H ) {
        H = UtilDecompositons_ZDRM.checkZeros(H,N,N);

        // copy the first row
        System.arraycopy(QH.data, 0, H.data, 0, N*2);

        for( int i = 1; i < N; i++ ) {
            System.arraycopy(QH.data, (i*N+i-1)*2, H.data, (i*N+i-1)*2, (N-i+1)*2);
        }

        return H;
    }
1137957
public static int fromHSL(float h, float s, float l) {
        int alpha = MAX_INT;
        return fromHSL(h, s, l, alpha);
    }
677799
public static <T extends Number> ImmutableNumberStatistics<T> copyOf(NumberStatistics<? extends T> statistics){
		return new ImmutableNumberStatistics<T>(statistics);
	}
1327164
public static int fromHSL(float h, float s, float l, int a) {
        int r, g, b;

        if (s == 0) {
            r = g = b = (int) (l * MAX);
        } else {
            float v1, v2;
            float hue = h / 360f;

            v2 = (l < 0.5) ? (l * (1 + s)) : ((l + s) - (l * s));
            v1 = 2 * l - v2;

            r = (int) (MAX * HueToRGB(v1, v2, hue + (1.0f / 3)));
            g = (int) (MAX * HueToRGB(v1, v2, hue));
            b = (int) (MAX * HueToRGB(v1, v2, hue - (1.0f / 3)));
        }

        return getARGB(r, g, b, a);
    }
1161788
public static ApproximateHistogram fromBytesDense(ByteBuffer buf)
  {
    int size = buf.getInt();
    int binCount = buf.getInt();

    float[] positions = new float[size];
    long[] bins = new long[size];

    buf.asFloatBuffer().get(positions);
    buf.position(buf.position() + Float.BYTES * positions.length);
    buf.asLongBuffer().get(bins);
    buf.position(buf.position() + Long.BYTES * bins.length);

    float min = buf.getFloat();
    float max = buf.getFloat();

    return new ApproximateHistogram(binCount, positions, bins, min, max);
  }
776382
public T header(Map<String, List<String>> headers) {
		return header(headers, false);
	}
835402
@SafeVarargs
    public static Map<String, Double> histogramsPlus(Map<String, Double>... histograms) {
        switch (histograms.length) {
            case 0:
                throw new IllegalArgumentException("histograms.length=" + histograms.length + "; needs to be >= 2");
                // return null;
            case 1:
                return histograms[0];
            default: // standard
        }


        final Set<String> mergedKeys = new HashSet<>();
        for (Map<String, Double> histogram : histograms) {
            mergedKeys.addAll(histogram.keySet());
        }
        final HashMap<String, Double> mergedHistogram = new HashMap<>();

        for (String key : mergedKeys) {
            double value = 0.0;
            for (Map<String, Double> histogram : histograms) {
                value += histogram.getOrDefault(key, 0.0);
            }
            mergedHistogram.put(key, value);
        }

        return mergedHistogram;
    }
243449
public Histogram_F64 newInstance() {
		Histogram_F64 out = new Histogram_F64(length);

		for (int i = 0; i < length.length; i++) {
			out.setRange(i,valueMin[i],valueMax[i]);
		}

		return out;
	}
584303
protected java.util.Map captureStatistics()
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass
                        , "captureStatistics"
                            );

        java.util.Map statistics = new java.util.HashMap();

        String histogram = " ";
        for (int n = 0; n < subMapAccessFrequency.length; n++) {
            histogram += subMapAccessFrequency[n] + " ";
            subMapAccessFrequency[n] = 0;
        }
        statistics.put("subMapAccessFrequency", histogram);

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass
                       , "captureStatistics"
                       , new Object[] { statistics }
                            );
        return statistics;
    }
110481
def copy(self, include_frequencies: bool = True) -> "HistogramBase":
        
        if include_frequencies:
            frequencies = np.copy(self.frequencies)
            missed = self._missed.copy()
            errors2 = np.copy(self.errors2)
            stats = self._stats or None
        else:
            frequencies = np.zeros_like(self._frequencies)
            errors2 = np.zeros_like(self._errors2)
            missed = np.zeros_like(self._missed)
            stats = None
        a_copy = self.__class__.__new__(self.__class__)
        a_copy._binnings = [binning.copy() for binning in self._binnings]
        a_copy._dtype = self.dtype
        a_copy._frequencies = frequencies
        a_copy._errors2 = errors2
        a_copy._meta_data = self._meta_data.copy()
        a_copy.keep_missed = self.keep_missed
        a_copy._missed = missed
        a_copy._stats = stats
        return a_copy
820488
public static ApproximateHistogram fromBytesSparse(ByteBuffer buf)
  {
    int size = buf.getInt();
    int binCount = -1 * buf.getInt();

    float[] positions = new float[size];
    long[] bins = new long[size];

    for (int i = 0; i < binCount; ++i) {
      positions[i] = buf.getFloat();
    }
    for (int i = 0; i < binCount; ++i) {
      bins[i] = buf.getLong();
    }

    float min = buf.getFloat();
    float max = buf.getFloat();

    return new ApproximateHistogram(binCount, positions, bins, min, max);
  }
581675
public static <T> T newProxyInstance(final Class<?>[] interfaceClasses, final InvocationHandler h) {
        return (T) Proxy.newProxyInstance(N.class.getClassLoader(), interfaceClasses, h);
    }
379366
public static IoBuffer copy(ByteBuffer src) {
        IoBuffer copy = IoBuffer.allocate(src.remaining());
        copy.put(src);
        copy.flip();
        return copy;
    }
1126586
public void mergeHistograms(MetricInfo metricInfo, String meta, Map<Integer, MetricSnapshot> data,
                                Map<String, Integer> metaCounters, Map<String, Map<Integer, Histogram>> histograms) {
        Map<Integer, MetricSnapshot> existing = metricInfo.get_metrics().get(meta);
        if (existing == null) {
            metricInfo.put_to_metrics(meta, data);
            Map<Integer, Histogram> histogramMap = new HashMap<>();
            for (Map.Entry<Integer, MetricSnapshot> dataEntry : data.entrySet()) {
                Histogram histogram = MetricUtils.metricSnapshot2Histogram(dataEntry.getValue());
                histogramMap.put(dataEntry.getKey(), histogram);
            }
            histograms.put(meta, histogramMap);
        } else {
            for (Map.Entry<Integer, MetricSnapshot> dataEntry : data.entrySet()) {
                Integer win = dataEntry.getKey();
                MetricSnapshot snapshot = dataEntry.getValue();
                MetricSnapshot old = existing.get(win);
                if (old == null) {
                    existing.put(win, snapshot);
                    histograms.get(meta).put(win, MetricUtils.metricSnapshot2Histogram(snapshot));
                } else {
                    if (snapshot.get_ts() >= old.get_ts()) {
                        old.set_ts(snapshot.get_ts());
                        Histogram histogram = histograms.get(meta).get(win);
                        Snapshot updateSnapshot = histogram.getSnapshot();
                        if (updateSnapshot instanceof JAverageSnapshot) {
                            sumMetricSnapshot(((JAverageSnapshot) updateSnapshot).getMetricSnapshot(), snapshot);
                        } else {
                            // update points
                            MetricUtils.updateHistogramPoints(histogram, snapshot.get_points(), snapshot.get_pointSize());
                        }
                    }
                }
            }
        }
        updateMetricCounters(meta, metaCounters);
    }
386014
private Histogram getHistogram(String entity, String watermarkColumn, SourceState state,
      Partition partition) {
    SalesforceConnector connector = getConnector(state);

    try {
      if (!connector.connect()) {
        throw new RuntimeException("Failed to connect.");
      }
    } catch (RestApiConnectionException e) {
      throw new RuntimeException("Failed to connect.", e);
    }

    Histogram histogram = getHistogramByDayBucketing(connector, entity, watermarkColumn, partition);

    // exchange the first histogram group key with the global low watermark to ensure that the low watermark is captured
    // in the range of generated partitions
    HistogramGroup firstGroup = histogram.get(0);
    Date lwmDate = Utils.toDate(partition.getLowWatermark(), Partitioner.WATERMARKTIMEFORMAT);
    histogram.getGroups().set(0, new HistogramGroup(Utils.epochToDate(lwmDate.getTime(), SECONDS_FORMAT),
        firstGroup.getCount()));

    // refine the histogram
    if (state.getPropAsBoolean(ENABLE_DYNAMIC_PROBING)) {
      histogram = getRefinedHistogram(connector, entity, watermarkColumn, state, partition, histogram);
    }

    return histogram;
  }
923785
protected void CopyHeader()
	{
		seek(0);
        @SuppressWarnings("unused")
		int major = getCard8();
        @SuppressWarnings("unused")
		int minor = getCard8();
        int hdrSize = getCard8();
        @SuppressWarnings("unused")
		int offSize = getCard8();
        nextIndexOffset = hdrSize;
        OutputList.addLast(new RangeItem(buf,0,hdrSize));
	}