Exemplo n.º 1
0
 def resolve(self, state):
     '''Ensure filter code and blob argument are available in the blob
     cache, load the blob argument, and initialize the cache digest.'''
     if self.code_path is not None:
         return
     # Get path to filter code
     code_path, code_signature = self._resolve_code(state)
     # Get contents of blob argument
     blob, blob_signature = self._resolve_blob(state)
     # Initialize digest
     summary = ([code_signature, self.name] + self.arguments +
                [blob_signature])
     cache_digest = murmur(' '.join(summary))
     # Commit
     self.code_path = code_path
     self.signature = code_signature
     self.blob = blob
     self.cache_digest = cache_digest
Exemplo n.º 2
0
 def resolve(self, state):
     '''Ensure filter code and blob argument are available in the blob
     cache, load the blob argument, and initialize the cache digest.'''
     if self.code_path is not None:
         return
     # Get path to filter code
     code_path, code_signature = self._resolve_code(state)
     # Get contents of blob argument
     blob, blob_signature = self._resolve_blob(state)
     # Initialize digest
     summary = ([code_signature, self.name] + self.arguments +
             [blob_signature])
     cache_digest = murmur(' '.join(summary))
     # Commit
     self.code_path = code_path
     self.signature = code_signature
     self.blob = blob
     self.cache_digest = cache_digest
Exemplo n.º 3
0
 def get_cache_key(self, obj):
     '''Return the result cache lookup key for previous filter executions
     on this object.'''
     return 'result:' + murmur(self._get_cache_digest() + ' ' + str(obj))
Exemplo n.º 4
0
#
#  The OpenDiamond Platform for Interactive Search
#
#  Copyright (c) 2011 Carnegie Mellon University
#  All rights reserved.
#
#  This software is distributed under the terms of the Eclipse Public
#  License, Version 1.0 which can be found in the file named LICENSE.
#  ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
#  RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
#

'''Filter configuration and execution; result and attribute caching.

There are two caches, both accessible via key lookups in the same
Redis database.

Result cache:
    'result:' + murmur(
        ' '.join(
            murmur(
                ' '.join(
                    SHA256(filter code),
                    filter name,
                    ' '.join(filter arguments),
                    SHA256(filter blob argument),
                ),
            ),
            object ID
        )
    ) => JSON({
Exemplo n.º 5
0
 def __setitem__(self, key, value):
     self._attrs[key] = value
     self._signatures[key] = murmur(value)
Exemplo n.º 6
0
 def get_signature(rtype, *args, **kargs):
     return murmur(rtype + ''.join(map(str, args)) +
                   ''.join(map(str, kargs.keys())) +
                   ''.join(map(str, kargs.values())))
Exemplo n.º 7
0
 def get_cache_key(self, obj):
     '''Return the result cache lookup key for previous filter executions
     on this object.'''
     return 'result:' + murmur(self._get_cache_digest() + ' ' + str(obj))
Exemplo n.º 8
0
#
#  The OpenDiamond Platform for Interactive Search
#
#  Copyright (c) 2011 Carnegie Mellon University
#  All rights reserved.
#
#  This software is distributed under the terms of the Eclipse Public
#  License, Version 1.0 which can be found in the file named LICENSE.
#  ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS SOFTWARE CONSTITUTES
#  RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT
#

'''Filter configuration and execution; result and attribute caching.

There are two caches, both accessible via key lookups in the same
Redis database.

Result cache:
    'result:' + murmur(
        ' '.join(
            murmur(
                ' '.join(
                    SHA256(filter code),
                    filter name,
                    ' '.join(filter arguments),
                    SHA256(filter blob argument),
                ),
            ),
            object ID
        )
    ) => JSON({
Exemplo n.º 9
0
 def get_signature(rtype, *args):
     return murmur(rtype + '' + ''.join(args))