|
Lucene example source code file (DirContentSource.java)
The Lucene DirContentSource.java source code
package org.apache.lucene.benchmark.byTask.feeds;
/**
* 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 org.apache.lucene.benchmark.byTask.utils.Config;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileFilter;
import java.io.FileReader;
import java.io.IOException;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.Locale;
import java.util.Stack;
/**
* A {@link ContentSource} using the Dir collection for its input. Supports
* the following configuration parameters (on top of {@link ContentSource}):
* <ul>
* <li>work.dir - specifies the working directory. Required if "docs.dir"
* denotes a relative path (<b>default=work).
* <li>docs.dir - specifies the directory the Dir collection. Can be set
* to a relative path if "work.dir" is also specified (<b>default=dir-out).
* </ul>
*/
public class DirContentSource extends ContentSource {
private static final class DateFormatInfo {
DateFormat df;
ParsePosition pos;
}
public static class Iterator implements java.util.Iterator<File> {
static class Comparator implements java.util.Comparator<File> {
public int compare(File _a, File _b) {
String a = _a.toString();
String b = _b.toString();
int diff = a.length() - b.length();
if (diff > 0) {
while (diff-- > 0) {
b = "0" + b;
}
} else if (diff < 0) {
diff = -diff;
while (diff-- > 0) {
a = "0" + a;
}
}
/* note it's reversed because we're going to push,
which reverses again */
return b.compareTo(a);
}
}
int count = 0;
Stack<File> stack = new Stack
Other Lucene examples (source code examples)Here is a short list of links related to this Lucene DirContentSource.java source code file: |
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.