Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
John Wang committed Mar 3, 2014
1 parent 4b26672 commit f2f2e2b
Showing 1 changed file with 44 additions and 45 deletions.
89 changes: 44 additions & 45 deletions src/main/java/com/senseidb/clue/commands/InfoCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -39,57 +40,55 @@ public String help() {
private static void toString(Object[] info, PrintStream out) throws IOException {
FieldInfo finfo = (FieldInfo) info[0];
List<Terms> termList = (List<Terms>) 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));
}
}

Expand All @@ -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<String, Object[]> fields = new HashMap<String, Object[]>();
SortedMap<String, Object[]> fields = new TreeMap<String, Object[]>();
for (AtomicReaderContext leaf : leaves) {
AtomicReader ar = leaf.reader();
FieldInfos fldInfos = ar.getFieldInfos();
Expand Down

0 comments on commit f2f2e2b

Please sign in to comment.