lucene-core-2.9.4-dev

  1987: goto -1313 -> 674
    //   1990: iconst_0
    //   1991: aload 4
    //   1993: getfield 179	org/apache/lucene/index/CheckIndex$Status:numBadSegments	I
    //   1996: if_icmpne +18 -> 2014
    //   1999: aload 4
    //   2001: iconst_1
    //   2002: putfield 15	org/apache/lucene/index/CheckIndex$Status:clean	Z
    //   2005: aload_0
    //   2006: ldc -73
    //   2008: invokespecial 26	org/apache/lucene/index/CheckIndex:msg	(Ljava/lang/String;)V
    //   2011: goto +48 -> 2059
    //   2014: aload_0
    //   2015: new 48	java/lang/StringBuffer
    //   2018: dup
    //   2019: invokespecial 49	java/lang/StringBuffer:<init>	()V
    //   2022: ldc -72
    //   2024: invokevirtual 51	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   2027: aload 4
    //   2029: getfield 179	org/apache/lucene/index/CheckIndex$Status:numBadSegments	I
    //   2032: invokevirtual 52	java/lang/StringBuffer:append	(I)Ljava/lang/StringBuffer;
    //   2035: ldc -71
    //   2037: invokevirtual 51	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   2040: aload 4
    //   2042: getfield 178	org/apache/lucene/index/CheckIndex$Status:totLoseDocCount	I
    //   2045: invokevirtual 52	java/lang/StringBuffer:append	(I)Ljava/lang/StringBuffer;
    //   2048: ldc -70
    //   2050: invokevirtual 51	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   2053: invokevirtual 54	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   2056: invokespecial 26	org/apache/lucene/index/CheckIndex:msg	(Ljava/lang/String;)V
    //   2059: aload 4
    //   2061: areturn
    // Line number table:
    //   Java source line #335	-> byte code offset #0
    //   Java source line #336	-> byte code offset #4
    //   Java source line #337	-> byte code offset #12
    //   Java source line #338	-> byte code offset #21
    //   Java source line #340	-> byte code offset #30
    //   Java source line #347	-> byte code offset #38
    //   Java source line #341	-> byte code offset #41
    //   Java source line #342	-> byte code offset #43
    //   Java source line #343	-> byte code offset #49
    //   Java source line #344	-> byte code offset #55
    //   Java source line #345	-> byte code offset #62
    //   Java source line #346	-> byte code offset #71
    //   Java source line #349	-> byte code offset #74
    //   Java source line #350	-> byte code offset #80
    //   Java source line #351	-> byte code offset #86
    //   Java source line #353	-> byte code offset #89
    //   Java source line #360	-> byte code offset #100
    //   Java source line #354	-> byte code offset #103
    //   Java source line #355	-> byte code offset #105
    //   Java source line #356	-> byte code offset #111
    //   Java source line #357	-> byte code offset #118
    //   Java source line #358	-> byte code offset #127
    //   Java source line #359	-> byte code offset #133
    //   Java source line #361	-> byte code offset #136
    //   Java source line #363	-> byte code offset #139
    //   Java source line #364	-> byte code offset #146
    //   Java source line #373	-> byte code offset #149
    //   Java source line #364	-> byte code offset #152
    //   Java source line #365	-> byte code offset #154
    //   Java source line #366	-> byte code offset #160
    //   Java source line #367	-> byte code offset #167
    //   Java source line #368	-> byte code offset #176
    //   Java source line #369	-> byte code offset #182
    //   Java source line #371	-> byte code offset #192
    //   Java source line #372	-> byte code offset #207
    //   Java source line #375	-> byte code offset #214
    //   Java source line #376	-> byte code offset #218
    //   Java source line #378	-> byte code offset #221
    //   Java source line #379	-> byte code offset #227
    //   Java source line #380	-> byte code offset #231
    //   Java source line #381	-> byte code offset #238
    //   Java source line #382	-> byte code offset #245
    //   Java source line #383	-> byte code offset #252
    //   Java source line #384	-> byte code offset #259
    //   Java source line #385	-> byte code offset #266
    //   Java source line #387	-> byte code offset #273
    //   Java source line #388	-> byte code offset #280
    //   Java source line #389	-> byte code offset #287
    //   Java source line #390	-> byte code offset #294
    //   Java source line #391	-> byte code offset #301
    //   Java source line #392	-> byte code offset #308
    //   Java source line #393	-> byte code offset #315
    //   Java source line #394	-> byte code offset #322
    //   Java source line #395	-> byte code offset #329
    //   Java source line #396	-> byte code offset #336
    //   Java source line #397	-> byte code offset #343
    //   Java source line #398	-> byte code offset #350
    //   Java source line #399	-> byte code offset #377
    //   Java source line #401	-> byte code offset #383
    //   Java source line #405	-> byte code offset #405
    //   Java source line #406	-> byte code offset #412
    //   Java source line #407	-> byte code offset #419
    //   Java source line #408	-> byte code offset #426
    //   Java source line #410	-> byte code offset #435
    //   Java source line #411	-> byte code offset #447
    //   Java source line #413	-> byte code offset #474
    //   Java source line #416	-> byte code offset #478
    //   Java source line #418	-> byte code offset #527
    //   Java source line #419	-> byte code offset #531
    //   Java source line #420	-> byte code offset #537
    //   Java source line #421	-> byte code offset #544
    //   Java source line #422	-> byte code offset #553
    //   Java source line #423	-> byte code offset #561
    //   Java source line #424	-> byte code offset #571
    //   Java source line #425	-> byte code offset #578
    //   Java source line #427	-> byte code offset #613
    //   Java source line #428	-> byte code offset #625
    //   Java source line #431	-> byte code offset #631
    //   Java source line #432	-> byte code offset #636
    //   Java source line #433	-> byte code offset #642
    //   Java source line #434	-> byte code offset #648
    //   Java source line #438	-> byte code offset #651
    //   Java source line #439	-> byte code offset #663
    //   Java source line #441	-> byte code offset #671
    //   Java source line #442	-> byte code offset #681
    //   Java source line #443	-> byte code offset #689
    //   Java source line #444	-> byte code offset #707
    //   Java source line #445	-> byte code offset #710
    //   Java source line #446	-> byte code offset #719
    //   Java source line #447	-> byte code offset #732
    //   Java source line #448	-> byte code offset #794
    //   Java source line #449	-> byte code offset #804
    //   Java source line #451	-> byte code offset #814
    //   Java source line #453	-> byte code offset #821
    //   Java source line #456	-> byte code offset #824
    //   Java source line #457	-> byte code offset #851
    //   Java source line #458	-> byte code offset #861
    //   Java source line #459	-> byte code offset #888
    //   Java source line #460	-> byte code offset #898
    //   Java source line #461	-> byte code offset #930
    //   Java source line #462	-> byte code offset #945
    //   Java source line #463	-> byte code offset #981
    //   Java source line #464	-> byte code offset #996
    //   Java source line #465	-> byte code offset #1003
    //   Java source line #466	-> byte code offset #1010
    //   Java source line #467	-> byte code offset #1020
    //   Java source line #470	-> byte code offset #1044
    //   Java source line #471	-> byte code offset #1051
    //   Java source line #472	-> byte code offset #1057
    //   Java source line #473	-> byte code offset #1081
    //   Java source line #474	-> byte code offset #1088
    //   Java source line #475	-> byte code offset #1115
    //   Java source line #476	-> byte code offset #1125
    //   Java source line #477	-> byte code offset #1152
    //   Java source line #479	-> byte code offset #1162
    //   Java source line #480	-> byte code offset #1169
    //   Java source line #481	-> byte code offset #1174
    //   Java source line #482	-> byte code offset #1180
    //   Java source line #485	-> byte code offset #1189
    //   Java source line #486	-> byte code offset #1218
    //   Java source line #487	-> byte code offset #1224
    //   Java source line #489	-> byte code offset #1231
    //   Java source line #490	-> byte code offset #1238
    //   Java source line #491	-> byte code offset #1247
    //   Java source line #493	-> byte code offset #1254
    //   Java source line #495	-> byte code offset #1260
    //   Java source line #496	-> byte code offset #1267
    //   Java source line #497	-> byte code offset #1271
    //   Java source line #498	-> byte code offset #1279
    //   Java source line #499	-> byte code offset #1295
    //   Java source line #501	-> byte code offset #1342
    //   Java source line #502	-> byte code offset #1358
    //   Java source line #504	-> byte code offset #1405
    //   Java source line #505	-> byte code offset #1421
    //   Java source line #507	-> byte code offset #1468
    //   Java source line #508	-> byte code offset #1481
    //   Java source line #510	-> byte code offset #1516
    //   Java source line #511	-> byte code offset #1524
    //   Java source line #513	-> byte code offset #1571
    //   Java source line #515	-> byte code offset #1577
    //   Java source line #516	-> byte code offset #1590
    //   Java source line #519	-> byte code offset #1634
    //   Java source line #520	-> byte code offset #1641
    //   Java source line #522	-> byte code offset #1650
    //   Java source line #523	-> byte code offset #1660
    //   Java source line #524	-> byte code offset #1694
    //   Java source line #527	-> byte code offset #1706
    //   Java source line #530	-> byte code offset #1719
    //   Java source line #533	-> byte code offset #1732
    //   Java source line #536	-> byte code offset #1746
    //   Java source line #540	-> byte code offset #1760
    //   Java source line #541	-> byte code offset #1771
    //   Java source line #542	-> byte code offset #1781
    //   Java source line #543	-> byte code offset #1792
    //   Java source line #544	-> byte code offset #1802
    //   Java source line #545	-> byte code offset #1813
    //   Java source line #546	-> byte code offset #1823
    //   Java source line #547	-> byte code offset #1834
    //   Java source line #550	-> byte code offset #1844
    //   Java source line #552	-> byte code offset #1850
    //   Java source line #566	-> byte code offset #1853
    //   Java source line #552	-> byte code offset #1856
    //   Java source line #553	-> byte code offset #1858
    //   Java source line #555	-> byte code offset #1864
    //   Java source line #556	-> byte code offset #1868
    //   Java source line #557	-> byte code offset #1897
    //   Java source line #558	-> byte code offset #1904
    //   Java source line #559	-> byte code offset #1913
    //   Java source line #560	-> byte code offset #1919
    //   Java source line #561	-> byte code offset #1931
    //   Java source line #562	-> byte code offset #1942
    //   Java source line #564	-> byte code offset #1948
    //   Java source line #565	-> byte code offset #1963
    //   Java source line #569	-> byte code offset #1970
    //   Java source line #441	-> byte code offset #1984
    //   Java source line #572	-> byte code offset #1990
    //   Java source line #573	-> byte code offset #1999
    //   Java source line #574	-> byte code offset #2005
    //   Java source line #576	-> byte code offset #2014
    //   Java source line #578	-> byte code offset #2059
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	2062	0	this	CheckIndex
    //   0	2062	1	onlySegments	List
    //   3	1751	2	nf	NumberFormat
    //   11	671	3	sis	SegmentInfos
    //   19	2041	4	result	Status
    //   41	22	5	t	Throwable
    //   78	680	5	numSegments	int
    //   84	408	6	segmentsFileName	String
    //   87	121	7	input	org.apache.lucene.store.IndexInput
    //   103	16	8	t	Throwable
    //   137	254	8	format	int
    //   152	16	9	t	Throwable
    //   216	296	9	sFormat	String
    //   184	6	10	localStatus1	Status
    //   219	413	10	skip	boolean
    //   192	6	11	localObject1	Object
    //   469	3	11	userDataString	String
    //   476	41	11	userDataString	String
    //   200	1	12	localObject2	Object
    //   559	36	12	it	Iterator
    //   672	1313	12	i	int
    //   687	1289	13	info	SegmentInfo
    //   717	1107	14	segInfoStat	CheckIndex.Status.SegmentInfoStatus
    //   819	1107	15	toLoseDocCount	int
    //   822	1142	16	reader	SegmentReader
    //   1001	33	17	diagnostics	Map
    //   1856	49	17	t	Throwable
    //   1049	35	18	docStoreOffset	int
    //   1866	16	18	comment	String
    //   1167	60	19	delFileName	String
    //   1265	294	20	numDocs	int
    //   1658	52	21	fieldNames	Collection
    //   1948	6	22	localObject3	Object
    //   1956	1	23	localObject4	Object
    // Exception table:
    //   from	to	target	type
    //   30	38	41	java/lang/Throwable
    //   89	100	103	java/lang/Throwable
    //   139	146	152	java/lang/Throwable
    //   139	149	192	finally
    //   152	189	192	finally
    //   192	197	192	finally
    //   824	1850	1856	java/lang/Throwable
    //   824	1853	1948	finally
    //   1856	1945	1948	finally
    //   1948	1953	1948	finally
  }
  
  private CheckIndex.Status.FieldNormStatus testFieldNorms(Collection fieldNames, SegmentReader reader)
  {
    CheckIndex.Status.FieldNormStatus status = new CheckIndex.Status.FieldNormStatus();
    try
    {
      if (infoStream != null) {
        infoStream.print("    test: field norms.........");
      }
      Iterator it = fieldNames.iterator();
      byte[] b = new byte[reader.maxDoc()];
      while (it.hasNext())
      {
        String fieldName = (String)it.next();
        if (reader.hasNorms(fieldName))
        {
          reader.norms(fieldName, b, 0);
          totFields += 1L;
        }
      }
      msg("OK [" + totFields + " fields]");
    }
    catch (Throwable e)
    {
      msg("ERROR [" + String.valueOf(e.getMessage()) + "]");
      error = e;
      if (infoStream != null) {
        e.printStackTrace(infoStream);
      }
    }
    return status;
  }
  
  private CheckIndex.Status.TermIndexStatus testTermIndex(SegmentInfo info, SegmentReader reader)
  {
    CheckIndex.Status.TermIndexStatus status = new CheckIndex.Status.TermIndexStatus();
    try
    {
      if (infoStream != null) {
        infoStream.print("    test: terms, freq, prox...");
      }
      TermEnum termEnum = reader.terms();
      TermPositions termPositions = reader.termPositions();
      
      MySegmentTermDocs myTermDocs = new MySegmentTermDocs(reader);
      
      int maxDoc = reader.maxDoc();
      while (termEnum.next())
      {
        termCount += 1L;
        Term term = termEnum.term();
        int docFreq = termEnum.docFreq();
        termPositions.seek(term);
        int lastDoc = -1;
        int freq0 = 0;
        totFreq += docFreq;
        while (termPositions.next())
        {
          freq0++;
          int doc = termPositions.doc();
          int freq = termPositions.freq();
          if (doc <= lastDoc) {
            throw new RuntimeException("term " + term + ": doc " + doc + " <= lastDoc " + lastDoc);
          }
          if (doc >= maxDoc) {
            throw new RuntimeException("term " + term + ": doc " + doc + " >= maxDoc " + maxDoc);
          }
          lastDoc = doc;
          if (freq <= 0) {
            throw new RuntimeException("term " + term + ": doc " + doc + ": freq " + freq + " is out of bounds");
          }
          int lastPos = -1;
          totPos += freq;
          for (int j = 0; j < freq; j++)
          {
            int pos = termPositions.nextPosition();
            if (pos < -1) {
              throw new RuntimeException("term " + term + ": doc " + doc + ": pos " + pos + " is out of bounds");
            }
            if (pos < lastPos) {
              throw new RuntimeException("term " + term + ": doc " + doc + ": pos " + pos + " < lastPos " + lastPos);
            }
          }
        }
        int delCount;
        int delCount;
        if (reader.hasDeletions())
        {
          myTermDocs.seek(term);
          while (myTermDocs.next()) {}
          delCount = delCount;
        }
        else
        {
          delCount = 0;
        }
        if (freq0 + delCount != docFreq) {
          throw new RuntimeException("term " + term + " docFreq=" + docFreq + " != num docs seen " + freq0 + " + num docs deleted " + delCount);
        }
      }
      msg("OK [" + termCount + " terms; " + totFreq + " terms/docs pairs; " + totPos + " tokens]");
    }
    catch (Throwable e)
    {
      msg("ERROR [" + String.valueOf(e.getMessage()) + "]");
      error = e;
      if (infoStream != null) {
        e.printStackTrace(infoStream);
      }
    }
    return status;
  }
  
  private CheckIndex.Status.StoredFieldStatus testStoredFields(SegmentInfo info, SegmentReader reader, NumberFormat format)
  {
    CheckIndex.Status.StoredFieldStatus status = new CheckIndex.Status.StoredFieldStatus();
    try
    {
      if (infoStream != null) {
        infoStream.print("    test: stored fields.......");
      }
      for (int j = 0; j < docCount; j++) {
        if (!reader.isDeleted(j))
        {
          docCount += 1;
          Document doc = reader.document(j);
          totFields += doc.getFields().size();
        }
      }
      if (docCount != reader.numDocs()) {
        throw new RuntimeException("docCount=" + docCount + " but saw " + docCount + " undeleted docs");
      }
      msg("OK [" + totFields + " total field count; avg " + format.format((float)totFields / docCount) + " fields per doc]");
    }
    catch (Throwable e)
    {
      msg("ERROR [" + String.valueOf(e.getMessage()) + "]");
      error = e;
      if (infoStream != null) {
        e.printStackTrace(infoStream);
      }
    }
    return status;
  }
  
  private CheckIndex.Status.TermVectorStatus testTermVectors(SegmentInfo info, SegmentReader reader, NumberFormat format)
  {
    CheckIndex.Status.TermVectorStatus status = new CheckIndex.Status.TermVectorStatus();
    try
    {
      if (infoStream != null) {
        infoStream.print("    test: term vectors........");
      }
      for (int j = 0; j < docCount; j++) {
        if (!reader.isDeleted(j))
        {
          docCount += 1;
          TermFreqVector[] tfv = reader.getTermFreqVectors(j);
          if (tfv != null) {
            totVectors += tfv.length;
          }
        }
      }
      msg("OK [" + totVectors + " total vector count; avg " + format.format((float)totVectors / docCount) + " term/freq vector fields per doc]");
    }
    catch (Throwable e)
    {
      msg("ERROR [" + String.valueOf(e.getMessage()) + "]");
      error = e;
      if (infoStream != null) {
        e.printStackTrace(infoStream);
      }
    }
    return status;
  }
  
  public void fixIndex(Status result)
    throws IOException
  {
    if (partial) {
      throw new IllegalArgumentException("can only fix an index that was fully checked (this status checked a subset of segments)");
    }
    newSegments.commit(dir);
  }
  
  private static boolean testAsserts()
  {
    assertsOn = true;
    return true;
  }
  
  private static boolean assertsOn()
  {
    assert (testAsserts());
    return assertsOn;
  }
  
  public static void main(String[] args)
    throws IOException, InterruptedException
  {
    boolean doFix = false;
    List onlySegments = new ArrayList();
    String indexPath = null;
    int i = 0;
    while (i < args.length) {
      if (args[i].equals("-fix"))
      {
        doFix = true;
        i++;
      }
      else if (args[i].equals("-segment"))
      {
        if (i == args.length - 1)
        {
          System.out.println("ERROR: missing name for -segment option");
          System.exit(1);
        }
        onlySegments.add(args[(i + 1)]);
        i += 2;
      }
      else
      {
        if (indexPath != null)
        {
          System.out.println("ERROR: unexpected extra argument '" + args[i] + "'");
          System.exit(1);
        }
        indexPath = args[i];
        i++;
      }
    }
    if (indexPath == null)
    {
      System.out.println("\nERROR: index path not specified");
      System.out.println("\nUsage: java org.apache.lucene.index.CheckIndex pathToIndex [-fix] [-segment X] [-segment Y]\n\n  -fix: actually write a new segments_N file, removing any problematic segments\n  -segment X: only check the specified segments.  This can be specified multiple\n              times, to check more than one segment, eg '-segment _2 -segment _a'.\n              You can't use this with the -fix option\n\n**WARNING**: -fix should only be used on an emergency basis as it will cause\ndocuments (perhaps many) to be permanently removed from the index.  Always make\na backup copy of your index before running this!  Do not run this tool on an index\nthat is actively being written to.  You have been warned!\n\nRun without -fix, this tool will open the index, report version information\nand report any exceptions it hits and what action it would take if -fix were\nspecified.  With -fix, this tool will remove any segments that have issues and\nwrite a new segments_N file.  This means all documents contained in the affected\nsegments will be removed.\n\nThis tool exits with exit code 1 if the index cannot be opened or has any\ncorruption, else 0.\n");
      
      System.exit(1);
    }
    if (!assertsOn()) {
      System.out.println("\nNOTE: testing will be more thorough if you run java with '-ea:org.apache.lucene...', so assertions are enabled");
    }
    if (onlySegments.size() == 0)
    {
      onlySegments = null;
    }
    else if (doFix)
    {
      System.out.println("ERROR: cannot specify both -fix and -segment");
      System.exit(1);
    }
    System.out.println("\nOpening index @ " + indexPath + "\n");
    Directory dir = null;
    try
    {
      dir = FSDirectory.open(new File(indexPath));
    }
    catch (Throwable t)
    {
      System.out.println("ERROR: could not open directory \"" + indexPath + "\"; exiting");
      t.printStackTrace(System.out);
      System.exit(1);
    }
    CheckIndex checker = new CheckIndex(dir);
    checker.setInfoStream(System.out);
    
    Status result = checker.checkIndex(onlySegments);
    if (missingSegments) {
      System.exit(1);
    }
    if (!clean) {
      if (!doFix)
      {
        System.out.println("WARNING: would write new segments file, and " + totLoseDocCount + " documents would be lost, if -fix were specified\n");
      }
      else
      {
        System.out.println("WARNING: " + totLoseDocCount + " documents will be lost\n");
        System.out.println("NOTE: will write new segments file in 5 seconds; this will remove " + totLoseDocCount + " docs from the index. THIS IS YOUR LAST CHANCE TO CTRL+C!");
        for (int s = 0; s < 5; s++)
        {
          Thread.sleep(1000L);
          System.out.println("  " + (5 - s) + "...");
        }
        System.out.println("Writing...");
        checker.fixIndex(result);
        System.out.println("OK");
        System.out.println("Wrote new segments file \"" + newSegments.getCurrentSegmentFileName() + "\"");
      }
    }
    System.out.println("");
    int exitCode;
    int exitCode;
    if ((result != null) && (clean == true)) {
      exitCode = 0;
    } else {
      exitCode = 1;
    }
    System.exit(exitCode);
  }
}

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

class CompoundFileReader$1 {}

/* Location:
 * Qualified Name:     org.apache.lucene.index.CompoundFileReader.1
 * 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.BufferedIndexInput;
import org.apache.lucene.store.IndexInput;

final class CompoundFileReader$CSIndexInput
  extends BufferedIndexInput
{
  IndexInput base;
  long fileOffset;
  long length;
  
  CompoundFileReader$CSIndexInput(IndexInput base, long fileOffset, long length)
  {
    this(base, fileOffset, length, 1024);
  }
  
  CompoundFileReader$CSIndexInput(IndexInput base, long fileOffset, long length, int readBufferSize)
  {
    super(readBufferSize);
    this.base = ((IndexInput)base.clone());
    this.fileOffset = fileOffset;
    this.length = length;
  }
  
  public Object clone()
  {
    CSIndexInput clone = (CSIndexInput)super.clone();
    base = ((IndexInput)base.clone());
    fileOffset = fileOffset;
    length = length;
    return clone;
  }
  
  protected void readInternal(byte[] b, int offset, int len)
    throws IOException
  {
    long start = getFilePointer();
    if (start + len > length) {
      throw new IOException("read past EOF");
    }
    base.seek(fileOffset + start);
    base.readBytes(b, offset, len, false);
  }
  
  protected void seekInternal(long pos) {}
  
  public void close()
    throws IOException
  {
    base.close();
  }
  
  public long length()
  {
    return length;
  }
}

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

final class CompoundFileReader$FileEntry
{
  long offset;
  long length;
  
  private CompoundFileReader$FileEntry() {}
  
  CompoundFileReader$FileEntry(CompoundFileReader.1 x0)
  {
    this();
  }
}

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

import java.io.IOException;
import java.util.HashMap;
import java.util.Set;
import org.apache.lucene.store.BufferedIndexInput;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
import org.apache.lucene.store.Lock;

class CompoundFileReader
  extends Directory
{
  private int readBufferSize;
  private Directory directory;
  private String fileName;
  private IndexInput stream;
  
  private static final class FileEntry
  {
    long offset;
    long length;
    
    private FileEntry() {}
    
    FileEntry(CompoundFileReader.1 x0)
    {
      this();
    }
  }
  
  private HashMap entries = new HashMap();
  
  public CompoundFileReader(Directory dir, String name)
    throws IOException
  {
    this(dir, name, 1024);
  }
  
  public CompoundFileReader(Directory dir, String name, int readBufferSize)
    throws IOException
  {
    directory = dir;
    fileName = name;
    this.readBufferSize = readBufferSize;
    
    boolean success = false;
    try
    {
      stream = dir.openInput(name, readBufferSize);
      
      int count = stream.readVInt();
      FileEntry entry = null;
      for (int i = 0; i < count; i++)
      {
        long offset = stream.readLong();
        String id = stream.readString();
        if (entry != null) {
          length = (offset - offset);
        }
        entry = new FileEntry(null);
        offset = offset;
        entries.put(id, entry);
      }
      if (entry != null) {
        length = (stream.length() - offset);
      }
      success = true;
    }
    finally
    {
      if ((!success) && (stream != null)) {
        try
        {
          stream.close();
        }
        catch (IOException e) {}
      }
    }
  }
  
  public Directory getDirectory()
  {
    return directory;
  }
  
  public String getName()
  {
    return fileName;
  }
  
  public synchronized void close()
    throws IOException
  {
    if (stream == null) {
      throw new IOException("Already closed");
    }
    entries.clear();
    stream.close();
    stream = null;
  }
  
  public synchronized IndexInput openInput(String id)
    throws IOException
  {
    return openInput(id, readBufferSize);
  }
  
  public synchronized IndexInput openInput(String id, int readBufferSize)
    throws IOException
  {
    if (stream == null) {
      throw new IOException("Stream closed");
    }
    FileEntry entry = (FileEntry)entries.get(id);
    if (entry == null) {
      throw new IOException("No sub-file with id " + id + " found");
    }
    return new CSIndexInput(stream, offset, length, readBufferSize);
  }
  
  public String[] list()
  {
    String[] res = new String[entries.size()];
    return (String[])entries.keySet().toArray(res);
  }
  
  public boolean fileExists(String name)
  {
    return entries.containsKey(name);
  }
  
  public long fileModified(String name)
    throws IOException
  {
    return directory.fileModified(fileName);
  }
  
  public void touchFile(String name)
    throws IOException
  {
    directory.touchFile(fileName);
  }
  
  public void deleteFile(String name)
  {
    throw new UnsupportedOperationException();
  }
  
  public void renameFile(String from, String to)
  {
    throw new UnsupportedOperationException();
  }
  
  public long fileLength(String name)
    throws IOException
  {
    FileEntry e = (FileEntry)entries.get(name);
    if (e == null) {
      throw new IOException("File " + name + " does not exist");
    }
    return length;
  }
  
  public IndexOutput createOutput(String name)
  {
    throw new UnsupportedOperationException();
  }
  
  public Lock makeLock(String name)
  {
    throw new UnsupportedOperationException();
  }
  
  static final class CSIndexInput
    extends BufferedIndexInput
  {
    IndexInput base;
    long fileOffset;
    long length;
    
    CSIndexInput(IndexInput base, long fileOffset, long length)
    {
      this(base, fileOffset, length, 1024);
    }
    
    CSIndexInput(IndexInput base, long fileOffset, long length, int readBufferSize)
    {
      super();
      this.base = ((IndexInput)base.clone());
      this.fileOffset = fileOffset;
      this.length = length;
    }
    
    public Object clone()
    {
      CSIndexInput clone = (CSIndexInput)super.clone();
      base = ((IndexInput)base.clone());
      fileOffset = fileOffset;
      length = length;
      return clone;
    }
    
    protected void readInternal(byte[] b, int offset, int len)
      throws IOException
    {
      long start = getFilePointer();
      if (start + len > length) {
        throw new IOException("read past EOF");
      }
      base.seek(fileOffset + start);
      base.readBytes(b, offset, len, false);
    }
    
    protected void seekInternal(long pos) {}
    
    public void close()
      throws IOException
    {
      base.close();
    }
    
    public long length()
    {
      return length;
    }
  }
}

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

class CompoundFileWriter$1 {}

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

final class CompoundFileWriter$FileEntry
{
  String file;
  long directoryOffset;
  long dataOffset;
  
  private CompoundFileWriter$FileEntry() {}
  
  CompoundFileWriter$FileEntry(CompoundFileWriter.1 x0)
  {
    this();
  }
}

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

import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;

final class CompoundFileWriter
{
  private Directory directory;
  private String fileName;
  private HashSet ids;
  private LinkedList entries;
  
  private static final class FileEntry
  {
    String file;
    long directoryOffset;
    long dataOffset;
    
    private FileEntry() {}
    
    FileEntry(CompoundFileWriter.1 x0)
    {
      this();
    }
  }
  
  private boolean merged = false;
  private SegmentMerger.CheckAbort checkAbort;
  
  public CompoundFileWriter(Directory dir, String name)
  {
    this(dir, name, null);
  }
  
  CompoundFileWriter(Directory dir, String name, SegmentMerger.CheckAbort checkAbort)
  {
    if (dir == null) {
      throw new NullPointerException("directory cannot be null");
    }
    if (name == null) {
      throw new NullPointerException("name cannot be null");
    }
    this.checkAbort = checkAbort;
    directory = dir;
    fileName = name;
    ids = new HashSet();
    entries = new LinkedList();
  }
  
  public Directory getDirectory()
  {
    return directory;
  }
  
  public String getName()
  {
    return fileName;
  }
  
  public void addFile(String file)
  {
    if (merged) {
      throw new IllegalStateException("Can't add extensions after merge has been called");
    }
    if (file == null) {
      throw new NullPointerException("file cannot be null");
    }
    if (!ids.add(file)) {
      throw new IllegalArgumentException("File " + file + " already added");
    }
    FileEntry entry = new FileEntry(null);
    file = file;
    entries.add(entry);
  }
  
  public void close()
    throws IOException
  {
    if (merged) {
      throw new IllegalStateException("Merge already performed");
    }
    if (entries.isEmpty()) {
      throw new IllegalStateException("No entries to merge have been defined");
    }
    merged = true;
    
    IndexOutput os = null;
    try
    {
      os = directory.createOutput(fileName);
      
      os.writeVInt(entries.size());
      
      Iterator it = entries.iterator();
      long totalSize = 0L;
      while (it.hasNext())
      {
        FileEntry fe = (FileEntry)it.next();
        directoryOffset = os.getFilePointer();
        os.writeLong(0L);
        os.writeString(file);
        totalSize += directory.fileLength(file);
      }
      long finalLength = totalSize + os.getFilePointer();
      os.setLength(finalLength);
      
      byte[] buffer = new byte['?'];
      it = entries.iterator();
      while (it.hasNext())
      {
        FileEntry fe = (FileEntry)it.next();
        dataOffset = os.getFilePointer();
        copyFile(fe, os, buffer);
      }
      it = entries.iterator();
      while (it.hasNext())
      {
        FileEntry fe = (FileEntry)it.next();
        os.seek(directoryOffset);
        os.writeLong(dataOffset);
      }
      assert (finalLength == os.length());
      
      IndexOutput tmp = os;
      os = null;
      tmp.close();
    }
    finally
    {
      if (os != null) {
        try
        {
          os.close();
        }
        catch (IOException e) {}
      }
    }
  }
  
  private void copyFile(FileEntry source, IndexOutput os, byte[] buffer)
    throws IOException
  {
    IndexInput is = null;
    try
    {
      long startPtr = os.getFilePointer();
      
      is = directory.openInput(file);
      long length = is.length();
      long remainder = length;
      int chunk = buffer.length;
      while (remainder > 0L)
      {
        int len = (int)Math.min(chunk, remainder);
        is.readBytes(buffer, 0, len, false);
        os.writeBytes(buffer, len);
        remainder -= len;
        if (checkAbort != null) {
          checkAbort.work(80.0D);
        }
      }
      if (remainder != 0L) {
        throw new IOException("Non-zero remainder length after copying: " + remainder + " (id: " + file + ", length: " + length + ", buffer size: " + chunk + ")");
      }
      long endPtr = os.getFilePointer();
      long diff = endPtr - startPtr;
      if (diff != length) {
        throw new IOException("Difference in the output file offsets " + diff + " does not match the original file length " + length);
      }
    }
    finally
    {
      if (is != null) {
        is.close();
      }
    }
  }
}

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

import java.io.IOException;
import java.util.List;

public class ConcurrentMergeScheduler$MergeThread
  extends Thread
{
  IndexWriter writer;
  MergePolicy.OneMerge startMerge;
  MergePolicy.OneMerge runningMerge;
  private final ConcurrentMergeScheduler this$0;
  
  public ConcurrentMergeScheduler$MergeThread(ConcurrentMergeScheduler paramConcurrentMergeScheduler, IndexWriter writer, MergePolicy.OneMerge startMerge)
    throws IOException
  {
    this.writer = writer;
    this.startMerge = startMerge;
  }
  
  public synchronized void setRunningMerge(MergePolicy.OneMerge merge)
  {
    runningMerge = merge;
  }
  
  public synchronized MergePolicy.OneMerge getRunningMerge()
  {
    return runningMerge;
  }
  
  public void setThreadPriority(int pri)
  {
    try
    {
      setPriority(pri);
    }
    catch (NullPointerException npe) {}catch (SecurityException se) {}
  }
  
  public void run()
  {
    MergePolicy.OneMerge merge = startMerge;
    try
    {
      if (ConcurrentMergeScheduler.access$000(this$0)) {
        ConcurrentMergeScheduler.access$100(this$0, "  merge thread: start");
      }
      for (;;)
      {
        setRunningMerge(merge);
        this$0.doMerge(merge);
        
        merge = writer.getNextMerge();
        if (merge == null) {
          break;
        }
        writer.mergeInit(merge);
        if (ConcurrentMergeScheduler.access$000(this$0)) {
          ConcurrentMergeScheduler.access$100(this$0, "  merge thread: do another merge " + merge.segString(this$0.dir));
        }
      }
      if (ConcurrentMergeScheduler.access$000(this$0)) {
        ConcurrentMergeScheduler.access$100(this$0, "  merge thread: done");
      }
    }
    catch (Throwable exc)
    {
      if ((!(exc instanceof MergePolicy.MergeAbortedException)) && 
        (!ConcurrentMergeScheduler.access$200(this$0)))
      {
        ConcurrentMergeScheduler.anyExceptions = true;
        this$0.handleMergeException(exc);
      }
    }
    finally
    {
      synchronized (this$0)
      {
        this$0.notifyAll();
        boolean removed = this$0.mergeThreads.remove(this);
        if ((!$assertionsDisabled) && (!removed)) {
          throw new AssertionError();
        }
      }
    }
  }
  
  public String toString()
  {
    MergePolicy.OneMerge merge = getRunningMerge();
    if (merge == null) {
      merge = startMerge;
    }
    return "merge thread: " + merge.segString(this$0.dir);
  }
}

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

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

public class ConcurrentMergeScheduler
  extends MergeScheduler
{
  private int mergeThreadPriority = -1;
  protected List mergeThreads = new ArrayList();
  private int maxThreadCount = 1;
  protected Directory dir;
  private boolean closed;
  protected IndexWriter writer;
  protected int mergeThreadCount;
  
  public ConcurrentMergeScheduler()
  {
    if (allInstances != null) {
      addMyself();
    }
  }
  
  public void setMaxThreadCount(int count)
  {
    if (count < 1) {
      throw new IllegalArgumentException("count should be at least 1");
    }
    maxThreadCount = count;
  }
  
  public int getMaxThreadCount()
  {
    return maxThreadCount;
  }
  
  public synchronized int getMergeThreadPriority()
  {
    initMergeThreadPriority();
    return mergeThreadPriority;
  }
  
  public synchronized void setMergeThreadPriority(int pri)
  {
    if ((pri > 10) || (pri < 1)) {
      throw new IllegalArg
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