|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.apache.datasketches.tuple.aninteger; |
| 21 | + |
| 22 | +import org.apache.datasketches.ResizeFactor; |
| 23 | +import org.apache.datasketches.memory.Memory; |
| 24 | +import org.apache.datasketches.tuple.UpdatableSketch; |
| 25 | + |
| 26 | +/** |
| 27 | + * @author Lee Rhodes |
| 28 | + */ |
| 29 | +public class IntegerSketch extends UpdatableSketch<Integer, IntegerSummary> { |
| 30 | + |
| 31 | + /** |
| 32 | + * Constructs this sketch with given <i>lgK</i>. |
| 33 | + * @param lgK Log_base2 of <i>Nominal Entries</i>. |
| 34 | + * <a href="{@docRoot}/resources/dictionary.html#nomEntries">See Nominal Entries</a> |
| 35 | + * @param mode The IntegerSummary mode to be used |
| 36 | + */ |
| 37 | + public IntegerSketch(final int lgK, final IntegerSummary.Mode mode) { |
| 38 | + super(1 << lgK, ResizeFactor.X8.ordinal(), 1.0F, new IntegerSummaryFactory(mode)); |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * Constructs this sketch from a Memory image, which must be from an IntegerSketch, and |
| 43 | + * usually with data. |
| 44 | + * @param mem the given Memory |
| 45 | + * @param mode The IntegerSummary mode to be used |
| 46 | + */ |
| 47 | + public IntegerSketch(final Memory mem, final IntegerSummary.Mode mode) { |
| 48 | + super(mem, new IntegerSummaryDeserializer(), new IntegerSummaryFactory(mode)); |
| 49 | + } |
| 50 | + |
| 51 | + @Override |
| 52 | + public void update(final String key, final Integer value) { |
| 53 | + super.update(key, value); |
| 54 | + } |
| 55 | + |
| 56 | + @Override |
| 57 | + public void update(final long key, final Integer value) { |
| 58 | + super.update(key, value); |
| 59 | + } |
| 60 | + |
| 61 | +} |
0 commit comments