org.apache.lucene.index.CorruptIndexException Java Examples
The following examples show how to use
org.apache.lucene.index.CorruptIndexException.
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: Store.java From crate with Apache License 2.0 | 6 votes |
@Override public void verify() throws IOException { String footerDigest = null; if (metadata.checksum().equals(actualChecksum) && writtenBytes == metadata.length()) { ByteArrayIndexInput indexInput = new ByteArrayIndexInput("checksum", this.footerChecksum); footerDigest = digestToString(indexInput.readLong()); if (metadata.checksum().equals(footerDigest)) { return; } } throw new CorruptIndexException( "verification failed (hardware problem?) : " + "expected=" + metadata.checksum() + " actual=" + actualChecksum + " footer=" + footerDigest + " writtenLength=" + writtenBytes + " expectedLength=" + metadata.length() + " (resource=" + metadata.toString() + ")", "VerifyingIndexOutput(" + metadata.name() + ")" ); }
Example #2
Source File: ChecksumBlobStoreFormat.java From Elasticsearch with Apache License 2.0 | 6 votes |
/** * Reads blob with specified name without resolving the blobName using using {@link #blobName} method. * * @param blobContainer blob container * @param blobName blob name */ public T readBlob(BlobContainer blobContainer, String blobName) throws IOException { try (InputStream inputStream = blobContainer.readBlob(blobName)) { byte[] bytes = ByteStreams.toByteArray(inputStream); final String resourceDesc = "ChecksumBlobStoreFormat.readBlob(blob=\"" + blobName + "\")"; try (ByteArrayIndexInput indexInput = new ByteArrayIndexInput(resourceDesc, bytes)) { CodecUtil.checksumEntireFile(indexInput); CodecUtil.checkHeader(indexInput, codec, VERSION, VERSION); long filePointer = indexInput.getFilePointer(); long contentSize = indexInput.length() - CodecUtil.footerLength() - filePointer; BytesReference bytesReference = new BytesArray(bytes, (int) filePointer, (int) contentSize); return read(bytesReference); } catch (CorruptIndexException | IndexFormatTooOldException | IndexFormatTooNewException ex) { // we trick this into a dedicated exception with the original stacktrace throw new CorruptStateException(ex); } } }
Example #3
Source File: LuceneIndexSearch.java From sdudoc with MIT License | 6 votes |
/** * 查询方法 * @throws IOException * @throws CorruptIndexException * @throws ParseException */ public List Search(String searchString,LuceneResultCollector luceneResultCollector) throws CorruptIndexException, IOException, ParseException{ //方法一: System.out.println(this.indexSettings.getAnalyzer().getClass()+"----分词选择"); QueryParser q = new QueryParser(Version.LUCENE_44, "summary", this.indexSettings.getAnalyzer()); String search = new String(searchString.getBytes("ISO-8859-1"),"UTF-8"); System.out.println(search+"----------搜索的词语dd"); Query query = q.parse(search); //方法二: /* Term t = new Term("title", searchString); TermQuery query = new TermQuery(t); */ System.out.println(query.toString()+"--------query.tostring"); ScoreDoc[] docs = this.indexSearcher.search(query,100).scoreDocs; System.out.println("一共有:"+docs.length+"条记录"); List result = luceneResultCollector.collect(docs, this.indexSearcher); return result; }
Example #4
Source File: SimpleTextPointsReader.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public void checkIntegrity() throws IOException { BytesRefBuilder scratch = new BytesRefBuilder(); IndexInput clone = dataIn.clone(); clone.seek(0); // checksum is fixed-width encoded with 20 bytes, plus 1 byte for newline (the space is included in SimpleTextUtil.CHECKSUM): long footerStartPos = dataIn.length() - (SimpleTextUtil.CHECKSUM.length + 21); ChecksumIndexInput input = new BufferedChecksumIndexInput(clone); while (true) { SimpleTextUtil.readLine(input, scratch); if (input.getFilePointer() >= footerStartPos) { // Make sure we landed at precisely the right location: if (input.getFilePointer() != footerStartPos) { throw new CorruptIndexException("SimpleText failure: footer does not start at expected position current=" + input.getFilePointer() + " vs expected=" + footerStartPos, input); } SimpleTextUtil.checkFooter(input); break; } } }
Example #5
Source File: SimpleTextBKDReader.java From lucene-solr with Apache License 2.0 | 6 votes |
private void visitCompressedDocValues(int[] commonPrefixLengths, byte[] scratchPackedValue, IndexInput in, int[] docIDs, int count, IntersectVisitor visitor, int compressedDim) throws IOException { // the byte at `compressedByteOffset` is compressed using run-length compression, // other suffix bytes are stored verbatim final int compressedByteOffset = compressedDim * bytesPerDim + commonPrefixLengths[compressedDim]; commonPrefixLengths[compressedDim]++; int i; for (i = 0; i < count; ) { scratchPackedValue[compressedByteOffset] = in.readByte(); final int runLen = Byte.toUnsignedInt(in.readByte()); for (int j = 0; j < runLen; ++j) { for(int dim = 0; dim< numDims; dim++) { int prefix = commonPrefixLengths[dim]; in.readBytes(scratchPackedValue, dim*bytesPerDim + prefix, bytesPerDim - prefix); } visitor.visit(docIDs[i+j], scratchPackedValue); } i += runLen; } if (i != count) { throw new CorruptIndexException("Sub blocks do not add up to the expected count: " + count + " != " + i, in); } }
Example #6
Source File: BlockHeader.java From lucene-solr with Apache License 2.0 | 6 votes |
public BlockHeader read(DataInput input, BlockHeader reuse) throws IOException { int linesCount = input.readVInt(); if (linesCount <= 0 || linesCount > UniformSplitTermsWriter.MAX_NUM_BLOCK_LINES) { throw new CorruptIndexException("Illegal number of lines in block: " + linesCount, input); } long baseDocsFP = input.readVLong(); long basePositionsFP = input.readVLong(); long basePayloadsFP = input.readVLong(); int termStatesBaseOffset = input.readVInt(); if (termStatesBaseOffset < 0) { throw new CorruptIndexException("Illegal termStatesBaseOffset= " + termStatesBaseOffset, input); } int middleTermOffset = input.readVInt(); if (middleTermOffset < 0) { throw new CorruptIndexException("Illegal middleTermOffset= " + middleTermOffset, input); } BlockHeader blockHeader = reuse == null ? new BlockHeader() : reuse; return blockHeader.reset(linesCount, baseDocsFP, basePositionsFP, basePayloadsFP, termStatesBaseOffset, middleTermOffset); }
Example #7
Source File: LuceneContent.java From Lottery with GNU General Public License v2.0 | 6 votes |
public static List<Integer> getResultList(Searcher searcher, TopDocs docs, int first, int max) throws CorruptIndexException, IOException { List<Integer> list = new ArrayList<Integer>(max); ScoreDoc[] hits = docs.scoreDocs; if (first < 0) { first = 0; } if (max < 0) { max = 0; } int last = first + max; int len = hits.length; if (last > len) { last = len; } for (int i = first; i < last; i++) { Document d = searcher.doc(hits[i].doc); list.add(Integer.valueOf(d.getField(ID).stringValue())); } return list; }
Example #8
Source File: Lucene50FieldInfosFormat.java From lucene-solr with Apache License 2.0 | 6 votes |
private static DocValuesType getDocValuesType(IndexInput input, byte b) throws IOException { switch(b) { case 0: return DocValuesType.NONE; case 1: return DocValuesType.NUMERIC; case 2: return DocValuesType.BINARY; case 3: return DocValuesType.SORTED; case 4: return DocValuesType.SORTED_SET; case 5: return DocValuesType.SORTED_NUMERIC; default: throw new CorruptIndexException("invalid docvalues byte: " + b, input); } }
Example #9
Source File: ChecksumBlobStoreFormat.java From crate with Apache License 2.0 | 6 votes |
/** * Reads blob with specified name without resolving the blobName using using {@link #blobName} method. * * @param blobContainer blob container * @param blobName blob name */ public T readBlob(BlobContainer blobContainer, String blobName) throws IOException { final BytesReference bytes = Streams.readFully(blobContainer.readBlob(blobName)); final String resourceDesc = "ChecksumBlobStoreFormat.readBlob(blob=\"" + blobName + "\")"; try (ByteArrayIndexInput indexInput = new ByteArrayIndexInput(resourceDesc, BytesReference.toBytes(bytes))) { CodecUtil.checksumEntireFile(indexInput); CodecUtil.checkHeader(indexInput, codec, VERSION, VERSION); long filePointer = indexInput.getFilePointer(); long contentSize = indexInput.length() - CodecUtil.footerLength() - filePointer; try (XContentParser parser = XContentHelper.createParser(namedXContentRegistry, LoggingDeprecationHandler.INSTANCE, bytes.slice((int) filePointer, (int) contentSize), XContentType.SMILE)) { return reader.apply(parser); } } catch (CorruptIndexException | IndexFormatTooOldException | IndexFormatTooNewException ex) { // we trick this into a dedicated exception with the original stacktrace throw new CorruptStateException(ex); } }
Example #10
Source File: Lucene60FieldInfosFormat.java From lucene-solr with Apache License 2.0 | 6 votes |
private static DocValuesType getDocValuesType(IndexInput input, byte b) throws IOException { switch(b) { case 0: return DocValuesType.NONE; case 1: return DocValuesType.NUMERIC; case 2: return DocValuesType.BINARY; case 3: return DocValuesType.SORTED; case 4: return DocValuesType.SORTED_SET; case 5: return DocValuesType.SORTED_NUMERIC; default: throw new CorruptIndexException("invalid docvalues byte: " + b, input); } }
Example #11
Source File: BKDReader.java From lucene-solr with Apache License 2.0 | 6 votes |
private void visitSparseRawDocValues(int[] commonPrefixLengths, byte[] scratchPackedValue, IndexInput in, BKDReaderDocIDSetIterator scratchIterator, int count, IntersectVisitor visitor) throws IOException { int i; for (i = 0; i < count;) { int length = in.readVInt(); for(int dim = 0; dim < numDataDims; dim++) { int prefix = commonPrefixLengths[dim]; in.readBytes(scratchPackedValue, dim*bytesPerDim + prefix, bytesPerDim - prefix); } scratchIterator.reset(i, length); visitor.visit(scratchIterator, scratchPackedValue); i += length; } if (i != count) { throw new CorruptIndexException("Sub blocks do not add up to the expected count: " + count + " != " + i, in); } }
Example #12
Source File: TestCodecUtil.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testCheckFooterValidPastFooter() throws Exception { ByteBuffersDataOutput out = new ByteBuffersDataOutput(); IndexOutput output = new ByteBuffersIndexOutput(out, "temp", "temp"); CodecUtil.writeHeader(output, "FooBar", 5); output.writeString("this is the data"); CodecUtil.writeFooter(output); output.close(); ChecksumIndexInput input = new BufferedChecksumIndexInput(new ByteBuffersIndexInput(out.toDataInput(), "temp")); CodecUtil.checkHeader(input, "FooBar", 5, 5); assertEquals("this is the data", input.readString()); // bogusly read a byte too far (can happen) input.readByte(); Exception mine = new RuntimeException("fake exception"); CorruptIndexException expected = expectThrows(CorruptIndexException.class, () -> { CodecUtil.checkFooter(input, mine); }); assertTrue(expected.getMessage().contains("checksum status indeterminate")); Throwable suppressed[] = expected.getSuppressed(); assertEquals(1, suppressed.length); assertEquals("fake exception", suppressed[0].getMessage()); input.close(); }
Example #13
Source File: TestCodecUtil.java From lucene-solr with Apache License 2.0 | 6 votes |
public void testCheckFooterInvalid() throws Exception { ByteBuffersDataOutput out = new ByteBuffersDataOutput(); IndexOutput output = new ByteBuffersIndexOutput(out, "temp", "temp"); CodecUtil.writeHeader(output, "FooBar", 5); output.writeString("this is the data"); output.writeInt(CodecUtil.FOOTER_MAGIC); output.writeInt(0); output.writeLong(1234567); // write a bogus checksum output.close(); ChecksumIndexInput input = new BufferedChecksumIndexInput(new ByteBuffersIndexInput(out.toDataInput(), "temp")); CodecUtil.checkHeader(input, "FooBar", 5, 5); assertEquals("this is the data", input.readString()); Exception mine = new RuntimeException("fake exception"); CorruptIndexException expected = expectThrows(CorruptIndexException.class, () -> { CodecUtil.checkFooter(input, mine); }); assertTrue(expected.getMessage().contains("checksum failed")); Throwable suppressed[] = expected.getSuppressed(); assertEquals(1, suppressed.length); assertEquals("fake exception", suppressed[0].getMessage()); input.close(); }
Example #14
Source File: BlurUtilsTest.java From incubator-retired-blur with Apache License 2.0 | 6 votes |
private IndexReader getReader() throws CorruptIndexException, LockObtainFailedException, IOException { RAMDirectory directory = new RAMDirectory(); IndexWriterConfig conf = new IndexWriterConfig(LUCENE_VERSION, new KeywordAnalyzer()); IndexWriter writer = new IndexWriter(directory, conf); Document doc = new Document(); doc.add(new StringField(BlurConstants.PRIME_DOC, BlurConstants.PRIME_DOC_VALUE, Store.NO)); doc.add(new StringField("a", "b", Store.YES)); doc.add(new StringField("family", "f1", Store.YES)); Document doc1 = new Document(); doc.add(new StringField("a", "b", Store.YES)); writer.addDocument(doc); writer.addDocument(doc1); writer.close(); return DirectoryReader.open(directory); }
Example #15
Source File: TestOfflineSorter.java From lucene-solr with Apache License 2.0 | 6 votes |
/** Make sure corruption on the incoming (unsorted) file is caught, even if the corruption didn't confuse OfflineSorter! */ public void testBitFlippedOnInput1() throws Exception { try (Directory dir0 = newMockDirectory()) { Directory dir = new FilterDirectory(dir0) { @Override public IndexOutput createTempOutput(String prefix, String suffix, IOContext context) throws IOException { IndexOutput out = in.createTempOutput(prefix, suffix, context); if (prefix.equals("unsorted")) { return new CorruptingIndexOutput(dir0, 22, out); } else { return out; } } }; IndexOutput unsorted = dir.createTempOutput("unsorted", "tmp", IOContext.DEFAULT); writeAll(unsorted, generateFixed(10*1024)); CorruptIndexException e = expectThrows(CorruptIndexException.class, () -> { new OfflineSorter(dir, "foo").sort(unsorted.getName()); }); assertTrue(e.getMessage().contains("checksum failed (hardware problem?)")); } }
Example #16
Source File: BlurUtilsTest.java From incubator-retired-blur with Apache License 2.0 | 6 votes |
private IndexReader getReaderWithDocsHavingFamily() throws CorruptIndexException, LockObtainFailedException, IOException { RAMDirectory directory = new RAMDirectory(); IndexWriterConfig conf = new IndexWriterConfig(LUCENE_VERSION, new KeywordAnalyzer()); IndexWriter writer = new IndexWriter(directory, conf); Document doc = new Document(); doc.add(new StringField(BlurConstants.PRIME_DOC, BlurConstants.PRIME_DOC_VALUE, Store.NO)); doc.add(new StringField("a", "b", Store.YES)); doc.add(new StringField("family", "f2", Store.YES)); Document doc1 = new Document(); doc1.add(new StringField("a", "b", Store.YES)); doc1.add(new StringField("family", "f1", Store.YES)); writer.addDocument(doc); writer.addDocument(doc1); writer.close(); return DirectoryReader.open(directory); }
Example #17
Source File: IndexManager.java From spacewalk with GNU General Public License v2.0 | 6 votes |
private IndexReader getIndexReader(String indexName, String locale) throws CorruptIndexException, IOException { String path = ""; if (indexName.compareTo(BuilderFactory.DOCS_TYPE) == 0) { path = indexWorkDir + File.separator + getDocIndexPath(locale); } else { path = indexWorkDir + indexName; } log.info("IndexManager::getIndexReader(" + indexName + ", " + locale + ") path = " + path); File f = new File(path); IndexReader retval = IndexReader.open(FSDirectory.getDirectory(f)); return retval; }
Example #18
Source File: Lucene60FieldInfosFormat.java From lucene-solr with Apache License 2.0 | 6 votes |
private static IndexOptions getIndexOptions(IndexInput input, byte b) throws IOException { switch (b) { case 0: return IndexOptions.NONE; case 1: return IndexOptions.DOCS; case 2: return IndexOptions.DOCS_AND_FREQS; case 3: return IndexOptions.DOCS_AND_FREQS_AND_POSITIONS; case 4: return IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS; default: // BUG throw new CorruptIndexException("invalid IndexOptions byte: " + b, input); } }
Example #19
Source File: IndexManager.java From uyuni with GNU General Public License v2.0 | 6 votes |
private IndexReader getIndexReader(String indexName, String locale) throws CorruptIndexException, IOException { String path = ""; if (indexName.compareTo(BuilderFactory.DOCS_TYPE) == 0) { path = indexWorkDir + File.separator + getDocIndexPath(locale); } else { path = indexWorkDir + indexName; } log.info("IndexManager::getIndexReader(" + indexName + ", " + locale + ") path = " + path); File f = new File(path); IndexReader retval = IndexReader.open(FSDirectory.getDirectory(f)); return retval; }
Example #20
Source File: TestBKD.java From lucene-solr with Apache License 2.0 | 6 votes |
private void assertCorruptionDetected(Throwable t) { if (t instanceof CorruptIndexException) { if (t.getMessage().contains("checksum failed (hardware problem?)")) { return; } } for(Throwable suppressed : t.getSuppressed()) { if (suppressed instanceof CorruptIndexException) { if (suppressed.getMessage().contains("checksum failed (hardware problem?)")) { return; } } } fail("did not see a suppressed CorruptIndexException"); }
Example #21
Source File: FileRestoreContext.java From crate with Apache License 2.0 | 5 votes |
/** * Restores a file * * @param fileInfo file to be restored */ private void restoreFile(final BlobStoreIndexShardSnapshot.FileInfo fileInfo, final Store store) throws IOException { boolean success = false; try (InputStream stream = fileInputStream(fileInfo)) { try (IndexOutput indexOutput = store.createVerifyingOutput(fileInfo.physicalName(), fileInfo.metadata(), IOContext.DEFAULT)) { final byte[] buffer = new byte[bufferSize]; int length; while ((length = stream.read(buffer)) > 0) { indexOutput.writeBytes(buffer, 0, length); recoveryState.getIndex().addRecoveredBytesToFile(fileInfo.physicalName(), length); } Store.verify(indexOutput); indexOutput.close(); store.directory().sync(Collections.singleton(fileInfo.physicalName())); success = true; } catch (CorruptIndexException | IndexFormatTooOldException | IndexFormatTooNewException ex) { try { store.markStoreCorrupted(ex); } catch (IOException e) { LOGGER.warn("store cannot be marked as corrupted", e); } throw ex; } finally { if (success == false) { store.deleteQuiet(fileInfo.physicalName()); } } } }
Example #22
Source File: Store.java From crate with Apache License 2.0 | 5 votes |
public static void checkIntegrity(final StoreFileMetaData md, final Directory directory) throws IOException { try (IndexInput input = directory.openInput(md.name(), IOContext.READONCE)) { if (input.length() != md.length()) { // first check the length no matter how old this file is throw new CorruptIndexException("expected length=" + md.length() + " != actual length: " + input.length() + " : file truncated?", input); } // throw exception if the file is corrupt String checksum = Store.digestToString(CodecUtil.checksumEntireFile(input)); // throw exception if metadata is inconsistent if (!checksum.equals(md.checksum())) { throw new CorruptIndexException("inconsistent metadata: lucene checksum=" + checksum + ", metadata checksum=" + md.checksum(), input); } } }
Example #23
Source File: BlockTreeTermsReader.java From lucene-solr with Apache License 2.0 | 5 votes |
private static BytesRef readBytesRef(IndexInput in) throws IOException { int numBytes = in.readVInt(); if (numBytes < 0) { throw new CorruptIndexException("invalid bytes length: " + numBytes, in); } BytesRef bytes = new BytesRef(); bytes.length = numBytes; bytes.bytes = new byte[numBytes]; in.readBytes(bytes.bytes, 0, numBytes); return bytes; }
Example #24
Source File: Store.java From crate with Apache License 2.0 | 5 votes |
public long verify() throws CorruptIndexException { long storedChecksum = getStoredChecksum(); if (getChecksum() == storedChecksum) { return storedChecksum; } throw new CorruptIndexException("verification failed : calculated=" + Store.digestToString(getChecksum()) + " stored=" + Store.digestToString(storedChecksum), this); }
Example #25
Source File: IndexManager.java From spacewalk with GNU General Public License v2.0 | 5 votes |
private IndexWriter getIndexWriter(String name, String lang) throws CorruptIndexException, LockObtainFailedException, IOException { String path = indexWorkDir + name; File f = new File(path); f.mkdirs(); Analyzer analyzer = getAnalyzer(name, lang); IndexWriter writer = new IndexWriter(path, analyzer); writer.setUseCompoundFile(true); return writer; }
Example #26
Source File: CodecUtil.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Validates the codec footer previously written by {@link #writeFooter}, optionally * passing an unexpected exception that has already occurred. * <p> * When a {@code priorException} is provided, this method will add a suppressed exception * indicating whether the checksum for the stream passes, fails, or cannot be computed, and * rethrow it. Otherwise it behaves the same as {@link #checkFooter(ChecksumIndexInput)}. * <p> * Example usage: * <pre class="prettyprint"> * try (ChecksumIndexInput input = ...) { * Throwable priorE = null; * try { * // ... read a bunch of stuff ... * } catch (Throwable exception) { * priorE = exception; * } finally { * CodecUtil.checkFooter(input, priorE); * } * } * </pre> */ public static void checkFooter(ChecksumIndexInput in, Throwable priorException) throws IOException { if (priorException == null) { checkFooter(in); } else { try { // If we have evidence of corruption then we return the corruption as the // main exception and the prior exception gets suppressed. Otherwise we // return the prior exception with a suppressed exception that notifies // the user that checksums matched. long remaining = in.length() - in.getFilePointer(); if (remaining < footerLength()) { // corruption caused us to read into the checksum footer already: we can't proceed throw new CorruptIndexException("checksum status indeterminate: remaining=" + remaining + "; please run checkindex for more details", in); } else { // otherwise, skip any unread bytes. in.skipBytes(remaining - footerLength()); // now check the footer long checksum = checkFooter(in); priorException.addSuppressed(new CorruptIndexException("checksum passed (" + Long.toHexString(checksum) + "). possibly transient resource issue, or a Lucene or JVM bug", in)); } } catch (CorruptIndexException corruptException) { corruptException.addSuppressed(priorException); throw corruptException; } catch (Throwable t) { // catch-all for things that shouldn't go wrong (e.g. OOM during readInt) but could... priorException.addSuppressed(new CorruptIndexException("checksum status indeterminate: unexpected exception", in, t)); } throw IOUtils.rethrowAlways(priorException); } }
Example #27
Source File: LuceneCorpusAdapter.java From Palmetto with GNU Affero General Public License v3.0 | 5 votes |
/** * Creates a corpus adapter which uses the Lucene index with the given path * and searches on the field with the given field name. * * @param indexPath * @param fieldName * @return * @throws CorruptIndexException * @throws IOException */ public static LuceneCorpusAdapter create(String indexPath, String fieldName) throws CorruptIndexException, IOException { DirectoryReader dirReader = DirectoryReader.open(new NIOFSDirectory(new File(indexPath))); List<AtomicReaderContext> leaves = dirReader.leaves(); AtomicReader reader[] = new AtomicReader[leaves.size()]; AtomicReaderContext contexts[] = new AtomicReaderContext[leaves.size()]; for (int i = 0; i < reader.length; i++) { contexts[i] = leaves.get(i); reader[i] = contexts[i].reader(); } return new LuceneCorpusAdapter(dirReader, reader, contexts, fieldName); }
Example #28
Source File: CodecUtil.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Reads CRC32 value as a 64-bit long from the input. * @throws CorruptIndexException if CRC is formatted incorrectly (wrong bits set) * @throws IOException if an i/o error occurs */ static long readCRC(IndexInput input) throws IOException { long value = input.readLong(); if ((value & 0xFFFFFFFF00000000L) != 0) { throw new CorruptIndexException("Illegal CRC-32 checksum: " + value, input); } return value; }
Example #29
Source File: LegacyVerification.java From Elasticsearch with Apache License 2.0 | 5 votes |
@Override public void verify() throws IOException { if (written != length) { throw new CorruptIndexException("expected length=" + length + " != actual length: " + written + " : file truncated?", out.toString()); } final String actualChecksum = Store.digestToString(checksum.getValue()); if (!adler32.equals(actualChecksum)) { throw new CorruptIndexException("checksum failed (hardware problem?) : expected=" + adler32 + " actual=" + actualChecksum, out.toString()); } }
Example #30
Source File: LuceneContent.java From Lottery with GNU General Public License v2.0 | 5 votes |
public static Pagination getResultPage(Searcher searcher, TopDocs docs, int pageNo, int pageSize) throws CorruptIndexException, IOException { List<Integer> list = new ArrayList<Integer>(pageSize); ScoreDoc[] hits = docs.scoreDocs; int endIndex = pageNo * pageSize; int len = hits.length; if (endIndex > len) { endIndex = len; } for (int i = (pageNo - 1) * pageSize; i < endIndex; i++) { Document d = searcher.doc(hits[i].doc); list.add(Integer.valueOf(d.getField(ID).stringValue())); } return new Pagination(pageNo, pageSize, docs.totalHits, list); }