     if condensedQuery[1].split.bucket in ['timePeriod', 'timeDuration']
       return @_timeCalculate(condensedQuery)
 
-    return @hashmap[@_generateHash(condensedQuery)]
+    return @hashmap[generateHash(condensedQuery)]
 
   put: (condensedQuery, root) ->
-    hash = @_generateHash(condensedQuery)
+    hash = generateHash(condensedQuery)
     splitOpName = condensedQuery[1].split.name
     hashValue = []
     for split in root.splits

# -----------------------------------------------------
driverUtil = require('./driverUtil')

class Cache
  constructor: ->
    @hashmap = {}

  _filterToHash: (filter) ->
    return '' unless filter?
    hash = []
    if filter.filters?
      for subFilter in filter.filters
        hash.push @_filterToHash(subFilter)
      return hash.sort().join(filter.type)
    else
      for k, v of filter
        hash.push(k + ":" + v)
    return hash.sort().join('|')

  _splitToHash: (split) ->
    hash = []
    for k, v of split
      hash.push(k + ":" + v)

    return hash.sort().join('|')

  _separateTimeFilter: (filter) ->
    if filter.filters?
      timeFilter = filter.filters.filter((({type}) -> type is 'within'), this)[0]
      filtersWithoutTime = filter.filters.filter((({type}) -> type is 'within'), this)
      if filtersWithoutTime.length is 1
        return {
          filter: filtersWithoutTime[0]
          timeFilter
        }
      else
        # ToDo: make new And filter

        filter.filters = filtersWithoutTime
        return {
          filter: {
            operation: 'filter'
            type: 'and'
            filters: filtersWithoutTime
          }
          timeFilter
        }
    else # Only time filter exists
      return {
        filter: null
        timeFilter: filter
      }

class FilterCache extends Cache
  # { key: filter,
  #   value: { key: metric,
  #            value: value } }

  get: (condensedQuery, values) ->
    # Return format:

    @hashmap[hash] = hashValue
    return

  _timeCalculate: (condensedQuery) ->
    split = condensedQuery[1].split
    {timeFilter} = separateTimeFilter(condensedQuery[0].filter)
    timestamps = []
    timestamp = new Date(timeFilter.range[0])
    end = new Date(timeFilter.range[1])
