<commit_before>from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
from builtins import *
import logging
import pandas as pd
import pymongo
import itertools

import emission.core.get_database as edb
import emission.storage.timeseries.abstract_timeseries as esta

import emission.core.wrapper.entry as ecwe

ts_enum_map = {
    esta.EntryType.DATA_TYPE: edb.get_timeseries_db(),
    esta.EntryType.ANALYSIS_TYPE: edb.get_analysis_timeseries_db()
}

INVALID_QUERY = {'1': '2'}

class BuiltinTimeSeries(esta.TimeSeries):
    def __init__(self, user_id):
        super(BuiltinTimeSeries, self).__init__(user_id)
        self.key_query = lambda key: {"metadata.key": key}
        self.type_query = lambda entry_type: {"metadata.type": entry_type}
        self.user_query = {"user_id": self.user_id} # UUID is mandatory for this version
        self.timeseries_db = ts_enum_map[esta.EntryType.DATA_TYPE]
        self.analysis_timeseries_db = ts_enum_map[esta.EntryType.ANALYSIS_TYPE]
        # Design question: Should the stats be a separate database, or should it be part
        # of the timeseries database? Technically, it should be part of the timeseries
        # database. However, I am concerned about the performance of the database
        # with even more entries - it already takes 10 seconds to query for a document
        # and I am not sure that adding a ton more data is going to make that better
        # it is going to be easier to copy entries into the same database instead of
        # splitting out, and we already support multiple indices, so I am tempted to put
        # it separately. On the other hand, then the load/store from timeseries won't work<commit_msg>Fix the invalid query to use an indexed key<commit_after>from __future__ import unicode_literals
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from future import standard_library
standard_library.install_aliases()
from builtins import *
import logging
import pandas as pd
import pymongo
import itertools

import emission.core.get_database as edb
import emission.storage.timeseries.abstract_timeseries as esta

import emission.core.wrapper.entry as ecwe

ts_enum_map = {
    esta.EntryType.DATA_TYPE: edb.get_timeseries_db(),
    esta.EntryType.ANALYSIS_TYPE: edb.get_analysis_timeseries_db()
}

INVALID_QUERY = {'metadata.key': 'invalid'}

class BuiltinTimeSeries(esta.TimeSeries):
    def __init__(self, user_id):
        super(BuiltinTimeSeries, self).__init__(user_id)
        self.key_query = lambda key: {"metadata.key": key}
        self.type_query = lambda entry_type: {"metadata.type": entry_type}
        self.user_query = {"user_id": self.user_id} # UUID is mandatory for this version
        self.timeseries_db = ts_enum_map[esta.EntryType.DATA_TYPE]
        self.analysis_timeseries_db = ts_enum_map[esta.EntryType.ANALYSIS_TYPE]
        # Design question: Should the stats be a separate database, or should it be part
        # of the timeseries database? Technically, it should be part of the timeseries
        # database. However, I am concerned about the performance of the database
        # with even more entries - it already takes 10 seconds to query for a document
        # and I am not sure that adding a ton more data is going to make that better
        # it is going to be easier to copy entries into the same database instead of
        # splitting out, and we already support multiple indices, so I am tempted to put
        # it separately. On the other hand, then the load/store from timeseries won't work
{'fraction_non_alphanumeric': 0.06051719541455612, 'fraction_numerical': 0.0015995734470807784, 'mean_word_length': 3.9368421052631577, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4733310', 'n_tokens_mistral': 1046, 'n_tokens_neox': 1030, 'n_words': 395}