/*
* 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.
*/
using System;
using IndexReader = Lucene.Net.Index.IndexReader;
namespace Lucene.Net.Search
{
/// Expert: Maintains caches of term values.
///
/// lucene 1.4
/// $Id:$
/// Expert: Stores term text values and document ordering data.
public class StringIndex
{
/// All the term values, in natural order.
public System.String[] Lookup;
/// For each document, an index into the lookup array.
public int[] Order;
/// Creates one of these objects
public StringIndex(int[] values, System.String[] lookup)
{
this.Order = values;
this.Lookup = lookup;
}
}
public struct FieldCache_Fields{
/// Indicator for StringIndex values in the cache.
// NOTE: the value assigned to this constant must not be
// the same as any of those in SortField!!
public readonly static int STRING_INDEX = - 1;
/// Expert: The cache used internally by sorting and range query classes.
public readonly static FieldCache DEFAULT;
static FieldCache_Fields()
{
DEFAULT = new FieldCacheImpl();
}
}
public interface FieldCache
{
/// Checks the internal cache for an appropriate entry, and if none is
/// found, reads the terms in field
as a single byte and returns an array
/// of size reader.maxDoc()
of the value each document
/// has in the given field.
///
/// Used to get field values.
///
/// Which field contains the single byte values.
///
/// The values in the given field for each document.
///
/// IOException If any error occurs.
byte[] GetBytes(IndexReader reader, System.String field);
/// Checks the internal cache for an appropriate entry, and if none is found,
/// reads the terms in field
as bytes and returns an array of
/// size reader.maxDoc()
of the value each document has in the
/// given field.
///
/// Used to get field values.
///
/// Which field contains the bytes.
///
/// Computes byte for string values.
///
/// The values in the given field for each document.
///
/// IOException If any error occurs.
byte[] GetBytes(IndexReader reader, System.String field, ByteParser parser);
/// Checks the internal cache for an appropriate entry, and if none is
/// found, reads the terms in field
as shorts and returns an array
/// of size reader.maxDoc()
of the value each document
/// has in the given field.
///
/// Used to get field values.
///
/// Which field contains the shorts.
///
/// The values in the given field for each document.
///
/// IOException If any error occurs.
short[] GetShorts(IndexReader reader, System.String field);
/// Checks the internal cache for an appropriate entry, and if none is found,
/// reads the terms in field
as shorts and returns an array of
/// size reader.maxDoc()
of the value each document has in the
/// given field.
///
/// Used to get field values.
///
/// Which field contains the shorts.
///
/// Computes short for string values.
///
/// The values in the given field for each document.
///
/// IOException If any error occurs.
short[] GetShorts(IndexReader reader, System.String field, ShortParser parser);
/// Checks the internal cache for an appropriate entry, and if none is
/// found, reads the terms in field
as integers and returns an array
/// of size reader.maxDoc()
of the value each document
/// has in the given field.
///
/// Used to get field values.
///
/// Which field contains the integers.
///
/// The values in the given field for each document.
///
/// IOException If any error occurs.
int[] GetInts(IndexReader reader, System.String field);
/// Checks the internal cache for an appropriate entry, and if none is found,
/// reads the terms in field
as integers and returns an array of
/// size reader.maxDoc()
of the value each document has in the
/// given field.
///
/// Used to get field values.
///
/// Which field contains the integers.
///
/// Computes integer for string values.
///
/// The values in the given field for each document.
///
/// IOException If any error occurs.
int[] GetInts(IndexReader reader, System.String field, IntParser parser);
/// Checks the internal cache for an appropriate entry, and if
/// none is found, reads the terms in field
as floats and returns an array
/// of size reader.maxDoc()
of the value each document
/// has in the given field.
///
/// Used to get field values.
///
/// Which field contains the floats.
///
/// The values in the given field for each document.
///
/// IOException If any error occurs.
float[] GetFloats(IndexReader reader, System.String field);
/// Checks the internal cache for an appropriate entry, and if
/// none is found, reads the terms in field
as floats and returns an array
/// of size reader.maxDoc()
of the value each document
/// has in the given field.
///
/// Used to get field values.
///
/// Which field contains the floats.
///
/// Computes float for string values.
///
/// The values in the given field for each document.
///
/// IOException If any error occurs.
float[] GetFloats(IndexReader reader, System.String field, FloatParser parser);
/// Checks the internal cache for an appropriate entry, and if none
/// is found, reads the term values in field
and returns an array
/// of size reader.maxDoc()
containing the value each document
/// has in the given field.
///
/// Used to get field values.
///
/// Which field contains the strings.
///
/// The values in the given field for each document.
///
/// IOException If any error occurs.
System.String[] GetStrings(IndexReader reader, System.String field);
/// Checks the internal cache for an appropriate entry, and if none
/// is found reads the term values in field
and returns
/// an array of them in natural order, along with an array telling
/// which element in the term array each document uses.
///
/// Used to get field values.
///
/// Which field contains the strings.
///
/// Array of terms and index into the array for each document.
///
/// IOException If any error occurs.
StringIndex GetStringIndex(IndexReader reader, System.String field);
/// Checks the internal cache for an appropriate entry, and if
/// none is found reads field
to see if it contains integers, floats
/// or strings, and then calls one of the other methods in this class to get the
/// values. For string values, a StringIndex is returned. After
/// calling this method, there is an entry in the cache for both
/// type AUTO
and the actual found type.
///
/// Used to get field values.
///
/// Which field contains the values.
///
/// int[], float[] or StringIndex.
///
/// IOException If any error occurs.
object GetAuto(IndexReader reader, System.String field);
/// Checks the internal cache for an appropriate entry, and if none
/// is found reads the terms out of field
and calls the given SortComparator
/// to get the sort values. A hit in the cache will happen if reader
,
/// field
, and comparator
are the same (using equals()
)
/// as a previous call to this method.
///
/// Used to get field values.
///
/// Which field contains the values.
///
/// Used to convert terms into something to sort by.
///
/// Array of sort objects, one for each document.
///
/// IOException If any error occurs.
System.IComparable[] GetCustom(IndexReader reader, System.String field, SortComparator comparator);
}
/// Interface to parse bytes from document fields.
///
///
public interface ByteParser
{
/// Return a single Byte representation of this field's value.
byte ParseByte(System.String string_Renamed);
}
/// Interface to parse shorts from document fields.
///
///
public interface ShortParser
{
/// Return a short representation of this field's value.
short ParseShort(System.String string_Renamed);
}
/// Interface to parse ints from document fields.
///
///
public interface IntParser
{
/// Return an integer representation of this field's value.
int ParseInt(System.String string_Renamed);
}
/// Interface to parse floats from document fields.
///
///
public interface FloatParser
{
/// Return an float representation of this field's value.
float ParseFloat(System.String string_Renamed);
}
}