当前位置: 首页>>代码示例>>Java>>正文


Java CorruptIndexException类代码示例

本文整理汇总了Java中org.apache.lucene.index.CorruptIndexException的典型用法代码示例。如果您正苦于以下问题:Java CorruptIndexException类的具体用法?Java CorruptIndexException怎么用?Java CorruptIndexException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CorruptIndexException类属于org.apache.lucene.index包,在下文中一共展示了CorruptIndexException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readBlob

import org.apache.lucene.index.CorruptIndexException; //导入依赖的package包/类
/**
 * 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)) {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        Streams.copy(inputStream, out);
        final byte[] bytes = out.toByteArray();
        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);
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:ChecksumBlobStoreFormat.java

示例2: outputBatch

import org.apache.lucene.index.CorruptIndexException; //导入依赖的package包/类
private void outputBatch(IndexReader indexReader, TopDocs topDocs, int batch, String outputBaseFormat, String pmidOutputFormat, String xmlOutputFormat) throws CorruptIndexException, IOException {
	String outputBasePath = String.format(outputBaseFormat, batch);
	OutputDirectory outputBaseDir = new OutputDirectory(outputBasePath);
	int start = batch * batchSize;
	int end = Math.min(start + batchSize, topDocs.totalHits);
	if (pmidOutputFormat != null) {
		try (PrintStream out = open(batch, outputBaseDir, pmidOutputFormat)) {
			for (int d = start; d < end; ++d) {
				outputBatchDocument(indexReader, topDocs, out, PubMedIndexField.PMID, d);
			}
		}
	}
	if (xmlOutputFormat != null) {
		try (PrintStream out = open(batch, outputBaseDir, xmlOutputFormat)) {
			out.println(XML_HEADER);
			for (int d = start; d < end; ++d) {
				outputBatchDocument(indexReader, topDocs, out, PubMedIndexField.XML, d);
			}
			out.println(XML_FOOTER);
		}
	}
}
 
开发者ID:Bibliome,项目名称:bibliome-java-utils,代码行数:23,代码来源:PubMedIndexSearcher.java

示例3: testCanOpenIndex

import org.apache.lucene.index.CorruptIndexException; //导入依赖的package包/类
public void testCanOpenIndex() throws IOException {
    final ShardId shardId = new ShardId("index", "_na_", 1);
    IndexWriterConfig iwc = newIndexWriterConfig();
    Path tempDir = createTempDir();
    final BaseDirectoryWrapper dir = newFSDirectory(tempDir);
    assertFalse(Store.canOpenIndex(logger, tempDir, shardId, (id, l) -> new DummyShardLock(id)));
    IndexWriter writer = new IndexWriter(dir, iwc);
    Document doc = new Document();
    doc.add(new StringField("id", "1", random().nextBoolean() ? Field.Store.YES : Field.Store.NO));
    writer.addDocument(doc);
    writer.commit();
    writer.close();
    assertTrue(Store.canOpenIndex(logger, tempDir, shardId, (id, l) -> new DummyShardLock(id)));

    DirectoryService directoryService = new DirectoryService(shardId, INDEX_SETTINGS) {

        @Override
        public Directory newDirectory() throws IOException {
            return dir;
        }
    };
    Store store = new Store(shardId, INDEX_SETTINGS, directoryService, new DummyShardLock(shardId));
    store.markStoreCorrupted(new CorruptIndexException("foo", "bar"));
    assertFalse(Store.canOpenIndex(logger, tempDir, shardId, (id, l) -> new DummyShardLock(id)));
    store.close();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:StoreTests.java

示例4: createNonExistentShards

import org.apache.lucene.index.CorruptIndexException; //导入依赖的package包/类
private List<ShardStateAction.ShardEntry> createNonExistentShards(ClusterState currentState, String reason) {
    // add shards from a non-existent index
    String nonExistentIndexUUID = "non-existent";
    Index index = new Index("non-existent", nonExistentIndexUUID);
    List<String> nodeIds = new ArrayList<>();
    for (ObjectCursor<String> nodeId : currentState.nodes().getNodes().keys()) {
        nodeIds.add(nodeId.toString());
    }
    List<ShardRouting> nonExistentShards = new ArrayList<>();
    nonExistentShards.add(nonExistentShardRouting(index, nodeIds, true));
    for (int i = 0; i < numberOfReplicas; i++) {
        nonExistentShards.add(nonExistentShardRouting(index, nodeIds, false));
    }

    List<ShardStateAction.ShardEntry> existingShards = createExistingShards(currentState, reason);
    List<ShardStateAction.ShardEntry> shardsWithMismatchedAllocationIds = new ArrayList<>();
    for (ShardStateAction.ShardEntry existingShard : existingShards) {
        shardsWithMismatchedAllocationIds.add(new ShardStateAction.ShardEntry(existingShard.shardId, UUIDs.randomBase64UUID(), 0L, existingShard.message, existingShard.failure));
    }

    List<ShardStateAction.ShardEntry> tasks = new ArrayList<>();
    nonExistentShards.forEach(shard -> tasks.add(new ShardStateAction.ShardEntry(shard.shardId(), shard.allocationId().getId(), 0L, reason, new CorruptIndexException("simulated", nonExistentIndexUUID))));
    tasks.addAll(shardsWithMismatchedAllocationIds);
    return tasks;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:ShardFailedClusterStateTaskExecutorTests.java

示例5: Search

import org.apache.lucene.index.CorruptIndexException; //导入依赖的package包/类
/**
 * 查询方法
 * @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;
}
 
开发者ID:zhangjikai,项目名称:sdudoc,代码行数:26,代码来源:LuceneIndexSearch.java

示例6: skipField

import org.apache.lucene.index.CorruptIndexException; //导入依赖的package包/类
private void skipField(int bits) throws IOException {
  final int numeric = bits & FIELD_IS_NUMERIC_MASK;
  if (numeric != 0) {
    switch(numeric) {
      case FIELD_IS_NUMERIC_INT:
      case FIELD_IS_NUMERIC_FLOAT:
        fieldsStream.readInt();
        return;
      case FIELD_IS_NUMERIC_LONG:
      case FIELD_IS_NUMERIC_DOUBLE:
        fieldsStream.readLong();
        return;
      default: 
        throw new CorruptIndexException("Invalid numeric type: " + Integer.toHexString(numeric));
    }
  } else {
    final int length = fieldsStream.readVInt();
    fieldsStream.seek(fieldsStream.getFilePointer() + length);
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:Lucene40StoredFieldsReader.java

示例7: loadByteField

import org.apache.lucene.index.CorruptIndexException; //导入依赖的package包/类
private NumericDocValues loadByteField(FieldInfo field, IndexInput input) throws IOException {
  CodecUtil.checkHeader(input, Lucene40DocValuesFormat.INTS_CODEC_NAME,
                               Lucene40DocValuesFormat.INTS_VERSION_START,
                               Lucene40DocValuesFormat.INTS_VERSION_CURRENT);
  int valueSize = input.readInt();
  if (valueSize != 1) {
    throw new CorruptIndexException("invalid valueSize: " + valueSize);
  }
  int maxDoc = state.segmentInfo.getDocCount();
  final byte values[] = new byte[maxDoc];
  input.readBytes(values, 0, values.length);
  ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
  return new NumericDocValues() {
    @Override
    public long get(int docID) {
      return values[docID];
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:Lucene40DocValuesReader.java

示例8: loadShortField

import org.apache.lucene.index.CorruptIndexException; //导入依赖的package包/类
private NumericDocValues loadShortField(FieldInfo field, IndexInput input) throws IOException {
  CodecUtil.checkHeader(input, Lucene40DocValuesFormat.INTS_CODEC_NAME,
                               Lucene40DocValuesFormat.INTS_VERSION_START,
                               Lucene40DocValuesFormat.INTS_VERSION_CURRENT);
  int valueSize = input.readInt();
  if (valueSize != 2) {
    throw new CorruptIndexException("invalid valueSize: " + valueSize);
  }
  int maxDoc = state.segmentInfo.getDocCount();
  final short values[] = new short[maxDoc];
  for (int i = 0; i < values.length; i++) {
    values[i] = input.readShort();
  }
  ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
  return new NumericDocValues() {
    @Override
    public long get(int docID) {
      return values[docID];
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:Lucene40DocValuesReader.java

示例9: loadIntField

import org.apache.lucene.index.CorruptIndexException; //导入依赖的package包/类
private NumericDocValues loadIntField(FieldInfo field, IndexInput input) throws IOException {
  CodecUtil.checkHeader(input, Lucene40DocValuesFormat.INTS_CODEC_NAME,
                               Lucene40DocValuesFormat.INTS_VERSION_START,
                               Lucene40DocValuesFormat.INTS_VERSION_CURRENT);
  int valueSize = input.readInt();
  if (valueSize != 4) {
    throw new CorruptIndexException("invalid valueSize: " + valueSize);
  }
  int maxDoc = state.segmentInfo.getDocCount();
  final int values[] = new int[maxDoc];
  for (int i = 0; i < values.length; i++) {
    values[i] = input.readInt();
  }
  ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
  return new NumericDocValues() {
    @Override
    public long get(int docID) {
      return values[docID];
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:Lucene40DocValuesReader.java

示例10: loadLongField

import org.apache.lucene.index.CorruptIndexException; //导入依赖的package包/类
private NumericDocValues loadLongField(FieldInfo field, IndexInput input) throws IOException {
  CodecUtil.checkHeader(input, Lucene40DocValuesFormat.INTS_CODEC_NAME,
                               Lucene40DocValuesFormat.INTS_VERSION_START,
                               Lucene40DocValuesFormat.INTS_VERSION_CURRENT);
  int valueSize = input.readInt();
  if (valueSize != 8) {
    throw new CorruptIndexException("invalid valueSize: " + valueSize);
  }
  int maxDoc = state.segmentInfo.getDocCount();
  final long values[] = new long[maxDoc];
  for (int i = 0; i < values.length; i++) {
    values[i] = input.readLong();
  }
  ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
  return new NumericDocValues() {
    @Override
    public long get(int docID) {
      return values[docID];
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:Lucene40DocValuesReader.java

示例11: loadFloatField

import org.apache.lucene.index.CorruptIndexException; //导入依赖的package包/类
private NumericDocValues loadFloatField(FieldInfo field, IndexInput input) throws IOException {
  CodecUtil.checkHeader(input, Lucene40DocValuesFormat.FLOATS_CODEC_NAME,
                               Lucene40DocValuesFormat.FLOATS_VERSION_START,
                               Lucene40DocValuesFormat.FLOATS_VERSION_CURRENT);
  int valueSize = input.readInt();
  if (valueSize != 4) {
    throw new CorruptIndexException("invalid valueSize: " + valueSize);
  }
  int maxDoc = state.segmentInfo.getDocCount();
  final int values[] = new int[maxDoc];
  for (int i = 0; i < values.length; i++) {
    values[i] = input.readInt();
  }
  ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
  return new NumericDocValues() {
    @Override
    public long get(int docID) {
      return values[docID];
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:Lucene40DocValuesReader.java

示例12: loadDoubleField

import org.apache.lucene.index.CorruptIndexException; //导入依赖的package包/类
private NumericDocValues loadDoubleField(FieldInfo field, IndexInput input) throws IOException {
  CodecUtil.checkHeader(input, Lucene40DocValuesFormat.FLOATS_CODEC_NAME,
                               Lucene40DocValuesFormat.FLOATS_VERSION_START,
                               Lucene40DocValuesFormat.FLOATS_VERSION_CURRENT);
  int valueSize = input.readInt();
  if (valueSize != 8) {
    throw new CorruptIndexException("invalid valueSize: " + valueSize);
  }
  int maxDoc = state.segmentInfo.getDocCount();
  final long values[] = new long[maxDoc];
  for (int i = 0; i < values.length; i++) {
    values[i] = input.readLong();
  }
  ramBytesUsed.addAndGet(RamUsageEstimator.sizeOf(values));
  return new NumericDocValues() {
    @Override
    public long get(int docID) {
      return values[docID];
    }
  };
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:Lucene40DocValuesReader.java

示例13: getDocValuesType

import org.apache.lucene.index.CorruptIndexException; //导入依赖的package包/类
private static DocValuesType getDocValuesType(IndexInput input, byte b) throws IOException {
  if (b == 0) {
    return null;
  } else if (b == 1) {
    return DocValuesType.NUMERIC;
  } else if (b == 2) {
    return DocValuesType.BINARY;
  } else if (b == 3) {
    return DocValuesType.SORTED;
  } else if (b == 4) {
    return DocValuesType.SORTED_SET;
  } else if (b == 5) {
    return DocValuesType.SORTED_NUMERIC;
  } else {
    throw new CorruptIndexException("invalid docvalues byte: " + b + " (resource=" + input + ")");
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:Lucene46FieldInfosReader.java

示例14: readSortedField

import org.apache.lucene.index.CorruptIndexException; //导入依赖的package包/类
private void readSortedField(int fieldNumber, IndexInput meta, FieldInfos infos) throws IOException {
  // sorted = binary + numeric
  if (meta.readVInt() != fieldNumber) {
    throw new CorruptIndexException("sorted entry for field: " + fieldNumber + " is corrupt (resource=" + meta + ")");
  }
  if (meta.readByte() != Lucene45DocValuesFormat.BINARY) {
    throw new CorruptIndexException("sorted entry for field: " + fieldNumber + " is corrupt (resource=" + meta + ")");
  }
  BinaryEntry b = readBinaryEntry(meta);
  binaries.put(fieldNumber, b);
  
  if (meta.readVInt() != fieldNumber) {
    throw new CorruptIndexException("sorted entry for field: " + fieldNumber + " is corrupt (resource=" + meta + ")");
  }
  if (meta.readByte() != Lucene45DocValuesFormat.NUMERIC) {
    throw new CorruptIndexException("sorted entry for field: " + fieldNumber + " is corrupt (resource=" + meta + ")");
  }
  NumericEntry n = readNumericEntry(meta);
  ords.put(fieldNumber, n);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:Lucene45DocValuesProducer.java

示例15: readFields

import org.apache.lucene.index.CorruptIndexException; //导入依赖的package包/类
private void readFields(IndexInput meta, FieldInfos infos) throws IOException {
  int fieldNumber = meta.readVInt();
  while (fieldNumber != -1) {
    FieldInfo info = infos.fieldInfo(fieldNumber);
    if (info == null) {
      throw new CorruptIndexException("Invalid field number: " + fieldNumber + " (resource=" + meta + ")");
    } else if (!info.hasNorms()) {
      throw new CorruptIndexException("Invalid field: " + info.name + " (resource=" + meta + ")");
    }
    NormsEntry entry = new NormsEntry();
    entry.format = meta.readByte();
    entry.offset = meta.readLong();
    switch(entry.format) {
      case CONST_COMPRESSED:
      case UNCOMPRESSED:
      case TABLE_COMPRESSED:
      case DELTA_COMPRESSED:
        break;
      default:
        throw new CorruptIndexException("Unknown format: " + entry.format + ", input=" + meta);
    }
    norms.put(fieldNumber, entry);
    fieldNumber = meta.readVInt();
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:Lucene49NormsProducer.java


注:本文中的org.apache.lucene.index.CorruptIndexException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。