Lucene 3.02 directory classification and its relationship with read/write classes

Source: Internet
Author: User

I. Classification of directory

Directory can be divided into two types: Memory directory and file directory.

1. The memory directory is ramdirectory.

2. File directory: fsdirectory

Fsdirectory is divided into three categories:

1) simplefsdirectory in Windows

2) Linux supports NiO niofsdirectory

3) Another is the memory map directory mmapdirectory.

Simplefsdirectory is a simple implementation of fsdirectory, and has limited concurrent processing capabilities. It is better to use mmapdirectory.
Niofsdirectory is a directory used in Linux and can provide good performance,

Ii. Tools inherited from directory

In addition, directory has two tool classes.


1. One is the fileswitchdirectory that can read files in two different directories at the same time. This is a proxy class.

2. You can only read files with the CFS extension by reading the compoundfilereader of the composite file. (Compoundfilewriter is used to write files with the CFS extension.) compoundfilereader is only referenced in segmentreader.


Iii. Correspondence between directory and read/write objects


Directory is an abstract class that defines the methods for obtaining read/write objects, createoutput () and openinput ().
Fsdirectory is an abstract class. Each class that inherits fsdirectory implements its own createoutput () and openinput () methods, and returns indexinput and indexoutput that match each directory of different types.

Objects returned by openinput:

Directory --> ramdirectory ==> indexinput --> raminputstream
Directory --> fsdirectory --> simplefsdirectory ==> indexinput --> bufferedindexinput --> simplefsindexinput
Directory --> fsdirectory --> niofsdirectory ==> indexinput --> bufferedindexinput --> niofsindexinput
Directory --> fsdirectory --> mmapdirectory ==> indexinput --> bufferedindexinput --> mmapindexinput/multimmapindexinput
Directory --> fileswitchdirectory ====> indexinput --> indexinput for cross-reading
Directory --> compoundfilereader ====> indexinput --> bufferedindexinput --> csindexinput



Objects returned by createoutput:

Directory --> ramdirectory ==> indexinput --> ramoutputstream
Directory --> fsdirectory --> simplefsdirectory ==> indexoutput --> bufferedindexoutput --> simplefsindexoutput
Directory --> fsdirectory --> niofsdirectory ==> indexoutput --> bufferedindexoutput --> simplefsdirectory. simplefsindexoutput
Directory --> fsdirectory --> mmapdirectory ==> indexoutput --> bufferedindexoutput --> simplefsdirectory. simplefsindexoutput
Directory --> fileswitchdirectory ====> indexinput --> indexinput for cross-reading
Directory --> compoundfilewriter ====> compoundfilewriter does not inherit indexoutput because compoundfilewriter uses add (string file) to add, instead of writebytes ()


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.