Java tutorial
/* * Copyright (c) 2011 Twitlinks * * Licensed 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. * */ package com.twitlinks; import java.io.IOException; import java.text.ParseException; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.twitlinks.indexer.Buffer; import com.twitlinks.indexer.Indexer; import com.twitlinks.indexer.SimpleSearcher; import com.twitlinks.parser.Parser; public class Main { /** * @param args * @throws ParseException * @throws org.apache.lucene.queryParser.ParseException * @throws IOException * @throws InterruptedException */ public static void main(String[] args) throws ParseException, IOException, org.apache.lucene.queryParser.ParseException, InterruptedException { Log log = LogFactory.getLog(Main.class); Parser parser = new Parser(true, "dataset_2m"); parser.start(); Indexer indexer = new Indexer(); indexer.start(); while (true) { try { Thread.sleep(2000); log.info(parser.getLinesRead() + ":" + indexer.docCount + ":" + Buffer.documentQueue.size()); } catch (InterruptedException e) { e.printStackTrace(); } if (!parser.isAlive() && Buffer.documentQueue.size() == 0) { log.info(parser.getLinesRead() + ":" + indexer.docCount + ":" + Buffer.documentQueue.size()); indexer.stopIndexing(); break; } } //Test the simple search, current text:fantastic SimpleSearcher searcher = new SimpleSearcher(); searcher.searcher(); } }