org.apache.lucene.util.fst.ListOfOutputs Maven / Gradle / Ivy
Show all versions of aem-sdk-api Show documentation
package org.apache.lucene.util.fst;
/*
* 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.
*/
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.lucene.store.DataInput;
import org.apache.lucene.store.DataOutput;
import org.apache.lucene.util.IntsRef; // javadocs
/**
* Wraps another Outputs implementation and encodes one or
* more of its output values. You can use this when a single
* input may need to map to more than one output,
* maintaining order: pass the same input with a different
* output by calling {@link Builder#add(IntsRef,Object)} multiple
* times. The builder will then combine the outputs using
* the {@link Outputs#merge(Object,Object)} method.
*
* The resulting FST may not be minimal when an input has
* more than one output, as this requires pushing all
* multi-output values to a final state.
*
*
NOTE: the only way to create multiple outputs is to
* add the same input to the FST multiple times in a row. This is
* how the FST maps a single input to multiple outputs (e.g. you
* cannot pass a List<Object> to {@link Builder#add}). If
* your outputs are longs, and you need at most 2, then use
* {@link UpToTwoPositiveIntOutputs} instead since it stores
* the outputs more compactly (by stealing a bit from each
* long value).
*
*
NOTE: this cannot wrap itself (ie you cannot make an
* FST with List<List<Object>> outputs using this).
*
* @lucene.experimental
*/
// NOTE: i think we could get a more compact FST if, instead
// of adding the same input multiple times with a different
// output each time, we added it only once with a
// pre-constructed List output. This way the "multiple
// values" is fully opaque to the Builder/FST. It would
// require implementing the full algebra using set
// arithmetic (I think?); maybe SetOfOutputs is a good name.
@SuppressWarnings("unchecked")
public final class ListOfOutputs extends Outputs