1 package org.apache.lucene.benchmark.byTask.feeds;
3 import java.io.IOException;
6 * Licensed to the Apache Software Foundation (ASF) under one or more
7 * contributor license agreements. See the NOTICE file distributed with
8 * this work for additional information regarding copyright ownership.
9 * The ASF licenses this file to You under the Apache License, Version 2.0
10 * (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
23 * Creates the same document each time {@link #getNextDocData(DocData)} is called.
25 public class SingleDocSource extends ContentSource {
27 private int docID = 0;
29 static final String DOC_TEXT =
30 "Well, this is just some plain text we use for creating the " +
31 "test documents. It used to be a text from an online collection " +
32 "devoted to first aid, but if there was there an (online) lawyers " +
33 "first aid collection with legal advices, \"it\" might have quite " +
34 "probably advised one not to include \"it\"'s text or the text of " +
35 "any other online collection in one's code, unless one has money " +
36 "that one don't need and one is happy to donate for lawyers " +
37 "charity. Anyhow at some point, rechecking the usage of this text, " +
38 "it became uncertain that this text is free to use, because " +
39 "the web site in the disclaimer of he eBook containing that text " +
40 "was not responding anymore, and at the same time, in projGut, " +
41 "searching for first aid no longer found that eBook as well. " +
42 "So here we are, with a perhaps much less interesting " +
43 "text for the test, but oh much much safer. ";
46 private synchronized int newdocid() throws NoMoreDataException {
47 if (docID > 0 && !forever) {
48 throw new NoMoreDataException();
54 public void close() throws IOException {}
57 public DocData getNextDocData(DocData docData) throws NoMoreDataException {
59 addBytes(DOC_TEXT.length());
61 docData.setName("doc" + id);
62 docData.setBody(DOC_TEXT);
67 public synchronized void resetInputs() throws IOException {