1 package org.apache.lucene.facet.search;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
21 * Provider of arrays used for facet operations such as counting.
23 * @lucene.experimental
25 public class FacetArrays {
27 private int[] intArray;
28 private float[] floatArray;
29 private IntArrayAllocator intArrayAllocator;
30 private FloatArrayAllocator floatArrayAllocator;
31 private int arraysLength;
34 * Create a FacetArrays with certain array allocators.
35 * @param intArrayAllocator allocator for int arrays.
36 * @param floatArrayAllocator allocator for float arrays.
38 public FacetArrays(IntArrayAllocator intArrayAllocator,
39 FloatArrayAllocator floatArrayAllocator) {
40 this.intArrayAllocator = intArrayAllocator;
41 this.floatArrayAllocator = floatArrayAllocator;
45 * Notify allocators that they can free arrays allocated
46 * on behalf of this FacetArrays object.
49 if (intArrayAllocator!=null) {
50 intArrayAllocator.free(intArray);
51 // Should give up handle to the array now
55 if (floatArrayAllocator!=null) {
56 floatArrayAllocator.free(floatArray);
57 // Should give up handle to the array now
65 * Obtain an int array, e.g. for facet counting.
67 public int[] getIntArray() {
68 if (intArray == null) {
69 intArray = intArrayAllocator.allocate();
70 arraysLength = intArray.length;
75 /** Obtain a float array, e.g. for evaluating facet association values. */
76 public float[] getFloatArray() {
77 if (floatArray == null) {
78 floatArray = floatArrayAllocator.allocate();
79 arraysLength = floatArray.length;
85 * Return the arrays length
87 public int getArraysLength() {