當前位置: 首頁>>代碼示例>>Python>>正文


Python ScalableBloomFilter.fromfile方法代碼示例

本文整理匯總了Python中pybloom.ScalableBloomFilter.fromfile方法的典型用法代碼示例。如果您正苦於以下問題:Python ScalableBloomFilter.fromfile方法的具體用法?Python ScalableBloomFilter.fromfile怎麽用?Python ScalableBloomFilter.fromfile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pybloom.ScalableBloomFilter的用法示例。


在下文中一共展示了ScalableBloomFilter.fromfile方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from pybloom import ScalableBloomFilter [as 別名]
# 或者: from pybloom.ScalableBloomFilter import fromfile [as 別名]
  def __init__(self,filterfile):
    self.filterfile = filterfile
	  #if filterfile is present load bloom filter from that file, else create new one
    if os.path.exists(filterfile):
      self.bf = ScalableBloomFilter.fromfile(open(filterfile,"rb"))
      print "available signatures = %d"%len(self.bf)
    else:
      self.bf = ScalableBloomFilter(mode=ScalableBloomFilter.SMALL_SET_GROWTH)
開發者ID:FireAVR,項目名稱:BloomAutoYara,代碼行數:10,代碼來源:BloomAutoYara.py

示例2: _load_from_file

# 需要導入模塊: from pybloom import ScalableBloomFilter [as 別名]
# 或者: from pybloom.ScalableBloomFilter import fromfile [as 別名]
 def _load_from_file(self):
   self.logger_.info('loading data from cache file...')
   if not os.path.isfile('data/bloom.data'):
     self.logger_.error('bloom cache file not found, create one instead.')
     self.deduper_ = ScalableBloomFilter(100000, 0.0001, 4)
   else:
     with open('data/bloom.data', 'r') as f:
       self.deduper_ = ScalableBloomFilter.fromfile(f)
開發者ID:cfhb,項目名稱:crawl_youtube,代碼行數:10,代碼來源:url_filter_service.py

示例3: load

# 需要導入模塊: from pybloom import ScalableBloomFilter [as 別名]
# 或者: from pybloom.ScalableBloomFilter import fromfile [as 別名]
    def load(cls, filename):
        #import pdb; pdb.set_trace()
        t = cls.transformer
        size = t.size
        with open(filename, "rb") as serialized_digest:
            readdata = serialized_digest.read(size)
            if len(readdata) != size:
                msg = 'invalid amount read from file for format %r: %r (should have been %d)'
                Logger("digest.load").log(msg % (t.format, readdata, size))
                raise ValueError
            nonce, maxcapacity, urlcount, meta = t.unpack(readdata)

            # If meta has a conversion from string repr, use it.
            if hasattr(self, 'meta_from_string'):
                meta = self.meta_from_string()
            filterS = ScalableBloomFilter.fromfile(serialized_digest)
        digest = cls(maxcapacity, meta, filename, filterS=filterS, nonce=nonce)
        digest.urlcount = urlcount
        return digest
開發者ID:F3DS,項目名稱:f3ds,代碼行數:21,代碼來源:digest.py

示例4: load

# 需要導入模塊: from pybloom import ScalableBloomFilter [as 別名]
# 或者: from pybloom.ScalableBloomFilter import fromfile [as 別名]
    def load(cls, filename):
        """
        This overrides the base class method to unpack using the siginfo.
        """
        #import pdb; pdb.set_trace()
        t = cls.transformer
        size = t.size
        with open(filename, "rb") as serialized_digest:
            readdata = serialized_digest.read(size)
            if len(readdata) != size:
                msg = 'invalid amount read from file for format %r: %r (should have been %d)'
                Logger("scandigest.load").log(msg % (t.format, readdata, size))
                raise ValueError
            nonce, maxcapacity, urlcount, scannervv, sigversion, sigtimestamp = t.unpack(readdata)

            # Read the datetime as non-utc, since that's how we wrote it with mktime.
            siginfo = SigInfo(scannervv, sigversion,
                              datetime.datetime.fromtimestamp(sigtimestamp))
            filterS = ScalableBloomFilter.fromfile(serialized_digest)
        scandigest = cls(maxcapacity, siginfo, filename, filterS=filterS, nonce=nonce)
        scandigest.urlcount = urlcount
        return scandigest
開發者ID:F3DS,項目名稱:f3ds,代碼行數:24,代碼來源:scandigest.py

示例5: open

# 需要導入模塊: from pybloom import ScalableBloomFilter [as 別名]
# 或者: from pybloom.ScalableBloomFilter import fromfile [as 別名]
RECOGNIZED = [LOINC, SNOMED, RXNORM, ICD9, ICD10, CPT, CVX, UNITS_OF_MEASURE]

# Enumerating all the FHIR systems here would be a waste of time,
# so load them from the constructed json file.
VALUE_SETS = []
with open('./data/fhir/systems.json') as fhir_handle:
    RECOGNIZED += json.load(fhir_handle)
with open('./data/fhir/daf.json') as daf_handle:
    VALUE_SETS += json.load(daf_handle)
with open('./data/fhir/argo.json') as argo_handle:
    VALUE_SETS += json.load(argo_handle)

# Instantiate the bloom filter.
try:
    with open('./data/codes.bf', 'rb') as handle:
        BLOOM = ScalableBloomFilter.fromfile(handle)
except FileNotFoundError:
    # Generated filter not found, just instantiate an empty one.
    BLOOM = ScalableBloomFilter()


def validate_coding(coding):
    """ If the coding system is recognized, check the code.
    """
    if coding.get('system') not in RECOGNIZED:
        raise SystemNotRecognized(coding.get('system'))

    if not coding.get('code'):
        return False

    key = coding['system'] + '|' + coding['code']
開發者ID:sync-for-science,項目名稱:test-suite,代碼行數:33,代碼來源:systems.py


注:本文中的pybloom.ScalableBloomFilter.fromfile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。