亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
国产成人av网站| 午夜国产精品影院在线观看| 国产精品一线二线三线| 欧美精品一区二区三区很污很色的| 美女一区二区视频| 亚洲精品在线免费播放| 国产精品亚洲视频| 亚洲欧洲av另类| 欧美亚州韩日在线看免费版国语版| 亚洲一区二区三区四区在线免费观看| 在线精品视频免费播放| 调教+趴+乳夹+国产+精品| 日韩一区二区三区精品视频| 国产白丝精品91爽爽久久| 一区二区三区视频在线看| 欧美美女视频在线观看| 经典三级在线一区| 亚洲老妇xxxxxx| 精品国产乱码久久久久久老虎| 国产不卡视频在线观看| 亚洲二区视频在线| 国产性天天综合网| 在线观看免费成人| 国产福利不卡视频| 亚洲国产一区二区三区青草影视| 日韩欧美综合在线| 99久久精品免费| 免费高清在线视频一区·| 国产女人aaa级久久久级 | 玉米视频成人免费看| 777奇米成人网| 成人美女视频在线观看| 午夜成人免费电影| 亚洲天堂中文字幕| 精品成人私密视频| 91小宝寻花一区二区三区| 麻豆成人免费电影| 亚洲精选免费视频| 国产亚洲一本大道中文在线| 欧美日韩一区二区三区免费看| 国产精品 欧美精品| 五月婷婷久久综合| 中文字幕在线不卡一区| 精品福利一二区| 91精品国产综合久久久久久久久久| 成人国产免费视频| 精品一区二区三区的国产在线播放| 亚洲精品视频在线观看网站| 久久久高清一区二区三区| 欧美乱妇一区二区三区不卡视频 | 91视视频在线观看入口直接观看www | 欧洲一区在线电影| 成人综合激情网| 久久99国产精品免费网站| 亚洲美女电影在线| 国产精品久久久久永久免费观看| 精品久久久久99| 欧美一区二区三区视频在线 | 成人免费毛片aaaaa**| 免费高清成人在线| 日韩中文字幕区一区有砖一区| 自拍偷拍欧美激情| 国产精品护士白丝一区av| 日本一区二区三区免费乱视频| 久久嫩草精品久久久精品一| 日韩美女主播在线视频一区二区三区| 欧洲国产伦久久久久久久| 91免费观看在线| 97久久超碰精品国产| 91亚洲男人天堂| 一本大道久久a久久精品综合| aaa欧美色吧激情视频| a在线播放不卡| av在线这里只有精品| 99麻豆久久久国产精品免费| 成人黄色片在线观看| 福利一区福利二区| kk眼镜猥琐国模调教系列一区二区| 成人免费观看视频| 99精品欧美一区二区三区小说| 99国产精品久久久久久久久久 | 中文字幕一区在线观看视频| 国产精品国产三级国产aⅴ无密码| 中文字幕成人在线观看| 欧美国产日韩亚洲一区| 亚洲国产精品精华液2区45| 国产精品传媒入口麻豆| 亚洲日本乱码在线观看| 亚洲一区二区视频在线| 午夜不卡在线视频| 国产资源精品在线观看| 成人午夜精品在线| 色美美综合视频| 日韩丝袜情趣美女图片| 欧美精品一区二区蜜臀亚洲| 欧美国产成人在线| 亚洲国产一区二区a毛片| 青椒成人免费视频| 国产xxx精品视频大全| 91国模大尺度私拍在线视频 | 日韩无一区二区| 日本一区二区视频在线观看| 亚洲欧美日韩一区二区| 午夜视黄欧洲亚洲| 国产精品99久久久久久似苏梦涵| 91色视频在线| 91精品国产乱码久久蜜臀| 欧美高清一级片在线观看| 一区二区三区 在线观看视频| 毛片av一区二区| 不卡在线观看av| 日韩一区二区三区在线| 欧美国产欧美综合| 日韩黄色在线观看| voyeur盗摄精品| 欧美v亚洲v综合ⅴ国产v| 国产精品久久久久婷婷二区次| 婷婷综合久久一区二区三区| 国产剧情一区二区| 欧美精品日韩一本| 欧美激情中文不卡| 免费成人在线视频观看| 91热门视频在线观看| 欧美xxxx在线观看| 亚洲成a人片综合在线| 丁香六月久久综合狠狠色| 欧美三级电影一区| 国产精品蜜臀在线观看| 麻豆成人久久精品二区三区红| 99国产欧美久久久精品| 精品国产乱码久久久久久闺蜜| 亚洲精品免费视频| 成人在线综合网站| 日韩欧美中文字幕一区| 一区二区三区在线观看动漫| 国产激情一区二区三区四区| 欧美二区三区的天堂| 亚洲精品欧美专区| 成人免费毛片aaaaa**| 久久综合久久综合九色| 日韩主播视频在线| 色天天综合色天天久久| 国产精品午夜久久| 韩国女主播成人在线观看| 欧美精品一级二级三级| 一区二区三区在线免费| 不卡视频免费播放| 国产情人综合久久777777| 美女尤物国产一区| 日韩一级片网站| 日韩专区在线视频| 欧美精品久久一区| 亚洲一区二区三区四区在线| 色呦呦网站一区| 自拍偷拍欧美精品| 91在线视频观看| 成人欧美一区二区三区白人| 国产suv精品一区二区6| 久久久亚洲综合| 国产精品综合在线视频| 久久综合999| 国产乱淫av一区二区三区| 久久久噜噜噜久噜久久综合| 国产麻豆欧美日韩一区| 26uuuu精品一区二区| 国内久久精品视频| 欧美精品一区二区三| 国产高清久久久久| 欧美国产成人精品| 成人黄页在线观看| 亚洲欧美日韩系列| 欧美综合一区二区三区| 亚洲国产精品欧美一二99| 欧美日韩免费观看一区二区三区| 亚洲成人先锋电影| 在线观看91av| 奇米精品一区二区三区四区| 在线不卡欧美精品一区二区三区| 青青草91视频| 国产欧美一区视频| 成人白浆超碰人人人人| 自拍视频在线观看一区二区| 在线免费观看一区| 亚洲成a人在线观看| 欧美一区二区高清| 国产精品99久久久久久宅男| 国产精品国产自产拍高清av| 欧美性色黄大片手机版| 日本不卡一二三区黄网| 久久精品免视看| 日本精品一级二级| 五月婷婷激情综合| 久久久亚洲精华液精华液精华液| 国产91精品一区二区麻豆网站 | 亚洲丝袜自拍清纯另类| 欧美午夜影院一区| 老司机精品视频一区二区三区| 久久精品免视看| 欧美日韩激情一区| 福利电影一区二区三区|