### Question:
CompressedFieldDataDirectory extends Directory { public void close() throws IOException { _directory.close(); } CompressedFieldDataDirectory(Directory dir);  CompressedFieldDataDirectory(Directory dir, CompressionCodec compression);  CompressedFieldDataDirectory(Directory dir, CompressionCodec compression, int blockSize); Directory getInnerDirectory(); IndexInput openInput(String name); IndexInput openInput(String name, int bufferSize); IndexOutput createOutput(String name); void clearLock(String name); void close(); void deleteFile(String name); boolean fileExists(String name); long fileLength(String name); @SuppressWarnings("deprecation") long fileModified(String name); String[] listAll(); void touchFile(String name); LockFactory getLockFactory(); String getLockID(); Lock makeLock(String name); void setLockFactory(LockFactory lockFactory); @SuppressWarnings("deprecation") void sync(String name); String toString(); static CompressionCodec DEFAULT_COMPRESSION; }### Answer:
@Test public void testCompressedFieldDataDirectoryBasic() throws CorruptIndexException, IOException { RAMDirectory dir = new RAMDirectory(); CompressedFieldDataDirectory directory = new CompressedFieldDataDirectory(dir, COMPRESSION_CODEC); IndexWriterConfig config = new IndexWriterConfig(LUCENE_VERSION, new KeywordAnalyzer()); TieredMergePolicy mergePolicy = (TieredMergePolicy) config.getMergePolicy(); mergePolicy.setUseCompoundFile(false); IndexWriter writer = new IndexWriter(directory, config); addDocs(writer, 0, 10); writer.close(); testFetches(directory); }
@Test public void testCompressedFieldDataDirectoryTransition() throws CorruptIndexException, LockObtainFailedException, IOException { RAMDirectory dir = new RAMDirectory(); IndexWriterConfig config = new IndexWriterConfig(LUCENE_VERSION, new KeywordAnalyzer()); TieredMergePolicy mergePolicy = (TieredMergePolicy) config.getMergePolicy(); mergePolicy.setUseCompoundFile(false); IndexWriter writer = new IndexWriter(dir, config); addDocs(writer, 0, 5); writer.close(); CompressedFieldDataDirectory directory = new CompressedFieldDataDirectory(dir, COMPRESSION_CODEC); config = new IndexWriterConfig(LUCENE_VERSION, new KeywordAnalyzer()); mergePolicy = (TieredMergePolicy) config.getMergePolicy(); mergePolicy.setUseCompoundFile(false); writer = new IndexWriter(directory, config); addDocs(writer, 5, 5); writer.close(); testFetches(directory); }
@Test public void testCompressedFieldDataDirectoryMixedBlockSize() throws CorruptIndexException, LockObtainFailedException, IOException { RAMDirectory dir = new RAMDirectory(); IndexWriterConfig config = new IndexWriterConfig(LUCENE_VERSION, new KeywordAnalyzer()); TieredMergePolicy mergePolicy = (TieredMergePolicy) config.getMergePolicy(); mergePolicy.setUseCompoundFile(false); IndexWriter writer = new IndexWriter(dir, config); addDocs(writer, 0, 5); writer.close(); CompressedFieldDataDirectory directory1 = new CompressedFieldDataDirectory(dir, COMPRESSION_CODEC, 2); config = new IndexWriterConfig(LUCENE_VERSION, new KeywordAnalyzer()); mergePolicy = (TieredMergePolicy) config.getMergePolicy(); mergePolicy.setUseCompoundFile(false); writer = new IndexWriter(directory1, config); addDocs(writer, 5, 2); writer.close(); CompressedFieldDataDirectory directory2 = new CompressedFieldDataDirectory(dir, COMPRESSION_CODEC, 4); config = new IndexWriterConfig(LUCENE_VERSION, new KeywordAnalyzer()); mergePolicy = (TieredMergePolicy) config.getMergePolicy(); mergePolicy.setUseCompoundFile(false); writer = new IndexWriter(directory2, config); addDocs(writer, 7, 3); writer.close(); testFetches(directory2); testFileLengths(directory2); }