     subListAndPad : (locations, desiredLength) ->
       padCount     = desiredLength - locations.length
       falseIndices = @indexGenerator.generate(padCount)
-
       return locations.concat(falseIndices)
 
   return MetadataMapper

        if token.length <= MINIMUM_TOKEN_LENGTH
          continue

        token = HashFunction.MURMUR3_128(token)

        indexForTerm    = @fheEngine.getTokenAddress(token, documentKey)
        paddedLocations = @subListAndPad(locations, bucketLength)

        balancedMetadatum = { id, token, locations : paddedLocations }

        if metadataMap[indexForTerm]
          metadataMap[indexForTerm].push(balancedMetadatum)
        else
          metadataMap[indexForTerm] = [ balancedMetadatum ]

      return metadataMap


define 'kryptnostic.search.metadata-mapper', [
  'require'
  'kryptnostic.logger'
  'kryptnostic.binary-utils'
  'kryptnostic.hash-function'
  'kryptnostic.mock.fhe-engine'
  'kryptnostic.search.random-index-generator'
], (require) ->

  Logger               = require 'kryptnostic.logger'
  BinaryUtils          = require 'kryptnostic.binary-utils'
  HashFunction         = require 'kryptnostic.hash-function'
  MockFheEngine        = require 'kryptnostic.mock.fhe-engine'
  RandomIndexGenerator = require 'kryptnostic.search.random-index-generator'

  MINIMUM_TOKEN_LENGTH = 1

  log = Logger.get('MetadataMapper')

  #
  # compute size of largest metadata bucket for padding.
