blob: 6b148009b565d37cc4b2caafdb283827a0cee7f1 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.datasketches.kll;
import static org.apache.datasketches.kll.KllSketch.Error.TGT_IS_READ_ONLY;
import static org.apache.datasketches.kll.KllSketch.Error.kllSketchThrow;
import org.apache.datasketches.memory.MemoryRequestServer;
import org.apache.datasketches.memory.WritableMemory;
abstract class KllFloatsProxy extends KllSketch {
KllFloatsProxy(final WritableMemory wmem, final MemoryRequestServer memReqSvr) {
super(SketchType.FLOATS_SKETCH, wmem, memReqSvr);
}
/**
* @return full size of internal items array including garbage.
*/
abstract float[] getFloatItemsArray();
abstract float getFloatSingleItem();
abstract float getMaxFloatItem();
abstract float getMinFloatItem();
abstract void setFloatItemsArray(float[] floatItems);
abstract void setFloatItemsArrayAt(int index, float item);
abstract void setMaxFloatItem(float item);
abstract void setMinFloatItem(float item);
/**
* {@inheritDoc}
* <p>The parameter <i>k</i> will not change.</p>
*/
@Override
public final void reset() {
if (readOnly) { kllSketchThrow(TGT_IS_READ_ONLY); }
final int k = getK();
setN(0);
setMinK(k);
setNumLevels(1);
setLevelZeroSorted(false);
setLevelsArray(new int[] {k, k});
setMinFloatItem(Float.NaN);
setMaxFloatItem(Float.NaN);
setFloatItemsArray(new float[k]);
}
}