亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? dbsearchindexer.java

?? 這是學習Java必須讀懂兩套源代碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/**
 * Copyright (C) 2001 Yasna.com. All rights reserved.
 *
 * ===================================================================
 * The Apache Software License, Version 1.1
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by
 *        Yasna.com (http://www.yasna.com)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Yazd" and "Yasna.com" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please
 *    contact yazd@yasna.com.
 *
 * 5. Products derived from this software may not be called "Yazd",
 *    nor may "Yazd" appear in their name, without prior written
 *    permission of Yasna.com.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL YASNA.COM OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of Yasna.com. For more information
 * on Yasna.com, please see <http://www.yasna.com>.
 */

/**
 * Copyright (C) 2000 CoolServlets.com. All rights reserved.
 *
 * ===================================================================
 * The Apache Software License, Version 1.1
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by
 *        CoolServlets.com (http://www.coolservlets.com)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Jive" and "CoolServlets.com" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please
 *    contact webmaster@coolservlets.com.
 *
 * 5. Products derived from this software may not be called "Jive",
 *    nor may "Jive" appear in their name, without prior written
 *    permission of CoolServlets.com.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL COOLSERVLETS.COM OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CoolServlets.com. For more information
 * on CoolServlets.com, please see <http://www.coolservlets.com>.
 */

package com.Yasna.forum.database;

import java.sql.*;
import java.util.*;
import java.io.*;

import com.lucene.document.*;
import com.lucene.analysis.*;
import com.lucene.analysis.standard.*;
import com.lucene.index.*;
import com.lucene.store.*;

import com.Yasna.forum.*;
import com.Yasna.util.*;

/**
 * Database implementation of SearchIndexer using the Lucene search package.
 *
 * Search indexes are stored in the "search" subdirectory of directory pointed to
 * by the Yazd property "yazdHome".
 */
public class DbSearchIndexer extends Thread implements SearchIndexer{

    /** DATABASE QUERIES **/
    //private static final String MESSAGES_BEFORE_DATE =
    //  "SELECT messageID FROM yazdMessage WHERE modifiedDate < ?";
    private static final String MESSAGES_BEFORE_DATE =
        "SELECT messageID, userID, yazdMessage.threadID, forumID, " +
        "subject, body, yazdMessage.creationDate " +
        "FROM yazdMessage, yazdThread WHERE yazdMessage.threadID=yazdThread.threadID " +
        "AND yazdMessage.modifiedDate < ?";
    private static final String MESSAGES_BEFORE_DATE_COUNT =
        "SELECT count(messageID) FROM yazdMessage WHERE modifiedDate < ?";
    private static final String MESSAGES_SINCE_DATE =
        "SELECT messageID FROM yazdMessage WHERE modifiedDate > ? " +
        "AND modifiedDate < ?";
    private static final String MESSAGES_SINCE_DATE_COUNT =
        "SELECT count(messageID) FROM yazdMessage WHERE modifiedDate > ? " +
        "AND modifiedDate < ?";
    private static final String LOAD_MESSAGE =
        "SELECT subject, body, userID, yazdMessage.threadID, forumID, " +
        "yazdMessage.creationDate FROM yazdMessage, yazdThread WHERE " +
        "yazdMessage.threadID=yazdThread.threadID AND yazdMessage.messageID=?";

    /**
     * Path to where index is stored.
     */
    private static String indexPath = null;

    /**
     * Time constants (in milleseconds)
     */
    private static final long MINUTE = 1000 * 60;
    private static final long HOUR = MINUTE * 60;

    /**
     * Maintains the amount of time that should elapse until the next index.
     */
    private long updateInterval;

    /**
     * Maintains the time that the last index took place.
     */
    private long lastIndexed;

    /**
     * Indicates whether auto-indexing should be on or off. When on, an update
     * will be run at the "updateInterval".
     */
    private boolean autoIndex = true;

    /**
     * ForumFactory so that we can load message objects based on their ID.
     */
    private DbForumFactory factory;

    /**
     * Lock so that only one indexing function can be executed at once. Not
     * locking could impact the database integrity. Therefore, in a cluster of
     * Yazd servers all pointed at the same db, only one indexer should be
     * running once.
     */
    private Object indexLock = new Object();

    private static Analyzer analyzer = new StopAnalyzer();

    /**
     * Creates a new DbSearchIndexer. It attempts to load properties for
     * the update interval and when the last index occured from the Yazd 
     * properties then starts the indexing thread.
     */
    public DbSearchIndexer(DbForumFactory factory) {
        this.factory = factory;

        //Default to performing updates ever 10 minutes.
        updateInterval = 10 * MINUTE;
        //If the update interval property exists, use that
        String updInterval = PropertyManager.getProperty("DbSearchIndexer.updateInterval");
        try {
            updateInterval = Long.parseLong(updInterval);
        }
        catch (Exception e) { /* ignore */ }

        //Attempt to get the last updated time from the Yazd properties
        String lastInd = PropertyManager.getProperty("DbSearchIndexer.lastIndexed");
        try {
            lastIndexed = Long.parseLong(lastInd);
        }
        catch (Exception e) {
            //Something went wrong. Therefore, set lastIndexed far into the past
            //so that we'll do a full index.
            lastIndexed = 0;
        }
        //Make this a daemon thread.
        this.setDaemon(true);
        //Start the indexing thread.
        start();
    }

    public int getHoursUpdateInterval() {
        return (int)(updateInterval / HOUR);
    }

    public int getMinutesUpdateInterval() {
        return (int)((updateInterval - getHoursUpdateInterval()*HOUR) / MINUTE);
    }

    public void setUpdateInterval(int minutes, int hours) {
        updateInterval = (minutes * MINUTE) + (hours * HOUR);
        //Save it to the properties
        PropertyManager.setProperty("DbSearchIndexer.updateInterval", ""+updateInterval);
    }

    public java.util.Date getLastIndexedDate() {
        return new java.util.Date(lastIndexed);
    }

    public boolean isAutoIndexEnabled() {
        return autoIndex;
    }

    public void setAutoIndexEnabled(boolean value) {
        autoIndex = value;
    }

    public void addToIndex(ForumMessage message) {
        //acquire the index lock so that no other indexing operations
        //are performed.
        synchronized (indexLock) {
            IndexWriter writer = null;
            try {
                writer = getWriter(false);
                addMessageToIndex(writer, message.getID(),
                    message.getUnfilteredSubject(), message.getUnfilteredBody(),
                    message.getUser().getID(), message.getForumThread().getID(),
                    message.getForumThread().getForum().getID(),
                    message.getCreationDate()
                );
            }
            catch (IOException ioe) {
                ioe.printStackTrace();
            }
            finally{
                try { writer.close(); }
                catch (Exception e) { }
            }
        }
    }

    public void removeFromIndex(ForumMessage message) {
        //acquire the index lock so that no other indexing operations
        //are performed.
        synchronized (indexLock) {
            try {
                int [] toDelete = new int [] { message.getID() };
                deleteMessagesFromIndex(toDelete);
            }
            catch (IOException ioe) {
                ioe.printStackTrace();
            }
        }
    }

    public void updateIndex() {
        //acquire the index lock so that no other indexing operations
        //are performed.
        synchronized (indexLock) {
            long now = System.currentTimeMillis();
            updateIndex(lastIndexed, now);
            lastIndexed = now;
            //Save the time as a Yazd property.
            PropertyManager.setProperty("DbSearchIndexer.lastIndexed",
                "" + lastIndexed);
        }
    }

    public void rebuildIndex() {
        //acquire the index lock so that no other indexing operations
        //are performed.
        synchronized (indexLock) {
            long now = System.currentTimeMillis();
            rebuildIndex(now);
            lastIndexed = now;
            //Save the time as a Yazd property.
            PropertyManager.setProperty("DbSearchIndexer.lastIndexed",
                "" + lastIndexed);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美性一二三区| 无吗不卡中文字幕| 久久精品国产精品亚洲红杏| 99久久婷婷国产综合精品| 欧美一区二区三区日韩| 亚洲精品自拍动漫在线| 国产91露脸合集magnet| 精品日韩在线一区| 午夜精品久久久久久久99樱桃| 色综合天天做天天爱| 久久久99精品免费观看不卡| 欧美aaaaaa午夜精品| 欧美日韩精品高清| 亚洲成人av一区| 91福利精品视频| 一区二区视频在线| av成人老司机| 一区二区欧美视频| 在线亚洲免费视频| 亚洲图片有声小说| 中文字幕欧美日韩一区| 激情久久五月天| 精品裸体舞一区二区三区| 久久99精品国产麻豆婷婷 | 欧美一卡2卡三卡4卡5免费| 亚洲一区二区黄色| 538prom精品视频线放| 日本vs亚洲vs韩国一区三区| 制服丝袜在线91| 国产乱人伦偷精品视频不卡| 国产精品入口麻豆原神| 99re6这里只有精品视频在线观看| 国产精品久久国产精麻豆99网站| 波多野结衣在线aⅴ中文字幕不卡| 国产精品久久久久三级| 在线观看国产一区二区| 亚洲www啪成人一区二区麻豆| 在线播放91灌醉迷j高跟美女| 蜜桃视频一区二区三区| 日本一区二区视频在线| 在线观看亚洲a| 精品一区二区免费在线观看| 久久久久久久网| 91黄色免费看| 国产乱理伦片在线观看夜一区| 亚洲日本在线观看| 欧美肥大bbwbbw高潮| aaa国产一区| 成人一区在线看| 国产女主播在线一区二区| 91首页免费视频| 精品一区二区三区影院在线午夜| 国产精品美女久久久久av爽李琼| 欧美日韩一本到| 成人免费视频国产在线观看| 日精品一区二区| 亚洲素人一区二区| 国产亚洲1区2区3区| 欧美日韩视频在线第一区| 成人av电影在线观看| 精品制服美女丁香| 亚洲国产毛片aaaaa无费看| 欧美韩国日本综合| 日韩欧美亚洲一区二区| 欧美视频在线一区二区三区 | 亚洲伦理在线免费看| 久久综合久久鬼色中文字| 欧美视频在线一区二区三区| 91丨porny丨国产| 91亚洲精品乱码久久久久久蜜桃| 久久激情五月激情| 日本三级亚洲精品| 视频一区二区三区在线| 亚洲电影你懂得| 亚洲成av人片在线| 亚洲一二三区不卡| 亚洲国产sm捆绑调教视频| 亚洲精品视频在线看| 亚洲靠逼com| 亚洲老妇xxxxxx| 偷拍与自拍一区| 美女www一区二区| 精品亚洲国内自在自线福利| 国产一区二区伦理| 成人福利视频在线| 97精品电影院| 欧美日韩免费在线视频| 91精品国产高清一区二区三区| 欧美一区二视频| 久久久久九九视频| 亚洲同性gay激情无套| 一区二区三区美女视频| 日韩av电影免费观看高清完整版| 麻豆传媒一区二区三区| 国产精品一区二区三区乱码| 91一区二区三区在线观看| 欧美日韩黄色一区二区| 精品国产三级电影在线观看| 国产精品久久久久一区二区三区共 | 日本精品裸体写真集在线观看| 欧美日韩亚洲高清一区二区| 欧美经典一区二区| 在线不卡a资源高清| 日韩欧美在线一区二区三区| 久久久99精品久久| 亚洲国产另类精品专区| 国产99久久久国产精品潘金| 欧美日韩午夜精品| 国产精品国产三级国产a| 亚州成人在线电影| 成人爱爱电影网址| 91麻豆精品国产91久久久使用方法 | 国产一区在线观看视频| 色悠悠久久综合| 国产精品视频你懂的| 麻豆精品久久久| 欧美精品自拍偷拍| 中文字幕一区在线观看| 国产一区二区三区免费在线观看| 欧美色视频一区| 国产精品欧美一级免费| 国产人久久人人人人爽| 日本91福利区| 欧美中文字幕一二三区视频| 国产精品人妖ts系列视频| 国产在线精品一区二区夜色| 在线成人午夜影院| 天天综合色天天| 91成人免费在线视频| 一个色妞综合视频在线观看| 成人av网站在线观看免费| 久久久久国产精品免费免费搜索| 精品无码三级在线观看视频| 欧美一区二区三区人| 免费成人美女在线观看| 日韩欧美在线网站| 免费高清视频精品| 精品国产sm最大网站| 精品一区二区三区在线观看国产| 欧美一区二区黄| 精品亚洲aⅴ乱码一区二区三区| 日韩免费视频一区| 国产成a人无v码亚洲福利| 欧美激情在线看| 天堂一区二区在线免费观看| 91麻豆精品国产91久久久久久久久 | 蜜桃av噜噜一区| 精品国产sm最大网站免费看| 国产盗摄一区二区三区| 亚洲精品videosex极品| 91精品欧美一区二区三区综合在| 久久国产精品99久久人人澡| 国产女主播视频一区二区| 色综合视频一区二区三区高清| 亚洲乱码日产精品bd| 91精品婷婷国产综合久久性色| 看片网站欧美日韩| 亚洲免费观看高清完整版在线| 欧美精品乱人伦久久久久久| 国产一区中文字幕| 午夜欧美在线一二页| 91成人网在线| 日韩国产高清影视| 国产亚洲欧美一区在线观看| 色综合天天综合网国产成人综合天| 亚洲成人一区在线| 国产丝袜在线精品| 欧美高清一级片在线| 成人综合婷婷国产精品久久蜜臀| 91精彩视频在线观看| 亚洲一区视频在线| 日韩亚洲国产中文字幕欧美| 91片在线免费观看| 久久国产精品72免费观看| 亚洲精品v日韩精品| 国产视频一区二区在线| 91麻豆精品国产自产在线| 91在线观看美女| 丁香激情综合五月| 国内精品伊人久久久久av影院| 亚洲亚洲精品在线观看| 国产精品私人自拍| 久久精品视频网| 精品国产91久久久久久久妲己 | 日韩亚洲国产中文字幕欧美| 色国产综合视频| 色一情一伦一子一伦一区| 成人小视频免费观看| 国产成人亚洲精品狼色在线| 精品一区二区精品| 久久国内精品自在自线400部| 亚洲一区中文在线| 一区二区免费在线播放| 亚洲午夜影视影院在线观看| 亚洲男女一区二区三区| 亚洲人成精品久久久久| 亚洲欧美日韩在线不卡| 尤物av一区二区| 亚洲一区二区三区四区五区黄 | 在线视频一区二区三区|