Java Code Examples for org.apache.lucene.index.AtomicReader#maxDoc()

The following examples show how to use org.apache.lucene.index.AtomicReader#maxDoc() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterCache.java    From incubator-retired-blur with Apache License 2.0 6 votes vote down vote up
private DocIdSet docIdSetToCache(DocIdSet docIdSet, AtomicReader reader, String segmentName, Directory directory)
    throws IOException {
  if (docIdSet == null) {
    // this is better than returning null, as the nonnull result can be cached
    return DocIdSet.EMPTY_DOCIDSET;
  } else if (docIdSet.isCacheable()) {
    return docIdSet;
  } else {
    final DocIdSetIterator it = docIdSet.iterator();
    // null is allowed to be returned by iterator(),
    // in this case we wrap with the empty set,
    // which is cacheable.
    if (it == null) {
      return DocIdSet.EMPTY_DOCIDSET;
    } else {
      final IndexFileBitSet bits = new IndexFileBitSet(reader.maxDoc(), _id, segmentName, directory);
      if (!bits.exists()) {
        bits.create(it);
      }
      bits.load();
      return bits;
    }
  }
}
 
Example 2
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 5 votes vote down vote up
@Override
protected Accountable createValue(final AtomicReader reader, CacheKey key, boolean setDocsWithField)
    throws IOException {
  int maxDoc = reader.maxDoc();

  final int[][] matrix = new int[maxDoc][];
  BinaryDocValues valuesIn = reader.getBinaryDocValues(key.field);
  if (valuesIn == null) {
    for (int i = 0; i < maxDoc; ++i) {
      matrix[i] = new int[0];
    }
    return new IntList(matrix);
  }
  for (int i = 0; i < maxDoc; ++i) {
    String str = valuesIn.get(i).utf8ToString();
    if (StringUtils.isEmpty(str)) {
      matrix[i] = new int[0];
      continue;
    }
    JSONArray array = JSON.parseArray(str);
    matrix[i] = new int[array.size()];
    for (int j = 0; j < array.size(); ++j) {
      matrix[i][j] = array.getInteger(j);
    }
  }
  return new IntList(matrix);
}
 
Example 3
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 5 votes vote down vote up
@Override
protected Accountable createValue(final AtomicReader reader, CacheKey key, boolean setDocsWithField)
    throws IOException {
  int maxDoc = reader.maxDoc();

  final long[][] matrix = new long[maxDoc][];
  BinaryDocValues valuesIn = reader.getBinaryDocValues(key.field);
  if (valuesIn == null) {
    for (int i = 0; i < maxDoc; ++i) {
      matrix[i] = new long[0];
    }
    return new LongList(matrix);
  }
  for (int i = 0; i < maxDoc; ++i) {
    String str = valuesIn.get(i).utf8ToString();
    if (StringUtils.isEmpty(str)) {
      matrix[i] = new long[0];
      continue;
    }
    JSONArray array = JSON.parseArray(str);
    matrix[i] = new long[array.size()];
    for (int j = 0; j < array.size(); ++j) {
      matrix[i][j] = array.getInteger(j);
    }
  }
  return new LongList(matrix);
}
 
Example 4
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 5 votes vote down vote up
@Override
protected Accountable createValue(final AtomicReader reader, CacheKey key, boolean setDocsWithField)
    throws IOException {
  int maxDoc = reader.maxDoc();

  final float[][] matrix = new float[maxDoc][];
  BinaryDocValues valuesIn = reader.getBinaryDocValues(key.field);
  if (valuesIn == null) {
    for (int i = 0; i < maxDoc; ++i) {
      matrix[i] = new float[0];
    }
    return new FloatList(matrix);
  }
  for (int i = 0; i < maxDoc; ++i) {
    String str = valuesIn.get(i).utf8ToString();
    if (StringUtils.isEmpty(str)) {
      matrix[i] = new float[0];
      continue;
    }
    JSONArray array = JSON.parseArray(str);
    matrix[i] = new float[array.size()];
    for (int j = 0; j < array.size(); ++j) {
      matrix[i][j] = array.getFloat(j);
    }
  }
  return new FloatList(matrix);
}
 
Example 5
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 5 votes vote down vote up
@Override
protected Accountable createValue(final AtomicReader reader, CacheKey key, boolean setDocsWithField)
    throws IOException {
  int maxDoc = reader.maxDoc();

  final double[][] matrix = new double[maxDoc][];
  BinaryDocValues valuesIn = reader.getBinaryDocValues(key.field);
  if (valuesIn == null) {
    for (int i = 0; i < maxDoc; ++i) {
      matrix[i] = new double[0];
    }
    return new DoubleList(matrix);
  }
  for (int i = 0; i < maxDoc; ++i) {
    String str = valuesIn.get(i).utf8ToString();
    if (StringUtils.isEmpty(str)) {
      matrix[i] = new double[0];
      continue;
    }
    JSONArray array = JSON.parseArray(str);
    matrix[i] = new double[array.size()];
    for (int j = 0; j < array.size(); ++j) {
      matrix[i][j] = array.getFloat(j);
    }
  }
  return new DoubleList(matrix);
}
 
Example 6
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 5 votes vote down vote up
@Override
protected Accountable createValue(final AtomicReader reader, CacheKey key, boolean setDocsWithField)
    throws IOException {
  int maxDoc = reader.maxDoc();

  final String[][] matrix = new String[maxDoc][];
  BinaryDocValues valuesIn = reader.getBinaryDocValues(key.field);
  if (valuesIn == null) {
    for (int i = 0; i < maxDoc; ++i) {
      matrix[i] = new String[0];
    }
    return new StringList(matrix);
  }
  for (int i = 0; i < maxDoc; ++i) {
    String str = valuesIn.get(i).utf8ToString();
    if (StringUtils.isEmpty(str)) {
      matrix[i] = new String[0];
      continue;
    }
    JSONArray array = JSON.parseArray(str);
    matrix[i] = new String[array.size()];
    for (int j = 0; j < array.size(); ++j) {
      matrix[i][j] = array.getString(j);
    }
  }
  return new StringList(matrix);
}
 
Example 7
Source File: FacetExecutor.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
Info(AtomicReaderContext context, Scorer[] scorers, Lock[] locks, String instance) {
  AtomicReader reader = context.reader();
  _instance = instance;
  _bitSet = new OpenBitSet(reader.maxDoc());
  _scorers = scorers;
  _reader = reader;
  _readerStr = _reader.toString();
  _maxDoc = _reader.maxDoc();
  _locks = locks;
}
 
Example 8
Source File: LindenFieldCacheImpl.java    From linden with Apache License 2.0 4 votes vote down vote up
@Override
protected Accountable createValue(final AtomicReader reader, CacheKey key, boolean setDocsWithField)
    throws IOException {
  return new StoredStrings(reader.maxDoc(), key.field);
}
 
Example 9
Source File: FacetExecutor.java    From incubator-retired-blur with Apache License 2.0 4 votes vote down vote up
@Override
public int compare(Entry<Object, Info> o1, Entry<Object, Info> o2) {
  AtomicReader r1 = o1.getValue()._reader;
  AtomicReader r2 = o2.getValue()._reader;
  return r2.maxDoc() - r1.maxDoc();
}