<commit_before>import json
import types
from future.utils import with_metaclass

from .document import Document, Edge
from .theExceptions import ValidationError, SchemaViolation, CreationError, UpdateError, DeletionError, InvalidDocument
from .query import SimpleQuery
from .index import Index

__all__ = ["Collection", "Edges", "Field", "DocumentCache", "CachedDoc", "Collection_metaclass", "getCollectionClass", "isCollection", "isDocumentCollection", "isEdgeCollection", "getCollectionClasses"]

class CachedDoc(object) :
    """A cached document"""
    def __init__(self, document, prev, nextDoc) :
        self.prev = prev
        self.document = document
        self.nextDoc = nextDoc
        self.key = document.key

class DocumentCache(object) :
    "Document cache for collection, with insert, deletes and updates in O(1)"

    def __init__(self, cacheSize) :
        self.cacheSize = cacheSize
        self.cacheStore = {}
        self.head = None
        self.tail = None

    def cache(self, doc) :
        if doc.key in self.cacheStore :
            ret = self.cacheStore[doc.key]
            if ret.prev is not None :
                ret.prev.nextDoc = ret.nextDoc
                self.head.prev = ret<commit_msg>We need the CONST to be defined if we use it later on.<commit_after>import json
import types
from future.utils import with_metaclass
from . import consts as CONST

from .document import Document, Edge
from .theExceptions import ValidationError, SchemaViolation, CreationError, UpdateError, DeletionError, InvalidDocument
from .query import SimpleQuery
from .index import Index

__all__ = ["Collection", "Edges", "Field", "DocumentCache", "CachedDoc", "Collection_metaclass", "getCollectionClass", "isCollection", "isDocumentCollection", "isEdgeCollection", "getCollectionClasses"]

class CachedDoc(object) :
    """A cached document"""
    def __init__(self, document, prev, nextDoc) :
        self.prev = prev
        self.document = document
        self.nextDoc = nextDoc
        self.key = document.key

class DocumentCache(object) :
    "Document cache for collection, with insert, deletes and updates in O(1)"

    def __init__(self, cacheSize) :
        self.cacheSize = cacheSize
        self.cacheStore = {}
        self.head = None
        self.tail = None

    def cache(self, doc) :
        if doc.key in self.cacheStore :
            ret = self.cacheStore[doc.key]
            if ret.prev is not None :
                ret.prev.nextDoc = ret.nextDoc
                self.head.prev = ret
{'fraction_non_alphanumeric': 0.09339137316976652, 'fraction_numerical': 0.0007914523149980214, 'mean_word_length': 3.0972447325769856, 'pattern_counts': {'":': 0, '<': 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': '5179897', 'n_tokens_mistral': 701, 'n_tokens_neox': 688, 'n_words': 218}