<commit_before>import { Entity } from './entity.class';
import { TagClass } from './manager.interfaces';

import { Query } from './query.class';
import { QueryTypes } from './query.enums';
import { andExecutor, orExecutor, notExecutor, setsIntersector, setsUnioner, setInvertor } from './executor.helpers';



export class QueryExecutor {
    constructor( private entities: Entity[] ) {}

    public execute( query: Query ): Entity[] {
        return this.executeRecursive(query, this.entities);
    }



    private mutation: Entity[];

    private executeRecursive(query: Query, ents: Entity[]): Entity[] {
        let lTags = [];
        let lSubqueries = [];
        let lType = query.type;
        query.args.forEach( arg => (arg instanceof Query ? lSubqueries : lTags).push(arg) );
        let lEntitesSets = [];
        if (lTags.length) {
            lEntitesSets.push(this.proceedTags(lType, lTags, ents));
        }
        if (lSubqueries) {
            lEntitesSets = lEntitesSets.concat(this.proceedSubqueries(lSubqueries, ents));
        }<commit_msg>executor class improvements<commit_after>import { Entity } from './entity.class';
import { TagClass } from './manager.interfaces';

import { Query } from './query.class';
import { QueryTypes } from './query.enums';
import { andExecutor, orExecutor, notExecutor, setsIntersector, setsUnioner, setInvertor } from './executor.helpers';



export class QueryExecutor {
    constructor( private entities: Entity[] ) {}

    public execute( query: Query ): Entity[] {
        return this.executeRecursive(query, this.entities);
    }



    private executeRecursive(query: Query, ents: Entity[]): Entity[] {
        let lTags: TagClass<any>[] = [];
        let lSubqueries: Query[] = [];
        let lType = query.type;
        query.args.forEach( arg => arg instanceof Query
            ? lSubqueries.push(arg)
            : lTags.push(arg)
        );
        let lEntitesSets: Entity[][] = [];
        if (lTags.length) {
            lEntitesSets.push(this.proceedTags(lType, lTags, ents));
        }
        if (lSubqueries) {
            lEntitesSets = lEntitesSets.concat(this.proceedSubqueries(lSubqueries, ents));
        }
{'fraction_non_alphanumeric': 0.13339424394700777, 'fraction_numerical': 0.0, 'mean_word_length': 2.8898756660746003, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, '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': '2059682', 'n_tokens_mistral': 647, 'n_tokens_neox': 640, 'n_words': 152}