]>
git.proxmox.com Git - ceph.git/blob - ceph/src/arrow/java/algorithm/src/main/java/org/apache/arrow/algorithm/dictionary/DictionaryBuilder.java
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 package org
.apache
.arrow
.algorithm
.dictionary
;
20 import org
.apache
.arrow
.vector
.ValueVector
;
23 * A dictionary builder is intended for the scenario frequently encountered in practice:
24 * the dictionary is not known a priori, so it is generated dynamically.
25 * In particular, when a new value arrives, it is tested to check if it is already
26 * in the dictionary. If so, it is simply neglected, otherwise, it is added to the dictionary.
28 * The dictionary builder is intended to build a single dictionary.
29 * So it cannot be used for different dictionaries.
31 * <p>Below gives the sample code for using the dictionary builder
33 * DictionaryBuilder dictionaryBuilder = ...
35 * dictionaryBuild.addValue(newValue);
40 * With the above code, the dictionary vector will be populated,
41 * and it can be retrieved by the {@link DictionaryBuilder#getDictionary()} method.
42 * After that, dictionary encoding can proceed with the populated dictionary..
45 * @param <V> the dictionary vector type.
47 public interface DictionaryBuilder
<V
extends ValueVector
> {
50 * Try to add all values from the target vector to the dictionary.
52 * @param targetVector the target vector containing values to probe.
53 * @return the number of values actually added to the dictionary.
55 int addValues(V targetVector
);
58 * Try to add an element from the target vector to the dictionary.
60 * @param targetVector the target vector containing new element.
61 * @param targetIndex the index of the new element in the target vector.
62 * @return the index of the new element in the dictionary.
64 int addValue(V targetVector
, int targetIndex
);
67 * Gets the dictionary built.
69 * @return the dictionary.