From f2f2e2b2edd0f8f08a8c883a0c156091e207d1d4 Mon Sep 17 00:00:00 2001 From: John Wang Date: Mon, 3 Mar 2014 14:41:41 -0800 Subject: [PATCH] clean up --- .../senseidb/clue/commands/InfoCommand.java | 89 +++++++++---------- 1 file changed, 44 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/senseidb/clue/commands/InfoCommand.java b/src/main/java/com/senseidb/clue/commands/InfoCommand.java index 05bc5f4..ec65ffa 100644 --- a/src/main/java/com/senseidb/clue/commands/InfoCommand.java +++ b/src/main/java/com/senseidb/clue/commands/InfoCommand.java @@ -3,10 +3,11 @@ import java.io.IOException; import java.io.PrintStream; import java.util.Arrays; -import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.SortedMap; +import java.util.TreeMap; import org.apache.lucene.index.AtomicReader; import org.apache.lucene.index.AtomicReaderContext; @@ -39,57 +40,55 @@ public String help() { private static void toString(Object[] info, PrintStream out) throws IOException { FieldInfo finfo = (FieldInfo) info[0]; List termList = (List) info[1]; - out.println("name:\t" + finfo.name); - out.println("norms:\t" + String.valueOf(finfo.hasNorms())); - out.println("payloads:\t" + String.valueOf(finfo.hasPayloads())); - out.println("docval:\t" + String.valueOf(finfo.hasDocValues())); + out.println("name:\t\t" + finfo.name); + out.println("docval:\t\t" + String.valueOf(finfo.hasDocValues())); + if (finfo.hasDocValues()) { + out.println("docval_type:\t" + String.valueOf(finfo.getDocValuesType())); + } + out.println("norms:\t\t" + String.valueOf(finfo.hasNorms())); + + if (finfo.hasNorms()) { + out.println("norm_type:\t" + String.valueOf(finfo.getNormType())); + } + out.println("indexed:\t" + String.valueOf(finfo.isIndexed())); IndexOptions indexOptions = finfo.getIndexOptions(); if (indexOptions != null) { out.println("index_options:\t" + finfo.getIndexOptions().name()); } - + out.println("payloads:\t" + String.valueOf(finfo.hasPayloads())); out.println("vectors:\t" + String.valueOf(finfo.hasVectors())); out.println("attributes:\t" + finfo.attributes().toString()); - - if (finfo.hasNorms()) { - out.println("norm_type:\t" + String.valueOf(finfo.getNormType())); - } - if (finfo.hasDocValues()) { - out.println("docval_type:\t" + String.valueOf(finfo.getDocValuesType())); - } else { - - if (termList != null) { - - long numTerms = 0L; - long docCount = 0L; - long sumDocFreq = 0L; - long sumTotalTermFreq = 0L; - - for (Terms t : termList) { - if (t != null) { - numTerms += t.size(); - docCount += t.getDocCount(); - sumDocFreq += t.getSumDocFreq(); - sumTotalTermFreq += t.getSumTotalTermFreq(); - } - } - if (numTerms < 0) { - numTerms = -1; + if (termList != null) { + + long numTerms = 0L; + long docCount = 0L; + long sumDocFreq = 0L; + long sumTotalTermFreq = 0L; + + for (Terms t : termList) { + if (t != null) { + numTerms += t.size(); + docCount += t.getDocCount(); + sumDocFreq += t.getSumDocFreq(); + sumTotalTermFreq += t.getSumTotalTermFreq(); } - if (docCount < 0) { - docCount = -1; - } - if (sumDocFreq < 0) { - sumDocFreq = -1; - } - if (sumTotalTermFreq < 0) { - sumTotalTermFreq = -1; - } - out.println("num_terms:\t" + String.valueOf(numTerms)); - out.println("doc_count:\t" + String.valueOf(docCount)); - out.println("sum_doc_freq:\t" + String.valueOf(sumDocFreq)); - out.println("sum_total_term_freq:\t" + String.valueOf(sumTotalTermFreq)); } + if (numTerms < 0) { + numTerms = -1; + } + if (docCount < 0) { + docCount = -1; + } + if (sumDocFreq < 0) { + sumDocFreq = -1; + } + if (sumTotalTermFreq < 0) { + sumTotalTermFreq = -1; + } + out.println("num_terms:\t" + String.valueOf(numTerms)); + out.println("doc_count:\t" + String.valueOf(docCount)); + out.println("sum_doc_freq:\t" + String.valueOf(sumDocFreq)); + out.println("sum_total_term_freq:\t" + String.valueOf(sumTotalTermFreq)); } } @@ -105,7 +104,7 @@ public void execute(String[] args, PrintStream out) throws Exception { out.println("maxdoc: " + r.maxDoc()); out.println("num deleted docs: " + r.numDeletedDocs()); out.println("segment count: " + leaves.size()); - HashMap fields = new HashMap(); + SortedMap fields = new TreeMap(); for (AtomicReaderContext leaf : leaves) { AtomicReader ar = leaf.reader(); FieldInfos fldInfos = ar.getFieldInfos();