lucene-core-2.9.4-dev

NALYZED)
    {
      isIndexed = true;
      isTokenized = true;
    }
    else if (index == Index.NOT_ANALYZED)
    {
      isIndexed = true;
      isTokenized = false;
    }
    else if (index == Index.NOT_ANALYZED_NO_NORMS)
    {
      isIndexed = true;
      isTokenized = false;
      omitNorms = true;
    }
    else if (index == Index.ANALYZED_NO_NORMS)
    {
      isIndexed = true;
      isTokenized = true;
      omitNorms = true;
    }
    else
    {
      throw new IllegalArgumentException("unknown index parameter " + index);
    }
    isBinary = false;
    
    setStoreTermVector(termVector);
  }
  
  public Field(String name, Reader reader)
  {
    this(name, reader, TermVector.NO);
  }
  
  public Field(String name, Reader reader, TermVector termVector)
  {
    if (name == null) {
      throw new NullPointerException("name cannot be null");
    }
    if (reader == null) {
      throw new NullPointerException("reader cannot be null");
    }
    this.name = StringHelper.intern(name);
    fieldsData = reader;
    
    isStored = false;
    isCompressed = false;
    
    isIndexed = true;
    isTokenized = true;
    
    isBinary = false;
    
    setStoreTermVector(termVector);
  }
  
  public Field(String name, TokenStream tokenStream)
  {
    this(name, tokenStream, TermVector.NO);
  }
  
  public Field(String name, TokenStream tokenStream, TermVector termVector)
  {
    if (name == null) {
      throw new NullPointerException("name cannot be null");
    }
    if (tokenStream == null) {
      throw new NullPointerException("tokenStream cannot be null");
    }
    this.name = StringHelper.intern(name);
    fieldsData = null;
    this.tokenStream = tokenStream;
    
    isStored = false;
    isCompressed = false;
    
    isIndexed = true;
    isTokenized = true;
    
    isBinary = false;
    
    setStoreTermVector(termVector);
  }
  
  public Field(String name, byte[] value, Store store)
  {
    this(name, value, 0, value.length, store);
  }
  
  public Field(String name, byte[] value, int offset, int length, Store store)
  {
    if (name == null) {
      throw new IllegalArgumentException("name cannot be null");
    }
    if (value == null) {
      throw new IllegalArgumentException("value cannot be null");
    }
    this.name = StringHelper.intern(name);
    fieldsData = value;
    if (store == Store.YES)
    {
      isStored = true;
      isCompressed = false;
    }
    else if (store == Store.COMPRESS)
    {
      isStored = true;
      isCompressed = true;
    }
    else
    {
      if (store == Store.NO) {
        throw new IllegalArgumentException("binary values can't be unstored");
      }
      throw new IllegalArgumentException("unknown store parameter " + store);
    }
    isIndexed = false;
    isTokenized = false;
    omitTermFreqAndPositions = false;
    omitNorms = true;
    
    isBinary = true;
    binaryLength = length;
    binaryOffset = offset;
    
    setStoreTermVector(TermVector.NO);
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.document.Field
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.document;

import java.io.Serializable;

public abstract interface FieldSelector
  extends Serializable
{
  public abstract FieldSelectorResult accept(String paramString);
}

/* Location:
 * Qualified Name:     org.apache.lucene.document.FieldSelector
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.document;

import java.io.Serializable;

public final class FieldSelectorResult
  implements Serializable
{
  public static final transient FieldSelectorResult LOAD = new FieldSelectorResult(0);
  public static final transient FieldSelectorResult LAZY_LOAD = new FieldSelectorResult(1);
  public static final transient FieldSelectorResult NO_LOAD = new FieldSelectorResult(2);
  public static final transient FieldSelectorResult LOAD_AND_BREAK = new FieldSelectorResult(3);
  /**
   * @deprecated
   */
  public static final transient FieldSelectorResult LOAD_FOR_MERGE = new FieldSelectorResult(4);
  public static final transient FieldSelectorResult SIZE = new FieldSelectorResult(5);
  public static final transient FieldSelectorResult SIZE_AND_BREAK = new FieldSelectorResult(6);
  private int id;
  
  private FieldSelectorResult(int id)
  {
    this.id = id;
  }
  
  public boolean equals(Object o)
  {
    if (this == o) {
      return true;
    }
    if ((o == null) || (getClass() != o.getClass())) {
      return false;
    }
    FieldSelectorResult that = (FieldSelectorResult)o;
    if (id != id) {
      return false;
    }
    return true;
  }
  
  public int hashCode()
  {
    return id;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.document.FieldSelectorResult
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.document;

import java.io.Reader;
import java.io.Serializable;
import org.apache.lucene.analysis.TokenStream;

public abstract interface Fieldable
  extends Serializable
{
  public abstract void setBoost(float paramFloat);
  
  public abstract float getBoost();
  
  public abstract String name();
  
  public abstract String stringValue();
  
  public abstract Reader readerValue();
  
  public abstract byte[] binaryValue();
  
  public abstract TokenStream tokenStreamValue();
  
  public abstract boolean isStored();
  
  public abstract boolean isIndexed();
  
  public abstract boolean isTokenized();
  
  public abstract boolean isCompressed();
  
  public abstract boolean isTermVectorStored();
  
  public abstract boolean isStoreOffsetWithTermVector();
  
  public abstract boolean isStorePositionWithTermVector();
  
  public abstract boolean isBinary();
  
  public abstract boolean getOmitNorms();
  
  public abstract void setOmitNorms(boolean paramBoolean);
  
  /**
   * @deprecated
   */
  public abstract void setOmitTf(boolean paramBoolean);
  
  /**
   * @deprecated
   */
  public abstract boolean getOmitTf();
  
  public abstract boolean isLazy();
  
  public abstract int getBinaryOffset();
  
  public abstract int getBinaryLength();
  
  public abstract byte[] getBinaryValue();
  
  public abstract byte[] getBinaryValue(byte[] paramArrayOfByte);
}

/* Location:
 * Qualified Name:     org.apache.lucene.document.Fieldable
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.document;

public class LoadFirstFieldSelector
  implements FieldSelector
{
  public FieldSelectorResult accept(String fieldName)
  {
    return FieldSelectorResult.LOAD_AND_BREAK;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.document.LoadFirstFieldSelector
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.document;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MapFieldSelector
  implements FieldSelector
{
  Map fieldSelections;
  
  public MapFieldSelector(Map fieldSelections)
  {
    this.fieldSelections = fieldSelections;
  }
  
  public MapFieldSelector(List fields)
  {
    fieldSelections = new HashMap(fields.size() * 5 / 3);
    for (int i = 0; i < fields.size(); i++) {
      fieldSelections.put(fields.get(i), FieldSelectorResult.LOAD);
    }
  }
  
  public MapFieldSelector(String[] fields)
  {
    fieldSelections = new HashMap(fields.length * 5 / 3);
    for (int i = 0; i < fields.length; i++) {
      fieldSelections.put(fields[i], FieldSelectorResult.LOAD);
    }
  }
  
  public FieldSelectorResult accept(String field)
  {
    FieldSelectorResult selection = (FieldSelectorResult)fieldSelections.get(field);
    return selection != null ? selection : FieldSelectorResult.NO_LOAD;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.document.MapFieldSelector
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.document;

/**
 * @deprecated
 */
public class NumberTools
{
  private static final int RADIX = 36;
  private static final char NEGATIVE_PREFIX = '-';
  private static final char POSITIVE_PREFIX = '0';
  public static final String MIN_STRING_VALUE = "-0000000000000";
  public static final String MAX_STRING_VALUE = "01y2p0ij32e8e7";
  public static final int STR_SIZE = "-0000000000000".length();
  
  public static String longToString(long l)
  {
    if (l == Long.MIN_VALUE) {
      return "-0000000000000";
    }
    StringBuffer buf = new StringBuffer(STR_SIZE);
    if (l < 0L)
    {
      buf.append('-');
      l = Long.MAX_VALUE + l + 1L;
    }
    else
    {
      buf.append('0');
    }
    String num = Long.toString(l, 36);
    
    int padLen = STR_SIZE - num.length() - buf.length();
    while (padLen-- > 0) {
      buf.append('0');
    }
    buf.append(num);
    
    return buf.toString();
  }
  
  public static long stringToLong(String str)
  {
    if (str == null) {
      throw new NullPointerException("string cannot be null");
    }
    if (str.length() != STR_SIZE) {
      throw new NumberFormatException("string is the wrong size");
    }
    if (str.equals("-0000000000000")) {
      return Long.MIN_VALUE;
    }
    char prefix = str.charAt(0);
    long l = Long.parseLong(str.substring(1), 36);
    if (prefix != '0') {
      if (prefix == '-') {
        l = l - Long.MAX_VALUE - 1L;
      } else {
        throw new NumberFormatException("string does not begin with the correct prefix");
      }
    }
    return l;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.document.NumberTools
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.document;

import java.io.Reader;
import org.apache.lucene.analysis.NumericTokenStream;
import org.apache.lucene.analysis.TokenStream;

public final class NumericField
  extends AbstractField
{
  private final NumericTokenStream tokenStream;
  
  public NumericField(String name)
  {
    this(name, 4, Field.Store.NO, true);
  }
  
  public NumericField(String name, Field.Store store, boolean index)
  {
    this(name, 4, store, index);
  }
  
  public NumericField(String name, int precisionStep)
  {
    this(name, precisionStep, Field.Store.NO, true);
  }
  
  public NumericField(String name, int precisionStep, Field.Store store, boolean index)
  {
    super(name, store, index ? Field.Index.ANALYZED_NO_NORMS : Field.Index.NO, Field.TermVector.NO);
    setOmitTermFreqAndPositions(true);
    tokenStream = new NumericTokenStream(precisionStep);
  }
  
  public TokenStream tokenStreamValue()
  {
    return isIndexed() ? tokenStream : null;
  }
  
  public byte[] binaryValue()
  {
    return null;
  }
  
  public byte[] getBinaryValue(byte[] result)
  {
    return null;
  }
  
  public Reader readerValue()
  {
    return null;
  }
  
  public String stringValue()
  {
    return fieldsData == null ? null : fieldsData.toString();
  }
  
  public Number getNumericValue()
  {
    return (Number)fieldsData;
  }
  
  public NumericField setLongValue(long value)
  {
    tokenStream.setLongValue(value);
    fieldsData = new Long(value);
    return this;
  }
  
  public NumericField setIntValue(int value)
  {
    tokenStream.setIntValue(value);
    fieldsData = new Integer(value);
    return this;
  }
  
  public NumericField setDoubleValue(double value)
  {
    tokenStream.setDoubleValue(value);
    fieldsData = new Double(value);
    return this;
  }
  
  public NumericField setFloatValue(float value)
  {
    tokenStream.setFloatValue(value);
    fieldsData = new Float(value);
    return this;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.document.NumericField
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.document;

import java.util.Set;

public class SetBasedFieldSelector
  implements FieldSelector
{
  private Set fieldsToLoad;
  private Set lazyFieldsToLoad;
  
  public SetBasedFieldSelector(Set fieldsToLoad, Set lazyFieldsToLoad)
  {
    this.fieldsToLoad = fieldsToLoad;
    this.lazyFieldsToLoad = lazyFieldsToLoad;
  }
  
  public FieldSelectorResult accept(String fieldName)
  {
    FieldSelectorResult result = FieldSelectorResult.NO_LOAD;
    if (fieldsToLoad.contains(fieldName) == true) {
      result = FieldSelectorResult.LOAD;
    }
    if (lazyFieldsToLoad.contains(fieldName) == true) {
      result = FieldSelectorResult.LAZY_LOAD;
    }
    return result;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.document.SetBasedFieldSelector
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

import java.io.IOException;

public abstract class AbstractAllTermDocs
  implements TermDocs
{
  protected int maxDoc;
  protected int doc = -1;
  
  protected AbstractAllTermDocs(int maxDoc)
  {
    this.maxDoc = maxDoc;
  }
  
  public void seek(Term term)
    throws IOException
  {
    if (term == null) {
      doc = -1;
    } else {
      throw new UnsupportedOperationException();
    }
  }
  
  public void seek(TermEnum termEnum)
    throws IOException
  {
    throw new UnsupportedOperationException();
  }
  
  public int doc()
  {
    return doc;
  }
  
  public int freq()
  {
    return 1;
  }
  
  public boolean next()
    throws IOException
  {
    return skipTo(doc + 1);
  }
  
  public int read(int[] docs, int[] freqs)
    throws IOException
  {
    int length = docs.length;
    int i = 0;
    while ((i < length) && (doc < maxDoc))
    {
      if (!isDeleted(doc))
      {
        docs[i] = doc;
        freqs[i] = 1;
        i++;
      }
      doc += 1;
    }
    return i;
  }
  
  public boolean skipTo(int target)
    throws IOException
  {
    doc = target;
    while (doc < maxDoc)
    {
      if (!isDeleted(doc)) {
        return true;
      }
      doc += 1;
    }
    return false;
  }
  
  public void close()
    throws IOException
  {}
  
  public abstract boolean isDeleted(int paramInt);
}

/* Location:
 * Qualified Name:     org.apache.lucene.index.AbstractAllTermDocs
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

import org.apache.lucene.util.BitVector;

class AllTermDocs
  extends AbstractAllTermDocs
{
  protected BitVector deletedDocs;
  
  protected AllTermDocs(SegmentReader parent)
  {
    super(parent.maxDoc());
    synchronized (parent)
    {
      deletedDocs = deletedDocs;
    }
  }
  
  public boolean isDeleted(int doc)
  {
    return (deletedDocs != null) && (deletedDocs.get(doc));
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.index.AllTermDocs
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

final class BufferedDeletes$Num
{
  private int num;
  
  BufferedDeletes$Num(int num)
  {
    this.num = num;
  }
  
  int getNum()
  {
    return num;
  }
  
  void setNum(int num)
  {
    if (num > this.num) {
      this.num = num;
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.index.BufferedDeletes.Num
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;

class BufferedDeletes
{
  int numTerms;
  Map terms;
  Map queries = new HashMap();
  List docIDs = new ArrayList();
  long bytesUsed;
  private final boolean doTermSort;
  
  public BufferedDeletes(boolean doTermSort)
  {
    this.doTermSort = doTermSort;
    if (doTermSort) {
      terms = new TreeMap();
    } else {
      terms = new HashMap();
    }
  }
  
  static final class Num
  {
    private int num;
    
    Num(int num)
    {
      this.num = num;
    }
    
    int getNum()
    {
      return num;
    }
    
    void setNum(int num)
    {
      if (num > this.num) {
        this.num = num;
      }
    }
  }
  
  int size()
  {
    return numTerms + queries.size() + docIDs.size();
  }
  
  void update(BufferedDeletes in)
  {
    numTerms += numTerms;
    bytesUsed += bytesUsed;
    terms.putAll(terms);
    queries.putAll(queries);
    docIDs.addAll(docIDs);
    in.clear();
  }
  
  void clear()
  {
    terms.clear();
    queries.clear();
    docIDs.clear();
    numTerms = 0;
    bytesUsed = 0L;
  }
  
  void addBytesUsed(long b)
  {
    bytesUsed += b;
  }
  
  boolean any()
  {
    return (terms.size() > 0) || (docIDs.size() > 0) || (queries.size() > 0);
  }
  
  synchronized void remap(MergeDocIDRemapper mapper, SegmentInfos infos, int[][] docMaps, int[] delCounts, MergePolicy.OneMerge merge, int mergeDocCount)
  {
    Map newDeleteTerms;
    if (terms.size() > 0)
    {
      Map newDeleteTerms;
      Map newDeleteTerms;
      if (doTermSort) {
        newDeleteTerms = new TreeMap();
      } else {
        newDeleteTerms = new HashMap();
      }
      Iterator iter = terms.entrySet().iterator();
      while (iter.hasNext())
      {
        Map.Entry entry = (Map.Entry)iter.next();
        Num num = (Num)entry.getValue();
        newDeleteTerms.put(entry.getKey(), new Num(mapper.remap(num.getNum())));
      }
    }
    else
    {
      newDeleteTerms = null;
    }
    List newDeleteDocIDs;
    if (docIDs.size() > 0)
    {
      List newDeleteDocIDs = new ArrayList(docIDs.size());
      Iterator iter = docIDs.iterator();
      while (iter.hasNext())
      {
        Integer num = (Integer)iter.next();
        newDeleteDocIDs.add(new Integer(mapper.remap(num.intValue())));
      }
    }
    else
    {
      newDeleteDocIDs = null;
    }
    HashMap newDeleteQueries;
    if (queries.size() > 0)
    {
      HashMap newDeleteQueries = new HashMap(queries.size());
      Iterator iter = queries.entrySet().iterator();
      while (iter.hasNext())
      {
        Map.Entry entry = (Map.Entry)iter.next();
        Integer num = (Integer)entry.getValue();
        newDeleteQueries.put(entry.getKey(), new Integer(mapper.remap(num.intValue())));
      }
    }
    else
    {
      newDeleteQueries = null;
    }
    if (newDeleteTerms != null) {
      terms = newDeleteTerms;
    }
    if (newDeleteDocIDs != null) {
      docIDs = newDeleteDocIDs;
    }
    if (newDeleteQueries != null) {
      queries = newDeleteQueries;
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.index.BufferedDeletes
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

import java.util.List;

abstract class ByteBlockPool$Allocator
{
  abstract void recycleByteBlocks(byte[][] paramArrayOfByte, int paramInt1, int paramInt2);
  
  abstract void recycleByteBlocks(List paramList);
  
  abstract byte[] getByteBlock(boolean paramBoolean);
}

/* Location:
 * Qualified Name:     org.apache.lucene.index.ByteBlockPool.Allocator
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

import java.util.Arrays;
import java.util.List;

final class ByteBlockPool
{
  public byte[][] buffers = new byte[10][];
  int bufferUpto = -1;
  public int byteUpto = 32768;
  public byte[] buffer;
  public int byteOffset = 32768;
  private final boolean trackAllocations;
  private final Allocator allocator;
  
  public ByteBlockPool(Allocator allocator, boolean trackAllocations)
  {
    this.allocator = allocator;
    this.trackAllocations = trackAllocations;
  }
  
  public void reset()
  {
    if (bufferUpto != -1)
    {
      for (int i = 0; i < bufferUpto; i++) {
        Arrays.fill(buffers[i], (byte)0);
      }
      Arrays.fill(buffers[bufferUpto], 0, byteUpto, (byte)0);
      if (bufferUpto > 0) {
        allocator.recycleByteBlocks(buffers, 1, 1 + bufferUpto);
      }
      bufferUpto = 0;
      byteUpto = 0;
      byteOffset = 0;
      buffer = buffers[0];
    }
  }
  
  public void nextBuffer()
  {
    if (1 + bufferUpto == buffers.length)
    {
      byte[][] newBuffers = new byte[(int)(buffers.length * 1.5D)][];
      System.arraycopy(buffers, 0, newBuffers, 0, buffers.length);
      buffers = newBuffers;
    }
    buffer = (buffers[(1 + bufferUpto)] = allocator.getByteBlock(trackAllocations));
    bufferUpto += 1;
    
    byteUpto = 0;
    byteOffset += 32768;
  }
  
  public int newSlice(int size)
  {
    if (byteUpto > 32768 - size) {
      nextBuffer();
    }
    int upto = byteUpto;
    byteUpto += size;
    buffer[(byteUpto - 1)] = 16;
    return upto;
  }
  
  static final int[] nextLevelArray = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 9 };
  static final int[] levelSizeArray = { 5, 14, 20, 30, 40, 40, 80, 80, 120, 200 };
  static final int FIRST_LEVEL_SIZE = levelSizeArray[0];
  
  public int allocSlice(byte[] slice, int upto)
  {
    int level = slice[upto] & 0xF;
    int newLevel = nextLevelArray[level];
    int newSize = levelSizeArray[newLevel];
    if (byteUpto > 32768 - newSize) {
      nextBuffer();
    }
    int newUpto = byteUpto;
    int offset = newUpto + byteOffset;
    byteUpto += newSize;
    
    buffer[newUpto] = slice[(upto - 3)];
    buffer[(newUpto + 1)] = slice[(upto - 2)];
    buffer[(newUpto + 2)] = slice[(upto - 1)];
    
    slice[(upto - 3)] = ((byte)(offset >>> 24));
    slice[(upto - 2)] = ((byte)(offset >>> 16));
    slice[(upto - 1)] = ((byte)(offset >>> 8));
    slice[upto] = ((byte)offset);
    
    buffer[(byteUpto - 1)] = ((byte)(0x10 | newLevel));
    
    return newUpto + 3;
  }
  
  static abstract class Allocator
  {
    abstract void recycleByteBlocks(byte[][] paramArrayOfByte, int paramInt1, int paramInt2);
    
    abstract void recycleByteBlocks(List paramList);
    
    abstract byte[] getByteBlock(boolean paramBoolean);
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.index.ByteBlockPool
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

import java.io.IOException;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;

final class ByteSliceReader
  extends IndexInput
{
  ByteBlockPool pool;
  int bufferUpto;
  byte[] buffer;
  public int upto;
  int limit;
  int level;
  public int bufferOffset;
  public int endIndex;
  
  public void init(ByteBlockPool pool, int startIndex, int endIndex)
  {
    assert (endIndex - startIndex >= 0);
    assert (startIndex >= 0);
    assert (endIndex >= 0);
    
    this.pool = pool;
    this.endIndex = endIndex;
    
    level = 0;
    bufferUpto = (startIndex / 32768);
    bufferOffset = (bufferUpto * 32768);
    buffer = buffers[bufferUpto];
    upto = (startIndex & 0x7FFF);
    
    int firstSize = ByteBlockPool.levelSizeArray[0];
    if (startIndex + firstSize >= endIndex) {
      limit = (endIndex & 0x7FFF);
    } else {
      limit = (upto + firstSize - 4);
    }
  }
  
  public boolean eof()
  {
    assert (upto + bufferOffset <= endIndex);
    return upto + bufferOffset == endIndex;
  }
  
  public byte readByte()
  {
    assert (!eof());
    assert (upto <= limit);
    if (upto == limit) {
      nextSlice();
    }
    return buffer[(upto++)];
  }
  
  public long writeTo(IndexOutput out)
    throws IOException
  {
    long size = 0L;
    for (;;)
    {
      if (limit + bufferOffset == endIndex)
      {
        assert (endIndex - bufferOffset >= upto);
        out.writeBytes(buffer, upto, limit - upto);
        size += limit - upto;
        break;
      }
      out.writeBytes(buffer, upto, limit - upto);
      size += limit - upto;
      nextSlice();
    }
    return size;
  }
  
  public void nextSlice()
  {
    int nextIndex = ((buffer[limit] & 0xFF) << 24) + ((buffer[(1 + limit)] & 0xFF) << 16) + ((buffer[(2 + limit)] & 0xFF) << 8) + (buffer[(3 + limit)] & 0xFF);
    
    level = ByteBlockPool.nextLevelArray[level];
    int newSize = ByteBlockPool.levelSizeArray[level];
    
    bufferUpto = (nextIndex / 32768);
    bufferOffset = (bufferUpto * 32768);
    
    buffer = pool.buffers[bufferUpto];
    upto = (nextIndex & 0x7FFF);
    if (nextIndex + newSize >= endIndex)
    {
      assert (endIndex - nextIndex > 0);
      limit = (endIndex - bufferOffset);
    }
    else
    {
      limit = (upto + newSize - 4);
    }
  }
  
  public void readBytes(byte[] b, int offset, int len)
  {
    while (len > 0)
    {
      int numLeft = limit - upto;
      if (numLeft < len)
      {
        System.arraycopy(buffer, upto, b, offset, numLeft);
        offset += numLeft;
        len -= numLeft;
        nextSlice();
      }
      else
      {
        System.arraycopy(buffer, upto, b, offset, len);
        upto += len;
        break;
      }
    }
  }
  
  public long getFilePointer()
  {
    throw new RuntimeException("not implemented");
  }
  
  public long length()
  {
    throw new RuntimeException("not implemented");
  }
  
  public void seek(long pos)
  {
    throw new RuntimeException("not implemented");
  }
  
  public void close()
  {
    throw new RuntimeException("not implemented");
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.index.ByteSliceReader
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

final class ByteSliceWriter
{
  private byte[] slice;
  private int upto;
  private final ByteBlockPool pool;
  int offset0;
  
  public ByteSliceWriter(ByteBlockPool pool)
  {
    this.pool = pool;
  }
  
  public void init(int address)
  {
    slice = pool.buffers[(address >> 15)];
    assert (slice != null);
    upto = (address & 0x7FFF);
    offset0 = address;
    assert (upto < slice.length);
  }
  
  public void writeByte(byte b)
  {
    assert (slice != null);
    if (slice[upto] != 0)
    {
      upto = pool.allocSlice(slice, upto);
      slice = pool.buffer;
      offset0 = pool.byteOffset;
      assert (slice != null);
    }
    slice[(upto++)] = b;
    assert (upto != slice.length);
  }
  
  public void writeBytes(byte[] b, int offset, int len)
  {
    int offsetEnd = offset + len;
    for (; offset < offsetEnd; throw new AssertionError())
    {
      label5:
      if (slice[upto] != 0)
      {
        upto = pool.allocSlice(slice, upto);
        slice = pool.buffer;
        offset0 = pool.byteOffset;
      }
      slice[(upto++)] = b[(offset++)];
      if (($assertionsDisabled) || (upto != slice.length)) {
        break label5;
      }
    }
  }
  
  public int getAddress()
  {
    return upto + (offset0 & 0x8000);
  }
  
  public void writeVInt(int i)
  {
    while ((i & 0xFFFFFF80) != 0)
    {
      writeByte((byte)(i & 0x7F | 0x80));
      i >>>= 7;
    }
    writeByte((byte)i);
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.index.ByteSliceWriter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

final class CharBlockPool
{
  public char[][] buffers = new char[10][];
  int numBuffer;
  int bufferUpto = -1;
  public int charUpto = 16384;
  public char[] buffer;
  public int charOffset = 49152;
  private final DocumentsWriter docWriter;
  
  public CharBlockPool(DocumentsWriter docWriter)
  {
    this.docWriter = docWriter;
  }
  
  public void reset()
  {
    docWriter.recycleCharBlocks(buffers, 1 + bufferUpto);
    bufferUpto = -1;
    charUpto = 16384;
    charOffset = 49152;
  }
  
  public void nextBuffer()
  {
    if (1 + bufferUpto == buffers.length)
    {
      char[][] newBuffers = new char[(int)(buffers.length * 1.5D)][];
      System.arraycopy(buffers, 0, newBuffers, 0, buffers.length);
      buffers = newBuffers;
    }
    buffer = (buffers[(1 + bufferUpto)] = docWriter.getCharBlock());
    bufferUpto += 1;
    
    charUpto = 0;
    charOffset += 16384;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.index.CharBlockPool
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

import java.io.IOException;

class CheckIndex$MySegmentTermDocs
  extends SegmentTermDocs
{
  int delCount;
  
  CheckIndex$MySegmentTermDocs(SegmentReader p)
  {
    super(p);
  }
  
  public void seek(Term term)
    throws IOException
  {
    super.seek(term);
    delCount = 0;
  }
  
  protected void skippingDoc()
    throws IOException
  {
    delCount += 1;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.index.CheckIndex.MySegmentTermDocs
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

public final class CheckIndex$Status$FieldNormStatus
{
  public long totFields = 0L;
  public Throwable error = null;
}

/* Location:
 * Qualified Name:     org.apache.lucene.index.CheckIndex.Status.FieldNormStatus
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

import java.util.Map;

public class CheckIndex$Status$SegmentInfoStatus
{
  public String name;
  public int docCount;
  public boolean compound;
  public int numFiles;
  public double sizeMB;
  public int docStoreOffset = -1;
  public String docStoreSegment;
  public boolean docStoreCompoundFile;
  public boolean hasDeletions;
  public String deletionsFileName;
  public int numDeleted;
  public boolean openReaderPassed;
  int numFields;
  public boolean hasProx;
  public Map diagnostics;
  public CheckIndex.Status.FieldNormStatus fieldNormStatus;
  public CheckIndex.Status.TermIndexStatus termIndexStatus;
  public CheckIndex.Status.StoredFieldStatus storedFieldStatus;
  public CheckIndex.Status.TermVectorStatus termVectorStatus;
}

/* Location:
 * Qualified Name:     org.apache.lucene.index.CheckIndex.Status.SegmentInfoStatus
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

public final class CheckIndex$Status$StoredFieldStatus
{
  public int docCount = 0;
  public long totFields = 0L;
  public Throwable error = null;
}

/* Location:
 * Qualified Name:     org.apache.lucene.index.CheckIndex.Status.StoredFieldStatus
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

public final class CheckIndex$Status$TermIndexStatus
{
  public long termCount = 0L;
  public long totFreq = 0L;
  public long totPos = 0L;
  public Throwable error = null;
}

/* Location:
 * Qualified Name:     org.apache.lucene.index.CheckIndex.Status.TermIndexStatus
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

public final class CheckIndex$Status$TermVectorStatus
{
  public int docCount = 0;
  public long totVectors = 0L;
  public Throwable error = null;
}

/* Location:
 * Qualified Name:     org.apache.lucene.index.CheckIndex.Status.TermVectorStatus
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.lucene.store.Directory;

public class CheckIndex$Status
{
  public boolean clean;
  public boolean missingSegments;
  public boolean cantOpenSegments;
  public boolean missingSegmentVersion;
  public String segmentsFileName;
  public int numSegments;
  public String segmentFormat;
  public List segmentsChecked;
  public boolean toolOutOfDate;
  public List segmentInfos;
  public Directory dir;
  SegmentInfos newSegments;
  public int totLoseDocCount;
  public int numBadSegments;
  public boolean partial;
  public Map userData;
  
  public CheckIndex$Status()
  {
    segmentsChecked = new ArrayList();
    
    segmentInfos = new ArrayList();
  }
  
  public static class SegmentInfoStatus
  {
    public String name;
    public int docCount;
    public boolean compound;
    public int numFiles;
    public double sizeMB;
    public int docStoreOffset = -1;
    public String docStoreSegment;
    public boolean docStoreCompoundFile;
    public boolean hasDeletions;
    public String deletionsFileName;
    public int numDeleted;
    public boolean openReaderPassed;
    int numFields;
    public boolean hasProx;
    public Map diagnostics;
    public CheckIndex.Status.FieldNormStatus fieldNormStatus;
    public CheckIndex.Status.TermIndexStatus termIndexStatus;
    public CheckIndex.Status.StoredFieldStatus storedFieldStatus;
    public CheckIndex.Status.TermVectorStatus termVectorStatus;
  }
  
  public static final class FieldNormStatus
  {
    public long totFields = 0L;
    public Throwable error = null;
  }
  
  public static final class TermIndexStatus
  {
    public long termCount = 0L;
    public long totFreq = 0L;
    public long totPos = 0L;
    public Throwable error = null;
  }
  
  public static final class StoredFieldStatus
  {
    public int docCount = 0;
    public long totFields = 0L;
    public Throwable error = null;
  }
  
  public static final class TermVectorStatus
  {
    public int docCount = 0;
    public long totVectors = 0L;
    public Throwable error = null;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.index.CheckIndex.Status
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.index;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.lucene.document.Document;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;

public class CheckIndex
{
  /**
   * @deprecated
   */
  public static PrintStream out = null;
  private PrintStream infoStream;
  private Directory dir;
  private static boolean assertsOn;
  
  public static class Status
  {
    public boolean clean;
    public boolean missingSegments;
    public boolean cantOpenSegments;
    public boolean missingSegmentVersion;
    public String segmentsFileName;
    public int numSegments;
    public String segmentFormat;
    public List segmentsChecked;
    public boolean toolOutOfDate;
    public List segmentInfos;
    public Directory dir;
    SegmentInfos newSegments;
    public int totLoseDocCount;
    public int numBadSegments;
    public boolean partial;
    public Map userData;
    
    public Status()
    {
      segmentsChecked = new ArrayList();
      
      segmentInfos = new ArrayList();
    }
    
    public static class SegmentInfoStatus
    {
      public String name;
      public int docCount;
      public boolean compound;
      public int numFiles;
      public double sizeMB;
      public int docStoreOffset = -1;
      public String docStoreSegment;
      public boolean docStoreCompoundFile;
      public boolean hasDeletions;
      public String deletionsFileName;
      public int numDeleted;
      public boolean openReaderPassed;
      int numFields;
      public boolean hasProx;
      public Map diagnostics;
      public CheckIndex.Status.FieldNormStatus fieldNormStatus;
      public CheckIndex.Status.TermIndexStatus termIndexStatus;
      public CheckIndex.Status.StoredFieldStatus storedFieldStatus;
      public CheckIndex.Status.TermVectorStatus termVectorStatus;
    }
    
    public static final class FieldNormStatus
    {
      public long totFields = 0L;
      public Throwable error = null;
    }
    
    public static final class TermIndexStatus
    {
      public long termCount = 0L;
      public long totFreq = 0L;
      public long totPos = 0L;
      public Throwable error = null;
    }
    
    public static final class StoredFieldStatus
    {
      public int docCount = 0;
      public long totFields = 0L;
      public Throwable error = null;
    }
    
    public static final class TermVectorStatus
    {
      public int docCount = 0;
      public long totVectors = 0L;
      public Throwable error = null;
    }
  }
  
  public CheckIndex(Directory dir)
  {
    this.dir = dir;
    infoStream = out;
  }
  
  public void setInfoStream(PrintStream out)
  {
    infoStream = out;
  }
  
  private void msg(String msg)
  {
    if (infoStream != null) {
      infoStream.println(msg);
    }
  }
  
  private static class MySegmentTermDocs
    extends SegmentTermDocs
  {
    int delCount;
    
    MySegmentTermDocs(SegmentReader p)
    {
      super();
    }
    
    public void seek(Term term)
      throws IOException
    {
      super.seek(term);
      delCount = 0;
    }
    
    protected void skippingDoc()
      throws IOException
    {
      delCount += 1;
    }
  }
  
  /**
   * @deprecated
   */
  public static boolean check(Directory dir, boolean doFix)
    throws IOException
  {
    return check(dir, doFix, null);
  }
  
  /**
   * @deprecated
   */
  public static boolean check(Directory dir, boolean doFix, List onlySegments)
    throws IOException
  {
    CheckIndex checker = new CheckIndex(dir);
    Status status = checker.checkIndex(onlySegments);
    if ((doFix) && (!clean)) {
      checker.fixIndex(status);
    }
    return clean;
  }
  
  public Status checkIndex()
    throws IOException
  {
    return checkIndex(null);
  }
  
  /* Error */
  public Status checkIndex(List onlySegments)
    throws IOException
  {
    // Byte code:
    //   0: invokestatic 17	java/text/NumberFormat:getInstance	()Ljava/text/NumberFormat;
    //   3: astore_2
    //   4: new 18	org/apache/lucene/index/SegmentInfos
    //   7: dup
    //   8: invokespecial 19	org/apache/lucene/index/SegmentInfos:<init>	()V
    //   11: astore_3
    //   12: new 20	org/apache/lucene/index/CheckIndex$Status
    //   15: dup
    //   16: invokespecial 21	org/apache/lucene/index/CheckIndex$Status:<init>	()V
    //   19: astore 4
    //   21: aload 4
    //   23: aload_0
    //   24: getfield 7	org/apache/lucene/index/CheckIndex:dir	Lorg/apache/lucene/store/Directory;
    //   27: putfield 22	org/apache/lucene/index/CheckIndex$Status:dir	Lorg/apache/lucene/store/Directory;
    //   30: aload_3
    //   31: aload_0
    //   32: getfield 7	org/apache/lucene/index/CheckIndex:dir	Lorg/apache/lucene/store/Directory;
    //   35: invokevirtual 23	org/apache/lucene/index/SegmentInfos:read	(Lorg/apache/lucene/store/Directory;)V
    //   38: goto +36 -> 74
    //   41: astore 5
    //   43: aload_0
    //   44: ldc 25
    //   46: invokespecial 26	org/apache/lucene/index/CheckIndex:msg	(Ljava/lang/String;)V
    //   49: aload 4
    //   51: iconst_1
    //   52: putfield 27	org/apache/lucene/index/CheckIndex$Status:missingSegments	Z
    //   55: aload_0
    //   56: getfield 9	org/apache/lucene/index/CheckIndex:infoStream	Ljava/io/PrintStream;
    //   59: ifnull +12 -> 71
    //   62: aload 5
    //   64: aload_0
    //   65: getfield 9	org/apache/lucene/index/CheckIndex:infoStream	Ljava/io/PrintStream;
    //   68: invokevirtual 28	java/lang/Throwable:printStackTrace	(Ljava/io/PrintStream;)V
    //   71: aload 4
    //   73: areturn
    //   74: aload_3
    //   75: invokevirtual 29	org/apache/lucene/index/SegmentInfos:size	()I
    //   78: istore 5
    //   80: aload_3
    //   81: invokevirtual 30	org/apache/lucene/index/SegmentInfos:getCurrentSegmentFileName	()Ljava/lang/String;
    //   84: astore 6
    //   86: aconst_null
    //   87: astore 7
    //   89: aload_0
    //   90: getfield 7	org/apache/lucene/index/CheckIndex:dir	Lorg/apache/lucene/store/Directory;
    //   93: aload 6
    //   95: invokevirtual 31	org/apache/lucene/store/Directory:openInput	(Ljava/lang/String;)Lorg/apache/lucene/store/IndexInput;
    //   98: astore 7
    //   100: goto +36 -> 136
    //   103: astore 8
    //   105: aload_0
    //   106: ldc 32
    //   108: invokespecial 26	org/apache/lucene/index/CheckIndex:msg	(Ljava/lang/String;)V
    //   111: aload_0
    //   112: getfield 9	org/apache/lucene/index/CheckIndex:infoStream	Ljava/io/PrintStream;
    //   115: ifnull +12 -> 127
    //   118: aload 8
    //   120: aload_0
    //   121: getfield 9	org/apache/lucene/index/CheckIndex:infoStream	Ljava/io/PrintStream;
    //   124: invokevirtual 28	java/lang/Throwable:printStackTrace	(Ljava/io/PrintStream;)V
    //   127: aload 4
    //   129: iconst_1
    //   130: putfield 33	org/apache/lucene/index/CheckIndex$Status:cantOpenSegments	Z
    //   133: aload 4
    // 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd