@Test
public void sequenceFileDictionary() throws IOException {

  Directory index = new SimpleFSDirectory(indexDir);
  Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_46);
  IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_46, analyzer);
  final IndexWriter writer = new IndexWriter(index, config);
  try {
    writer.addDocument(asDocument("One Ring to rule them all"));
    writer.addDocument(asDocument("One Ring to find them,"));
    writer.addDocument(asDocument("One Ring to bring them all"));
    writer.addDocument(asDocument("and in the darkness bind them"));
  } finally {
    writer.close(true);
  }
  File seqDict = new File(outputDir, "dict.seq");
  Driver.main(new String[] {
      "--dir", indexDir.getAbsolutePath(),
      "--output", new File(outputDir, "out").getAbsolutePath(),
      "--field", "text",
      "--dictOut", new File(outputDir, "dict.txt").getAbsolutePath(),
      "--seqDictOut", seqDict.getAbsolutePath(),
  });
  SequenceFile.Reader reader = null;
  Set<String> indexTerms = Sets.newHashSet();
  try {
    reader = new SequenceFile.Reader(FileSystem.getLocal(conf), new Path(seqDict.getAbsolutePath()), conf);
    Text term = new Text();
    IntWritable termIndex = new IntWritable();
    while (reader.next(term, termIndex)) {
      indexTerms.add(term.toString());
    }
  } finally {
    Closeables.close(reader, true);
  }
  Set<String> expectedIndexTerms = Sets.newHashSet("all", "bind", "bring", "darkness", "find", "one", "ring", "rule");
  // should contain the same terms as expected
  assertEquals(expectedIndexTerms.size(), Sets.union(expectedIndexTerms, indexTerms).size());
}