Skip to content

Commit

Permalink
cleanup code; remove old classes; add HdrHistogram.jar
Browse files Browse the repository at this point in the history
  • Loading branch information
serera committed Feb 5, 2014
1 parent 12563f6 commit 65ea4a2
Show file tree
Hide file tree
Showing 18 changed files with 299 additions and 1,045 deletions.
5 changes: 3 additions & 2 deletions BuildFST.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ public Pair(BytesRef input, T output) {
}

@Override
public int compareTo(Pair other) {
public int compareTo(Pair<T> other) {
return input.compareTo(other.input);
}
}

public static void main(String[] args) throws IOException {
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void main(String[] args) throws IOException {

boolean numeric = true;
boolean negative = false;
Expand Down
5 changes: 2 additions & 3 deletions DumpFacets.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import java.io.File;
import java.io.IOException;

import org.apache.lucene.facet.taxonomy.CategoryPath;
import org.apache.lucene.facet.FacetsConfig;
import org.apache.lucene.facet.taxonomy.TaxonomyReader;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyReader;
import org.apache.lucene.index.AtomicReader;
import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.SlowCompositeReaderWrapper;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
Expand All @@ -26,7 +25,7 @@ public static void main(String[] args) throws IOException {
TaxonomyReader tr = new DirectoryTaxonomyReader(tdir);
System.out.println("ords");
for(int ord=0;ord<tr.getSize();ord++) {
System.out.println(" " + ord + " " + tr.getPath(ord).toString('\u001f'));
System.out.println(" " + ord + " " + FacetsConfig.pathToString(tr.getPath(ord).components));
}
BinaryDocValues bdv = r.getBinaryDocValues(args[2]);
System.out.println("maxDoc=" + r.maxDoc() + " r=" + r);
Expand Down
25 changes: 4 additions & 21 deletions ToHGRM.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
import org.HdrHistogram.Histogram;

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import java.io.BufferedReader;
import java.io.InputStreamReader;

// javac -cp .:/l/HdrHistogram/src ToHGRM.java
import org.HdrHistogram.Histogram;

// javac -cp lib/HdrHistogram.jar ToHGRM.java

public class ToHGRM {

Expand All @@ -38,6 +21,6 @@ public static void main(String[] args) throws Exception {
h.recordValue((long) (1000*Double.parseDouble(line.trim())));
}

h.getRawHistogramData().outputPercentileDistribution(System.out, 50, 1.0);
h.getHistogramData().outputPercentileDistribution(System.out, 50, 1.0);
}
}
Binary file added lib/HdrHistogram.jar
Binary file not shown.
8 changes: 3 additions & 5 deletions perf/3x/LineFileDocs.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* limitations under the License.
*/

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.FileInputStream;
Expand All @@ -29,11 +28,10 @@
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.Random;
import java.util.concurrent.atomic.AtomicLong;

import org.apache.lucene.document.*;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.util.BytesRef;

public class LineFileDocs implements Closeable {
Expand Down Expand Up @@ -103,7 +101,7 @@ public static int idToInt(String id) {
int downTo = id.length() - 1;
int multiplier = 1;
while(downTo >= 0) {
final char ch = (char) id.charAt(downTo--);
final char ch = id.charAt(downTo--);
final int digit;
if (ch >= '0' && ch <= '9') {
digit = ch - '0';
Expand Down
4 changes: 1 addition & 3 deletions perf/CreateQueries.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ private static void makePrefixQueries(TermFreq[] terms, Writer queriesOut) throw
final Set<String> seen = new HashSet<String>();

int idx = 0;
int lastCount = 0;
while(seen.size() < NUM_QUERIES) {
if (idx == terms.length) {
throw new RuntimeException("not enough unique prefixes");
Expand All @@ -209,7 +208,6 @@ private static void makeWildcardQueries(TermFreq[] terms, Writer queriesOut) thr
final Set<String> seen = new HashSet<String>();

int idx = 0;
int lastCount = 0;
while(seen.size() < NUM_QUERIES) {
if (idx == terms.length) {
throw new RuntimeException("not enough unique prefixes");
Expand Down Expand Up @@ -268,7 +266,7 @@ private static void makeFuzzyAndRespellQueries(IndexReader r, String field, Term
throw new RuntimeException("index is too small: only " + pq.size() + " top fuzzy terms");
}

int downTo = NUM_QUERIES;
// int downTo = NUM_QUERIES;
while (pq.size()>0) {
TermFreq tdf = pq.pop();
System.out.println(" " + tdf.term.utf8ToString() + " freq=" + tdf.df);
Expand Down
5 changes: 2 additions & 3 deletions perf/IndexThreads.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
Expand Down Expand Up @@ -234,7 +232,8 @@ public Iterator<IndexDocument> iterator() {
int upto;
IndexDocument doc;

@Override
@SuppressWarnings("synthetic-access")
@Override
public boolean hasNext() {
if (upto < numDocs) {
upto++;
Expand Down
27 changes: 15 additions & 12 deletions perf/Indexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,11 @@
*/

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.en.EnglishAnalyzer;
Expand All @@ -39,15 +33,24 @@
import org.apache.lucene.codecs.DocValuesFormat;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.lucene46.Lucene46Codec;
import org.apache.lucene.document.*;
import org.apache.lucene.facet.FacetsConfig;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.facet.taxonomy.directory.DirectoryTaxonomyWriter;
import org.apache.lucene.index.*;
import org.apache.lucene.index.AtomicReaderContext;
import org.apache.lucene.search.*;
import org.apache.lucene.store.*;
import org.apache.lucene.util.*;
import org.apache.lucene.index.ConcurrentMergeScheduler;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.LogByteSizeMergePolicy;
import org.apache.lucene.index.LogDocMergePolicy;
import org.apache.lucene.index.LogMergePolicy;
import org.apache.lucene.index.MergePolicy;
import org.apache.lucene.index.NoDeletionPolicy;
import org.apache.lucene.index.NoMergePolicy;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TieredMergePolicy;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.InfoStream;
import org.apache.lucene.util.PrintStreamInfoStream;
import org.apache.lucene.util.Version;

// javac -Xlint:deprecation -cp ../modules/analysis/build/common/classes/java:build/classes/java:build/classes/test-framework:build/classes/test:build/contrib/misc/classes/java perf/Indexer.java perf/LineFileDocs.java

Expand Down
6 changes: 4 additions & 2 deletions perf/KeepNoCommitsDeletionPolicy.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ public KeepNoCommitsDeletionPolicy() {
/**
* Deletes all commits.
*/
public void onInit(List<? extends IndexCommit> commits) {
@Override
public void onInit(List<? extends IndexCommit> commits) {
// Note that commits.size() should normally be 1:
onCommit(commits);
}

/**
* Deletes all commits.
*/
public void onCommit(List<? extends IndexCommit> commits) {
@Override
public void onCommit(List<? extends IndexCommit> commits) {
// Note that commits.size() should normally be 2 (if not
// called by onInit above):
for(IndexCommit commit : commits) {
Expand Down
19 changes: 10 additions & 9 deletions perf/LineFileDocs.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

// FIELDS_HEADER_INDICATOR### title timestamp text username characterCount categories imageCount sectionCount subSectionCount subSubSectionCount refCount

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.FileInputStream;
Expand All @@ -31,21 +30,24 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.atomic.AtomicLong;

import org.apache.lucene.document.*;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.IntField;
import org.apache.lucene.document.LongField;
import org.apache.lucene.document.SortedDocValuesField;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.facet.FacetField;
import org.apache.lucene.facet.FacetsConfig;
import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
import org.apache.lucene.index.FieldInfo.IndexOptions;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.IndexDocument;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.util.BytesRef;
Expand Down Expand Up @@ -125,7 +127,8 @@ private void open() throws IOException {
}
}

public synchronized void close() throws IOException {
@Override
public synchronized void close() throws IOException {
if (reader != null) {
reader.close();
reader = null;
Expand Down Expand Up @@ -280,8 +283,6 @@ static Document cloneDoc(Document doc1) {
return doc2;
}

private final ThreadLocal<DocState> threadDocs = new ThreadLocal<DocState>();

private int readCount;

//private final Random rand = new Random(17);
Expand Down
3 changes: 1 addition & 2 deletions perf/NRTPerfTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.PostingsFormat;
import org.apache.lucene.codecs.lucene46.Lucene46Codec;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.AtomicReader;
import org.apache.lucene.index.ConcurrentMergeScheduler;
import org.apache.lucene.index.DirectoryReader;
Expand Down Expand Up @@ -65,7 +64,7 @@

public class NRTPerfTest {

private static boolean NEW_INDEX = false;
static final boolean NEW_INDEX = false;

// TODO: share w/ SearchPerfTest
private static IndexCommit findCommitPoint(String commit, Directory dir) throws IOException {
Expand Down
Loading

0 comments on commit 65ea4a2

Please sign in to comment.