Package org.apache.lucene.store

Examples of org.apache.lucene.store.IndexInput


   
    boolean isusechecksumfile=false;
    long checksum=-1;
    if(directory.fileExists(checksumfile))
    {
        IndexInput chkinput=directory.openInput(checksumfile);
        checksum=chkinput.readLong();
        chkinput.close();
        isusechecksumfile=true;
    }else{
  System.out.println("can`t found checksum file "+checksumfile);
    }
   
View Full Code Here


          // gens.  This way, if either approach is hitting
          // a stale cache (NFS) we have a better chance of
          // getting the right generation.
          long genB = -1;
          for(int i=0;i<defaultGenFileRetryCount;i++) {
            IndexInput genInput = null;
           
            if(!directory.fileExists(IndexFileNames.SEGMENTS_GEN))
            {
               if (infoStream != null) {
                     message("segments.gen open: FileNotFoundException "+IndexFileNames.SEGMENTS_GEN );
                   }
                   break;
            }
            try {
              genInput = directory.openInput(IndexFileNames.SEGMENTS_GEN);
            } catch (FileNotFoundException e) {
              if (infoStream != null) {
                message("segments.gen open: FileNotFoundException " + e);
              }
              break;
            } catch (IOException e) {
              if (infoStream != null) {
                message("segments.gen open: IOException " + e);
              }
            }
 
            if (genInput != null) {
              try {
                int version = genInput.readInt();
                if (version == FORMAT_LOCKLESS) {
                  long gen0 = genInput.readLong();
                  long gen1 = genInput.readLong();
                  if (infoStream != null) {
                    message("fallback check: " + gen0 + "; " + gen1);
                  }
                  if (gen0 == gen1) {
                    // The file is consistent.
                    genB = gen0;
                    break;
                  }
                }
              } catch (FileNotFoundException err2) {
                  if (infoStream != null) {
                    message("segments.gen open: FileNotFoundException " + err2);
                  }
                  break;
               
              }
              catch (IOException err2) {
                // will retry
              } finally {
                genInput.close();
              }
            }
            try {
              Thread.sleep(defaultGenFileRetryPauseMsec);
            } catch (InterruptedException ie) {
View Full Code Here

    }
    if(!d.fileExists("txid"))
    {
      return 0l;
    }
    IndexInput in=d.openInput("txid");
   
    long rtn=0l;
    try{
      rtn=Long.parseLong(in.readString());
    }catch (Throwable e) {
      rtn=0;
    }
    in.close();
    return rtn;
  }
View Full Code Here

    }
    if(!d.fileExists("txid"))
    {
      return 0l;
    }
    IndexInput in=d.openInput("txid");
   
    long rtn=0l;
    try{
      rtn=Long.parseLong(in.readString());
    }catch (Throwable e) {
      rtn=0;
    }
    in.close();
    return rtn;
  }
View Full Code Here

          d = cfsDir;
        }
       
        // singleNormFile means multiple norms share this file
        boolean singleNormFile = IndexFileNames.matchesExtension(fileName, IndexFileNames.NORMS_EXTENSION);
        IndexInput normInput = null;
        long normSeek;

        if (singleNormFile) {
          normSeek = nextNormSeek;
          if (singleNormStream == null) {
            singleNormStream = d.openInput(fileName, readBufferSize);
            singleNormRef = new AtomicInteger(1);
          } else {
            singleNormRef.incrementAndGet();
          }
          // All norms in the .nrm file can share a single IndexInput since
          // they are only used in a synchronized context.
          // If this were to change in the future, a clone could be done here.
          normInput = singleNormStream;
        } else {
          normInput = d.openInput(fileName);
          // if the segment was created in 3.2 or after, we wrote the header for sure,
          // and don't need to do the sketchy file size check. otherwise, we check
          // if the size is exactly equal to maxDoc to detect a headerless file.
          // NOTE: remove this check in Lucene 5.0!
          String version = si.getVersion();
          final boolean isUnversioned =
            (version == null || StringHelper.getVersionComparator().compare(version, "3.2") < 0)
            && normInput.length() == maxDoc();
          if (isUnversioned) {
            normSeek = 0;
          } else {
            normSeek = SegmentNorms.NORMS_HEADER.length;
          }
View Full Code Here

  }


  public void seekEnum(SegmentTermEnum enumerator, int indexOffset) throws IOException {
    IndexInput tii= (IndexInput)this.tiiInput.clone();
    IndexInput qtii=(IndexInput)this.quickTii.clone();
    TiiInfo ti=this.getTiiInfo(indexOffset, tii, qtii);


    // read the term
    Term term = ti.tm;
View Full Code Here

   * @param term
   *          the term to locate.
   * @throws IOException
   */
  public int getIndexOffset(Term term, BytesRef termBytesRef) throws IOException {
    IndexInput tii= (IndexInput)this.tiiInput.clone();
    IndexInput qtii=(IndexInput)this.quickTii.clone();
    int lo = 0;
    int hi = termInfoArr.length-1;
    while (hi >= lo) {
      int mid = (lo + hi) >>> 1;
      int delta = compareTo(term, termBytesRef, mid,tii, qtii,new BytesRef());
View Full Code Here

            CompoundFileWriter csw = new CompoundFileWriter(dir, name + ".cfs");
            csw.addFile(name);
            csw.close();

            CompoundFileReader csr = new CompoundFileReader(dir, name + ".cfs");
            IndexInput expected = dir.openInput(name);
            IndexInput actual = csr.openInput(name);
            assertSameStreams(name, expected, actual);
            assertSameSeekBehavior(name, expected, actual);
            expected.close();
            actual.close();
            csr.close();
        }
    }
View Full Code Here

        csw.addFile("d1");
        csw.addFile("d2");
        csw.close();

        CompoundFileReader csr = new CompoundFileReader(dir, "d.csf");
        IndexInput expected = dir.openInput("d1");
        IndexInput actual = csr.openInput("d1");
        assertSameStreams("d1", expected, actual);
        assertSameSeekBehavior("d1", expected, actual);
        expected.close();
        actual.close();

        expected = dir.openInput("d2");
        actual = csr.openInput("d2");
        assertSameStreams("d2", expected, actual);
        assertSameSeekBehavior("d2", expected, actual);
        expected.close();
        actual.close();
        csr.close();
    }
View Full Code Here

        }
        csw.close();

        CompoundFileReader csr = new CompoundFileReader(dir, "test.cfs");
        for (int i=0; i<data.length; i++) {
            IndexInput check = dir.openInput(segment + data[i]);
            IndexInput test = csr.openInput(segment + data[i]);
            assertSameStreams(data[i], check, test);
            assertSameSeekBehavior(data[i], check, test);
            test.close();
            check.close();
        }
        csr.close();
    }
View Full Code Here

TOP

Related Classes of org.apache.lucene.store.IndexInput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.