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

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

?? webdbreader.java

?? 爬蟲數據的改進,并修正了一些bug
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/* Copyright (c) 2003 The Nutch Organization.  All rights reserved.   */
/* Use subject to the conditions in http://www.nutch.org/LICENSE.txt. */
package net.nutch.db;

import java.io.*;
import java.util.*;
import java.nio.channels.*;

import net.nutch.io.*;
import net.nutch.fs.*;
import net.nutch.util.*;
import net.nutch.pagedb.*;
import net.nutch.linkdb.*;

/**********************************************
 * The WebDBReader implements all the read-only
 * parts of accessing our web database.
 * All the writing ones can be found in WebDBWriter.
 *
 * @author Mike Cafarella
 **********************************************/
public class WebDBReader implements IWebDBReader {
    static final Page[] PAGE_RECORDS = new Page[0];
    static final Link[] LINK_RECORDS = new Link[0];

    // filenames
    static final String PAGES_BY_URL = "pagesByURL";
    static final String PAGES_BY_MD5 = "pagesByMD5";
    static final String LINKS_BY_URL = "linksByURL";
    static final String LINKS_BY_MD5 = "linksByMD5";
    static final String STATS_FILE = "stats";

    NutchFileSystem nfs;
    File dbDir, dbFile;
    MapFile.Reader pagesByURL, pagesByMD5, linksByURL, linksByMD5;
    long totalPages = 0, totalLinks = 0;
    Vector mapReaders = null, setReaders = null;
    FileInputStream dbReadLockData;
    FileLock dbReadLock;

    /**
     * Open a web db reader for the named directory.
     */    
    public WebDBReader(NutchFileSystem nfs, File dbDir) throws IOException, FileNotFoundException {
        this.nfs = nfs;
        this.dbDir = dbDir;
        this.dbFile = new File(dbDir, "webdb");

        // Obtain read lock on db so writers don't try to 
        // move it out from under us.  This obtains a non-exclusive
        // lock on the directory that holds the dbs (old and new)
        nfs.lock(new File(dbDir, "dbreadlock"), true);

        this.pagesByURL = new MapFile.Reader(nfs, new File(dbFile, PAGES_BY_URL).getPath(), new UTF8.Comparator());
        this.pagesByMD5 = new MapFile.Reader(nfs, new File(dbFile, PAGES_BY_MD5).getPath(), new Page.Comparator());

        this.linksByURL = new MapFile.Reader(nfs, new File(dbFile, LINKS_BY_URL).getPath(), new Link.UrlComparator());
        this.linksByMD5 = new MapFile.Reader(nfs, new File(dbFile, LINKS_BY_MD5).getPath(), new Link.MD5Comparator());

        // Load in statistics
        File stats = new File(dbFile, STATS_FILE);
        if (nfs.exists(stats)) {
            DataInputStream in = new DataInputStream(nfs.open(stats));
            try {
                int version = (byte) in.read();
                this.totalPages = in.readLong();
                this.totalLinks = in.readLong();
            } finally {
                in.close();
            }
        }

        // Create vectors so we can GC readers used by 
        // enum() calls.  We do this so we can have multiple
        // simultaneous enum users.  However, since we keep
        // a handle to each one, we're assuming that we don't
        // create too many before WebDBReader.close() is called.
        this.mapReaders = new Vector();
        this.setReaders = new Vector();
    }

    /**
     * Shutdown
     */
    public void close() throws IOException {
        pagesByURL.close();
        pagesByMD5.close();
        linksByURL.close();
        linksByMD5.close();

        for (Enumeration e = mapReaders.elements(); e.hasMoreElements(); ) {
            MapFile.Reader tmp = (MapFile.Reader) e.nextElement();
            tmp.close();
        }
        for (Enumeration e = setReaders.elements(); e.hasMoreElements(); ) {
            SetFile.Reader tmp = (SetFile.Reader) e.nextElement();
            tmp.close();
        }

        // release the lock
        nfs.release(new File(dbDir, "dbreadlock"));
    }

    /**
     * Get Page from the pagedb with the given URL
     */
    public Page getPage(String url) throws IOException {
        return (Page) pagesByURL.get(new UTF8(url), new Page());
    }

    /**
     * Get Pages from the pagedb according to their
     * content hash.
     */
    public Page[] getPages(MD5Hash md5) throws IOException {
        Vector records = new Vector(3);
        Page p = new Page();
        p.getMD5().set(md5);

        pagesByMD5.seek(p);
        while (pagesByMD5.next(p, NullWritable.get())) {
            if (p.getMD5().compareTo(md5) == 0) {
                records.add(p);
                p = new Page();
            } else {
                break;
            }
        }

        // Xfer from the vector into an array
        return (Page[]) records.toArray(PAGE_RECORDS);
    }

    /**
     * Test whether a certain piece of content is in the
     * database, but don't bother returning the Page(s) itself.
     */
    public boolean pageExists(MD5Hash md5) throws IOException {
        Page p = new Page();
        p.getMD5().set(md5);
        pagesByMD5.seek(p);
        if (pagesByMD5.next(p, NullWritable.get()) && p.getMD5().compareTo(md5) == 0) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * Iterate through all the Pages, sorted by URL
     */
    public Enumeration pages() throws IOException {
        MapFile.Reader tmpReader = new MapFile.Reader(nfs, new File(dbFile, "pagesByURL").getPath());
        mapReaders.add(tmpReader);
        return new TableEnumerator(tmpReader);
    }

    //
    // The TableEnumerator goes through all the entries
    // in the Table (which is a MapFile).
    //
    class TableEnumerator implements Enumeration {
        MapFile.Reader reader;
        Page nextItem;

        /**
         * Start the cursor and find the first item.
         * Store it for later return.
         */
        public TableEnumerator(MapFile.Reader reader) {
            this.reader = reader;
            this.nextItem = new Page();
            try {
                if (! reader.next(new UTF8(), this.nextItem)) {
                    this.nextItem = null;
                }
            } catch (IOException ie) {
                this.nextItem = null;
            }
        }

        /**
         * If there's no item left in store, we've hit the end.
         */
        public boolean hasMoreElements() {
            return (nextItem != null);
        }

        /**
         * Set aside the item we have in store.  Then retrieve
         * another for the next time we're called.  Finally, return
         * the set-aside item.
         */
        public Object nextElement() {
            if (nextItem == null) {
                throw new NoSuchElementException("PageDB Enumeration");
            }
            Page toReturn = nextItem;
            this.nextItem = new Page();
            try {
                if (! reader.next(new UTF8(), nextItem)) {
                    this.nextItem = null;
                }
            } catch (IOException ie) {
                this.nextItem = null;
            }
            return toReturn;
        }
    }


    /**
     * Iterate through all the Pages, sorted by MD5
     */
    public Enumeration pagesByMD5() throws IOException {
        SetFile.Reader tmpReader = new SetFile.Reader(nfs, new File(dbFile, "pagesByMD5").getPath());
        setReaders.add(tmpReader);
        return new IndexEnumerator(tmpReader);
    }

    /**
     * Return the number of pages we're dealing with
     */
    public long numPages() {
        return totalPages;
    }

    //
    // The IndexEnumerator goes through all the entries
    // in the index (which is a SequenceFile).
    //
    class IndexEnumerator implements Enumeration {
        SetFile.Reader reader;
        Page nextItem;

        /**
         * Start the cursor and find the first item.
         * Store it for later return.
         */
        public IndexEnumerator(SetFile.Reader reader) {
            this.reader = reader;
            this.nextItem = new Page();
            try {
                if (! reader.next(nextItem)) {
                    this.nextItem = null;
                }
            } catch (IOException ie) {
                this.nextItem = null;
            }
        }

        /**
         * If there's no item left in store, we've hit the end.
         */
        public boolean hasMoreElements() {
            return (nextItem != null);
        }

        /**
         * Set aside the item we have in store.  Then retrieve
         * another for the next time we're called.  Finally, return
         * the set-aside item.
         */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
69堂亚洲精品首页| 亚洲丝袜精品丝袜在线| 国产精品欧美一区喷水| 午夜久久久影院| 成人动漫一区二区三区| 欧美一三区三区四区免费在线看| 亚洲美女偷拍久久| 国产精品白丝jk黑袜喷水| 日韩一级二级三级| 亚洲无人区一区| 91香蕉视频在线| 国产精品视频第一区| 经典一区二区三区| 日韩三级免费观看| 视频一区欧美精品| 欧美日韩中文字幕精品| ...xxx性欧美| 日本电影欧美片| 国产精品国产三级国产aⅴ入口| 国产在线国偷精品免费看| 日韩免费高清视频| 国产精品久久久久久久久免费樱桃| 不卡av免费在线观看| 欧美成人精精品一区二区频| 婷婷综合另类小说色区| 色88888久久久久久影院按摩| 18欧美亚洲精品| 色综合久久综合中文综合网| 国产精品久久久久久久久免费丝袜| 国产一区亚洲一区| 日韩精品一区在线| 国产一区二三区好的| 欧美精品一区在线观看| 国产精品中文欧美| 国产精品日产欧美久久久久| 成人免费视频caoporn| 亚洲三级理论片| 欧美中文字幕一区二区三区亚洲 | 国产精品亚洲第一区在线暖暖韩国| 日韩一区二区三区在线| 久色婷婷小香蕉久久| 精品国一区二区三区| 国产一区二区视频在线| 国产精品视频一二三| 91麻豆国产自产在线观看| 亚洲精品网站在线观看| 精品视频一区二区三区免费| 日韩国产一区二| 欧美videos大乳护士334| 国产成人亚洲综合a∨猫咪| 国产精品久久久久四虎| 97aⅴ精品视频一二三区| 一区二区三区在线观看国产 | 日韩不卡免费视频| 精品久久久久久亚洲综合网| 成人国产精品视频| 亚洲va国产va欧美va观看| 欧美一区二区三区啪啪| 国产a区久久久| 亚洲一区在线观看视频| 精品国产成人系列| 91天堂素人约啪| 男人的j进女人的j一区| 国产色综合久久| 欧美午夜在线观看| 国产麻豆精品95视频| 亚洲黄色录像片| 日韩女优毛片在线| 色拍拍在线精品视频8848| 毛片av中文字幕一区二区| 亚洲欧洲一区二区在线播放| 91精品欧美一区二区三区综合在 | 亚洲已满18点击进入久久| 日韩精品一区二区三区三区免费| 成人av网站在线观看免费| 亚洲成人av电影| 久久国产剧场电影| 中文av字幕一区| 日本久久一区二区三区| 免费看欧美美女黄的网站| 自拍视频在线观看一区二区| 日韩亚洲国产中文字幕欧美| 日本福利一区二区| 白白色 亚洲乱淫| 毛片av一区二区三区| 亚洲地区一二三色| 亚洲色图欧美在线| 亚洲国产精品成人久久综合一区| 91精品在线一区二区| 波波电影院一区二区三区| 日韩国产一区二| 亚洲高清视频的网址| 国产精品私人影院| 久久综合九色综合97_久久久| 欧美日韩一级黄| 在线精品视频免费观看| av一区二区三区四区| 国产精品 日产精品 欧美精品| 蜜桃视频一区二区| 美女精品一区二区| 日本女优在线视频一区二区| 亚洲成a人v欧美综合天堂| 一色屋精品亚洲香蕉网站| 中文字幕av在线一区二区三区| 久久久久久久综合日本| www国产精品av| 26uuu亚洲婷婷狠狠天堂| 91精品国产91久久久久久一区二区| 欧美三级日韩在线| 欧美怡红院视频| 欧美日韩精品一区二区三区| 在线欧美日韩精品| 欧美三级中文字| 欧美日韩高清不卡| 在线91免费看| 4438亚洲最大| 精品国产凹凸成av人网站| 2017欧美狠狠色| 国产色爱av资源综合区| 中文字幕国产一区二区| 国产精品久久久久久久久动漫| 中文字幕日韩欧美一区二区三区| 国产精品久久久久aaaa樱花| 亚洲视频一二三| 亚洲电影在线播放| 日韩高清中文字幕一区| 理论电影国产精品| 国产麻豆一精品一av一免费| 波多野结衣亚洲一区| 欧美性受xxxx| 国产三级一区二区三区| 国产精品无遮挡| 一区二区三区电影在线播| 视频在线在亚洲| 久久不见久久见免费视频7| 国产精品亚洲第一区在线暖暖韩国| 成人一区在线看| 欧美天堂一区二区三区| 日韩一级片在线观看| 国产拍欧美日韩视频二区| 亚洲精品成人在线| 久久精品国产网站| 99久久精品国产网站| 欧美丰满美乳xxx高潮www| 久久久精品免费免费| 一区二区三区四区视频精品免费 | 欧美精品自拍偷拍| 久久人人97超碰com| 亚洲欧美一区二区三区国产精品 | 美女网站色91| jizz一区二区| 日韩丝袜美女视频| 亚洲欧美一区二区三区国产精品| 日本欧美在线观看| 91一区二区三区在线播放| 欧美成人精品3d动漫h| 亚洲欧美视频在线观看| 美女视频黄a大片欧美| 91麻豆国产在线观看| 欧美精品一区二区蜜臀亚洲| 一区二区视频免费在线观看| 国产在线精品一区二区三区不卡 | 国产成人午夜电影网| 色综合天天狠狠| 精品免费视频.| 亚洲视频一二区| 国产精品一品二品| 欧美日本国产一区| 国产精品乱码一区二三区小蝌蚪| 免费在线观看一区| 欧美性受极品xxxx喷水| 中文字幕av一区 二区| 热久久一区二区| 欧美吞精做爰啪啪高潮| 亚洲婷婷国产精品电影人久久| 国产一区二区三区在线看麻豆| 欧美二区三区91| 一区二区三区久久| 一本大道久久a久久综合婷婷| 久久久久久久久伊人| 美女免费视频一区二区| 欧美日韩aaa| 亚洲国产成人91porn| 91麻豆国产在线观看| 最新日韩av在线| gogogo免费视频观看亚洲一| 久久色在线视频| 精品亚洲aⅴ乱码一区二区三区| 欧美人动与zoxxxx乱| 亚洲h动漫在线| 欧美最新大片在线看| 亚洲老妇xxxxxx| 91国产免费看| 一区二区三区视频在线看| 91久久线看在观草草青青| 三级一区在线视频先锋| 欧美午夜一区二区三区| 亚洲午夜精品网| 欧美人妇做爰xxxⅹ性高电影| 五月天激情小说综合|