⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fieldsreader.java

📁 索引aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
💻 JAVA
字号:
package org.apache.lucene.index;/** * Copyright 2004 The Apache Software Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * *     http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */import java.io.IOException;import org.apache.lucene.store.Directory;import org.apache.lucene.store.InputStream;import org.apache.lucene.document.Document;import org.apache.lucene.document.Field;/** * Class responsible for access to stored document fields. * * It uses &lt;segment&gt;.fdt and &lt;segment&gt;.fdx; files. * * @version $Id: FieldsReader.java,v 1.7 2004/03/29 22:48:02 cutting Exp $ */final class FieldsReader {  private FieldInfos fieldInfos;  private InputStream fieldsStream;  private InputStream indexStream;  private int size;  FieldsReader(Directory d, String segment, FieldInfos fn) throws IOException {    fieldInfos = fn;    fieldsStream = d.openFile(segment + ".fdt");    indexStream = d.openFile(segment + ".fdx");    size = (int)(indexStream.length() / 8);  }  final void close() throws IOException {    fieldsStream.close();    indexStream.close();  }  final int size() {    return size;  }  final Document doc(int n) throws IOException {    indexStream.seek(n * 8L);    long position = indexStream.readLong();    fieldsStream.seek(position);    Document doc = new Document();    int numFields = fieldsStream.readVInt();    for (int i = 0; i < numFields; i++) {      int fieldNumber = fieldsStream.readVInt();      FieldInfo fi = fieldInfos.fieldInfo(fieldNumber);      byte bits = fieldsStream.readByte();      doc.add(new Field(fi.name,		  // name			fieldsStream.readString(), // read value			true,			  // stored			fi.isIndexed,		  // indexed			(bits & 1) != 0, fi.storeTermVector)); // vector    }    return doc;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -