Return the neighbour buckets given hash_name and query bucket key.
339629
def get_neighbour_keys(self, hash_name, bucket_key):
        
        # get the permutedIndex given hash_name
        permutedIndex = self.permutedIndexs[hash_name]
        # return neighbour bucket keys of query bucket key
        return permutedIndex.get_neighbour_keys(
            bucket_key,
            permutedIndex.num_neighbour)
1033506
def get_keys(self, bucket, timeout=None):
        
        bucket_type = self._get_bucket_type(bucket.bucket_type)
        url = self.key_list_path(bucket.name, bucket_type=bucket_type,
                                 timeout=timeout)
        status, _, body = self._request('GET', url)

        if status == 200:
            props = json.loads(bytes_to_str(body))
            return props['keys']
        else:
            raise RiakError('Error listing keys.')
337176
def atlas_get_live_neighbors( remote_peer_hostport, peer_table=None, min_health=MIN_PEER_HEALTH, min_request_count=1 ):
    

    with AtlasPeerTableLocked(peer_table) as ptbl:
        alive_peers = []
        for peer_hostport in ptbl.keys():
            if peer_hostport == remote_peer_hostport:
                continue

            num_reqs = atlas_peer_get_request_count( peer_hostport, peer_table=ptbl )
            if num_reqs < min_request_count:
                continue

            health = atlas_peer_get_health( peer_hostport, peer_table=ptbl )
            if health < min_health:
                continue

            alive_peers.append( peer_hostport )

    random.shuffle(alive_peers)
    return alive_peers
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
147858
def _gcs_get_key_names(bucket, pattern):
  
  return [obj.metadata.name for obj in _gcs_get_keys(bucket, pattern)]
1031570
def hashone(self):
    ""
    rs = self.one()
    if not rs: 
      return {}
    else:
      finds = " ".join(self._find).split(' ')
      return dict(zip((x.replace('?','') for x in finds), rs))
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
786713
def store_vector(self, hash_name, bucket_key, v, data):
        

        if not hash_name in self.buckets:
            self.buckets[hash_name] = {}

        if not bucket_key in self.buckets[hash_name]:
            self.buckets[hash_name][bucket_key] = []
        self.buckets[hash_name][bucket_key].append((v, data))
16783
def list(self, path, filename=None, start=None, stop=None, recursive=False, directories=False):
        
        storageScheme, keys = self.getkeys(
            path, filename=filename, directories=directories, recursive=recursive)
        keys = [storageScheme + ":///" + key.bucket.name + "/" + key.name for key in keys]
        keys.sort()
        keys = select(keys, start, stop)
        return keys
940938
public static int[] getHashBuckets(String key, int hashCount, int max, boolean applyWidth) {
        byte[] b;
        b = key.getBytes(StandardCharsets.UTF_8);
        return getHashBuckets(b, hashCount, max, applyWidth);
    }
789870
def clean_buckets(self, hash_name):
        
        bucket_keys = self._iter_bucket_keys(hash_name)
        self.redis_object.delete(*bucket_keys)
320099
def get_default_bucket_key(buckets: List[Tuple[int, int]]) -> Tuple[int, int]:
    
    return max(buckets)
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
371259
def get_aggregation(self, name):
        '''
        
        '''
        agg = self.aggregations[name]
        if 'buckets' in agg:
            return agg['buckets']
        else:
            return agg
276522
def list_objects(self, bucket_name=None, **kwargs):
        
        if not bucket_name: bucket_name = self.bucket_name
        return self.client.list_objects(Bucket=bucket_name, **kwargs)
1011901
def mkbucketv2(self, bucket_name, region):
        
        bucket_name = urlsafe_base64_encode(bucket_name)
        return self.__rs_do('mkbucketv2', bucket_name, 'region', region)
1332659
def hash_vector(self, v, querying=False):
        

        bucket_keys = []

        if querying:
            # If we are querying, use the permuted indexes to get bucket keys
            for child_hash in self.child_hashes:
                lshash = child_hash['hash']
                # Make sure the permuted index for this hash is existing
                if not lshash.hash_name in self.permutation.permutedIndexs:
                    raise AttributeError('Permuted index is not existing for hash with name %s' % lshash.hash_name)

                # Get regular bucket keys from hash
                for bucket_key in lshash.hash_vector(v, querying):
                    #print 'Regular bucket key %s' % bucket_key
                    # Get neighbour keys from permuted index
                    neighbour_keys = self.permutation.get_neighbour_keys(lshash.hash_name,bucket_key)
                    # Add them to result, but prefix with hash name
                    for n in neighbour_keys:
                        bucket_keys.append(lshash.hash_name+'_'+n)

        else:
            # If we are indexing (storing) just use child hashes without permuted index
            for child_hash in self.child_hashes:
                lshash = child_hash['hash']

                # Get regular bucket keys from hash
                for bucket_key in lshash.hash_vector(v, querying):
                    # Register bucket key in child hash dict
                    child_hash['bucket_keys'][bucket_key] = bucket_key
                    # Append bucket key to result prefixed with child hash name
                    bucket_keys.append(lshash.hash_name+'_'+bucket_key)

        # Return all the bucket keys
        return bucket_keys