新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
手把手教你寫網(wǎng)絡(luò)爬蟲(7):URL去重
本系列:

創(chuàng)新互聯(lián)是一家專注于成都做網(wǎng)站、網(wǎng)站制作、成都外貿(mào)網(wǎng)站建設(shè)和雅安移動機(jī)房的網(wǎng)絡(luò)公司,有著豐富的建站經(jīng)驗和案例。
- 《手把手教你寫網(wǎng)絡(luò)爬蟲(1):網(wǎng)易云音樂歌單》
- 《手把手教你寫網(wǎng)絡(luò)爬蟲(2):迷你爬蟲架構(gòu)》
- 《手把手教你寫網(wǎng)絡(luò)爬蟲(3):開源爬蟲框架對比》
- 《手把手教你寫網(wǎng)絡(luò)爬蟲(4):Scrapy入門》
- 《手把手教你寫網(wǎng)絡(luò)爬蟲(5):PhantomJS實戰(zhàn)》
- 《手把手教你寫網(wǎng)絡(luò)爬蟲(6):分布式爬蟲》
IPv6編碼地址數(shù):2^128(約3.4×10^38)
IPv6是IETF設(shè)計的用于替代現(xiàn)行版本IP協(xié)議(IPv4)的下一代IP協(xié)議,號稱可以為全世界的每一粒沙子編上一個網(wǎng)址。
- public
boolean put(T object, Funnel super T> funnel, int numHashFunctions, BitArray bits) { - long bitSize = bits.bitSize();
- long hash64 = Hashing.murmur3_128().hashObject(object, funnel).asLong();
- int hash1 = (int) hash64;
- int hash2 = (int) (hash64 >>> 32);
- boolean bitsChanged = false;
- for (int i = 1; i <= numHashFunctions; i++) {
- int combinedHash = hash1 + (i * hash2);
- // Flip all the bits if it's negative (guaranteed positive number)
- if (combinedHash < 0) {
- combinedHash = ~combinedHash;
- }
- bitsChanged |= bits.set(combinedHash % bitSize);
- }
- return bitsChanged;
- }
- boolean set(long index) {
- if (!get(index)) {
- data[(int) (index >>> 6)] |= (1L << index);
- bitCount++;
- return true;
- }
- return false;
- }
- boolean get(long index) {
- return (data[(int) (index >>> 6)] & (1L << index)) != 0;
- }
02 先get()一下,看看是不是已經(jīng)置為1。
03 index右移6位就是除以64,說明data是long型的數(shù)組,除以64就定位到了bit所在的數(shù)組下標(biāo)。1L左移index位,定位到了bit在long中的位置。
當(dāng)前名稱:手把手教你寫網(wǎng)絡(luò)爬蟲(7):URL去重
分享網(wǎng)址:http://fisionsoft.com.cn/article/djcchjp.html


咨詢
建站咨詢
