# Path: lsh/utils/similarity.py
# def compute_positive_hash(value):
#     return hash(value) % ((sys.maxsize + 1) * 2)
# 
# Path: lsh/shingles/shingles.py
# def _get_list_of_shingles(doc, size=DEFAULT_SHINGLE_SIZE):
#     """
#         Creates a list of shingles (strings)
#         :param doc: doc to create shingles from
#         :type doc: string
#         :param size: size of shingle
#         :type size: int
#         :return: list of shingles (strings), will return an empty list if doc is None or empty
#     """
# 
#     if doc:
#         return [doc[i:i + size] for i in range(len(doc) - size + 1)]
#     else:
#         return []
# 
# Path: repositories/gae/dataset.py
# def get_random_bits(max_hashes):
#     return [random.getrandbits(get_max_bits()) for _ in xrange(max_hashes)]
# 
# def calculate_max_hashes(rows, bands):
#     return rows * bands


import operator, struct, math, sys, logging, datetime
from lsh.utils.similarity import compute_positive_hash
from lsh.shingles.shingles import _get_list_of_shingles
from repositories.gae.dataset import get_random_bits, calculate_max_hashes

def map(dataset, text, id=None):
    logging.info("OpenLSH > map() called.")
    start = datetime.datetime.utcnow()

    hashes = calculate_max_hashes(dataset.rows, dataset.bands)

    if len(dataset.random_seeds) < hashes:

# Path: lsh/utils/similarity.py
# def compute_positive_hash(value):
#     return hash(value) % ((sys.maxsize + 1) * 2)
# 
# Path: lsh/shingles/shingles.py
# def _get_list_of_shingles(doc, size=DEFAULT_SHINGLE_SIZE):
#     """
#         Creates a list of shingles (strings)
#         :param doc: doc to create shingles from
#         :type doc: string
#         :param size: size of shingle
#         :type size: int
#         :return: list of shingles (strings), will return an empty list if doc is None or empty
#     """
# 
#     if doc:
#         return [doc[i:i + size] for i in range(len(doc) - size + 1)]
#     else:
#         return []
# 
# Path: repositories/gae/dataset.py
# def get_random_bits(max_hashes):
#     return [random.getrandbits(get_max_bits()) for _ in xrange(max_hashes)]
# 
# def calculate_max_hashes(rows, bands):
#     return rows * bands


# Path: lsh/gae/map_reduce.py
import operator, struct, math, sys, logging, datetime
from lsh.utils.similarity import compute_positive_hash
from lsh.shingles.shingles import _get_list_of_shingles
from repositories.gae.dataset import get_random_bits, calculate_max_hashes


def map(dataset, text, id=None):
    logging.info("OpenLSH > map() called.")
    start = datetime.datetime.utcnow()

    hashes = calculate_max_hashes(dataset.rows, dataset.bands)

    if len(dataset.random_seeds) < hashes:

        dataset.random_seeds = get_random_bits(hashes)