Collect candidates from all buckets from all hashes
979070
def _get_candidates(self, v):
        
        candidates = []
        for lshash in self.lshashes:
            for bucket_key in lshash.hash_vector(v, querying=True):
                bucket_content = self.storage.get_bucket(
                    lshash.hash_name,
                    bucket_key,
                )
                #print 'Bucket %s size %d' % (bucket_key, len(bucket_content))
                candidates.extend(bucket_content)
        return candidates
1072886
function gather_list_from_hash(nid, hash){
    	    var retlist = new Array();
    	    retlist.push(nid);
    	    // Get all nodes cribbing from distances.
    	    for( vt in hash[nid] ){
    		//ll("id: " + id + ", v: " + ct);
    		retlist.push(vt);
    	    }
    	    return retlist;	
	}
1083391
def buckets(options = {})
      batches = Enumerator.new do |y|
        batch = []
        resp = @client.list_buckets(options)
        resp.data.buckets.each do |b|
          batch << Bucket.new(
            name: b.name,
            data: b,
            client: @client
          )
        end
        y.yield(batch)
      end
      Bucket::Collection.new(batches)
    end
898248
function (allCommitItems) {
            var filteredCommits = [],
                index,
                hashToIndex = {},
                reachabilityGraph = {},
                extendReachability = function (original, extension) {
                    var key;

                    for (key in extension) {
                        original[key] = true;
                    }
                },
                i, j;

            for (i = 0; i < allCommitItems.length; i += 1) {
                hashToIndex[allCommitItems[i][CONSTANTS.MONGO_ID]] = i;
            }

            //this is the function that fills out the rootHash...
            rootHash = allCommitItems[hashToIndex[toCommit]].root;

            for (i = 0; i < allCommitItems.length; i += 1) {
                for (j = 0; j < allCommitItems[i].parents.length; j += 1) {
                    index = hashToIndex[allCommitItems[i].parents[j]];
                    reachabilityGraph[index] = reachabilityGraph[index] || {};
                    reachabilityGraph[index][i] = true;
                    extendReachability(reachabilityGraph[index], reachabilityGraph[i]);

                }
            }

            for (index in reachabilityGraph[hashToIndex[fromCommit]]) {
                filteredCommits.push(allCommitItems[index]);
            }

            return filteredCommits;
        }
997654
def get_all_objects_in_bucket(
        aws_bucket_name,
        s3_client=None,
        max_keys=1000
):
    
    logger.debug("Retrieving bucket object list")

    if not s3_client:
        s3_client, s3_resource = get_s3_client()

    obj_dict = {}
    paginator = s3_client.get_paginator('list_objects')
    page_iterator = paginator.paginate(Bucket=aws_bucket_name)
    for page in page_iterator:
        key_list = page.get('Contents', [])
        logger.debug("Loading page with {} keys".format(len(key_list)))
        for obj in key_list:
            obj_dict[obj.get('Key')] = obj
    return obj_dict
234507
def hash(self):
        """"""
        if 'digest' not in self._p4dict:
            self._p4dict = self._connection.run(['fstat', '-m', '1', '-Ol', self.depotFile])[0]

        return self._p4dict['digest']
1299035
def get_bucket(self, hash_name, bucket_key):
        
        results = []
        for row in self._get_bucket_rows(hash_name, bucket_key):
            val_dict = pickle.loads(row)
            # Depending on type (sparse or not) reconstruct vector
            if 'sparse' in val_dict:

                # Fill these for COO creation
                row = []
                col = []
                data = []

                # For each non-zero element, append values
                for e in val_dict['nonzeros']:
                    row.append(e[0])  # Row index
                    data.append(e[1])  # Value
                    col.append(0)  # Column index (always 0)

                # Create numpy arrays for COO creation
                coo_row = numpy.array(row, dtype=numpy.int32)
                coo_col = numpy.array(col, dtype=numpy.int32)
                coo_data = numpy.array(data)

                # Create COO sparse vector
                vector = scipy.sparse.coo_matrix((coo_data, (coo_row, coo_col)), shape=(val_dict['dim'], 1))

            else:
                vector = numpy.fromstring(val_dict['vector'],
                                          dtype=val_dict['dtype'])

            # Add data to result tuple, if present
            results.append((vector, val_dict.get('data')))

        return results
644514
def hasher(data, algos=ALGOS):
    """"""
    try:
        data = data.encode()
    except Exception:
        pass

    result = {}

    for algo in sorted(hashlib.algorithms_available):
        if algo in algos:
            h = hashlib.new(algo)
            h.update(data)
            result[algo] = h.hexdigest()

    return result
34228
def get_nodes_by_hashes(self, node_hashes: List[str]) -> List[Node]:
        """"""
        return self.session.query(Node).filter(Node.sha512.in_(node_hashes)).all()
352763
def metas(self, prefix=None, limit=None, delimiter=None):
        
        limit = coalesce(limit, TOO_MANY_KEYS)
        keys = self.bucket.list(prefix=prefix, delimiter=delimiter)
        prefix_len = len(prefix)
        output = []
        for i, k in enumerate(k for k in keys if len(k.key) == prefix_len or k.key[prefix_len] in [".", ":"]):
            output.append({
                "key": strip_extension(k.key),
                "etag": convert.quote2string(k.etag),
                "expiry_date": Date(k.expiry_date),
                "last_modified": Date(k.last_modified)
            })
            if i >= limit:
                break
        return wrap(output)
659983
def prepare_regions_hash(rdo)
      res = {}
      rdo.each do |region|
        region.dealers.each do |dealer|
          dealer.offices.each do |office|
            if res[region.id].nil?
              res[region.id] = { id:region.id, title:region.title }
            else
              break
            end
          end
        end
      end
      res
    end
427553
function(bucket, keys, cb){
		contract(arguments)
			.params('string', 'array', 'function')
			.end()
		;
		
		var table = '';
		if (bucket.indexOf('allows') != -1) {
			table = this.prefix + this.buckets.permissions;
			this.db
				.select('key', 'value')
				.from(table)
				.where({'key': bucket})
				.then(function(results) {
					if (results.length && results[0].value) {
						var keyArrays = [];
						_.each(keys, function(key) {
							keyArrays.push.apply(keyArrays, results[0].value[key]);
						});
						cb(undefined, _.union(keyArrays));
					} else {
						cb(undefined, []);
					}
					
				})
			;
		} else {
			table = this.prefix + bucket;
			this.db
				.select('key', 'value')
				.from(table)
				.whereIn('key', keys)
				.then(function(results) {
					if (results.length) {
						var keyArrays = [];
						_.each(results, function(result) {
							keyArrays.push.apply(keyArrays, result.value);
						});
						cb(undefined, _.union(keyArrays));
					} else {
						cb(undefined, []);
					}
				})
			;
		}
	}
969473
def build_hash_with_entities(entities_name, entity_name, proc, entities)
      Hash[*entities_name.collect { |name| proc.call(name) == entity_name ? [name, entities] : [name, []] }.flatten(1)]
    end
1009107
def collect_all_bucket_keys(self):
        
        if len(self.childs) == 0:
            # This is a leaf so just return the bucket key (we reached the bucket leaf)
            #print 'Returning (collect) leaf bucket key %s with %d vectors' % (self.bucket_key, self.vector_count)
            return [self.bucket_key]

        # Not leaf, return results of childs
        result = []
        for child in self.childs.values():
            result = result + child.collect_all_bucket_keys()

        return result
492554
def list_blobs(self, prefix=''):
    """"""
    return [b.name for b in self.bucket.list_blobs(prefix=prefix)]
617086
def ReadHashBlobReferences(self, hashes, cursor):
    """"""
    query = ("SELECT hash_id, blob_references FROM hash_blob_references WHERE "
             "hash_id IN {}").format(mysql_utils.Placeholders(len(hashes)))
    cursor.execute(query, [hash_id.AsBytes() for hash_id in hashes])
    results = {hash_id: None for hash_id in hashes}
    for hash_id, blob_references in cursor.fetchall():
      sha_hash_id = rdf_objects.SHA256HashID.FromBytes(hash_id)
      refs = rdf_objects.BlobReferences.FromSerializedString(blob_references)
      results[sha_hash_id] = list(refs.items)
    return results
512965
def get_hash(self, handle):
        """"""
        fpath = self._fpath_from_handle(handle)
        return DiskStorageBroker.hasher(fpath)