01: package org.apache.lucene.benchmark.byTask.feeds;
02:
03: /**
04: * Licensed to the Apache Software Foundation (ASF) under one or more
05: * contributor license agreements. See the NOTICE file distributed with
06: * this work for additional information regarding copyright ownership.
07: * The ASF licenses this file to You under the Apache License, Version 2.0
08: * (the "License"); you may not use this file except in compliance with
09: * the License. You may obtain a copy of the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS,
15: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: * See the License for the specific language governing permissions and
17: * limitations under the License.
18: */
19:
20: /**
21: * Create documents for the test.
22: */
23: public class SimpleDocMaker extends BasicDocMaker {
24:
25: private int docID = 0;
26:
27: static final String DOC_TEXT = "Well, this is just some plain text we use for creating the "
28: + "test documents. It used to be a text from an online collection "
29: + "devoted to first aid, but if there was there an (online) lawyers "
30: + "first aid collection with legal advices, \"it\" might have quite "
31: + "probably advised one not to include \"it\"'s text or the text of "
32: + "any other online collection in one's code, unless one has money "
33: + "that one don't need and one is happy to donate for lawyers "
34: + "charity. Anyhow at some point, rechecking the usage of this text, "
35: + "it became uncertain that this text is free to use, because "
36: + "the web site in the disclaimer of he eBook containing that text "
37: + "was not responding anymore, and at the same time, in projGut, "
38: + "searching for first aid no longer found that eBook as well. "
39: + "So here we are, with a perhaps much less interesting "
40: + "text for the test, but oh much much safer. ";
41:
42: // return a new docid
43: private synchronized int newdocid() throws NoMoreDataException {
44: if (docID > 0 && !forever) {
45: throw new NoMoreDataException();
46: }
47: return docID++;
48: }
49:
50: /*
51: * (non-Javadoc)
52: * @see DocMaker#resetIinputs()
53: */
54: public synchronized void resetInputs() {
55: super .resetInputs();
56: docID = 0;
57: }
58:
59: /*
60: * (non-Javadoc)
61: * @see DocMaker#numUniqueTexts()
62: */
63: public int numUniqueTexts() {
64: return 0; // not applicable
65: }
66:
67: protected DocData getNextDocData() throws NoMoreDataException {
68: int id = newdocid();
69: addBytes(DOC_TEXT.length());
70: return new DocData("doc" + id, DOC_TEXT, null, null, null);
71: }
72:
73: }
|