<commit_before>'use strict';

var _ = require('underscore');
var errors = require('../../errors');

var reducers = require('../reducers').reducers;
var adapters = require('../adapters');

// Juttle namespace
//
// Assign Juttle to module.exports early to satisfy/break a circular dependency
// from base.js
var Juttle = module.exports = {
    hub: {},
    visitGen:0,
    teardown: function(entryNode) {
        var k;
        Juttle.visitGen += 1;
        // loop over the head array to handle the case where
        // the onramp to the graph is a parallel path
        for (k = 0; k < entryNode.head.length; ++k) {
            entryNode.head[k].deactivate(Juttle.visitGen);
        }
    }
};

Juttle.reducers = reducers;
Juttle.adapters = adapters;

// stash the filter compiler in the runtime to enable adapters to
// leverage the filters in their implementation.
var FilterJSCompiler = require('../../compiler/filters/filter-js-compiler.js');
Juttle.FilterJSCompiler = FilterJSCompiler;

var base = require('./base');
var fanin = require('./fanin');

var PASS_INFO = {
    type: 'proc',
    options: {}   // documented, non-deprecated options only
};

var pass = fanin.extend({
    procName: 'pass'
}, {
    info: PASS_INFO
});

Juttle.proc = {
    base: base,
    read: require('./read'),
    write: require('./write'),
    join: require('./join'),
    filter: require('./filter'),
    tail: require('./tail'),
    head: require('./head'),
    skip: require('./skip'),
    sort: require('./sort'),
    source: require('./source'),
    sink: require('./sink'),
    split: require('./split'),
    batch: require('./batch'),
    unbatch: require('./unbatch'),
    put: require('./put'),
    remove: require('./remove'),
    keep: require('./keep'),
    emit: require('./emit'),
    pace: require('./pace'),
    pass: pass,
    sequence: require('./sequence'),
    uniq: require('./uniq'),
    reduce: require('./reduce'),
    fanin: fanin
};

var nchannels = 0;
function alloc_channel(prefix) {
    prefix = prefix || 'chan';
    while (true) {
        var name = prefix + (nchannels++);
        if (!Juttle.hub.hasOwnProperty(name)) {
            // insert an empty list to "claim" this channel
            Juttle.hub[name] = [];
            return name;
        }
    }
}

Juttle.alloc_channel = alloc_channel;

var SINK_INFO = {
    type: 'sink',
    options: {}   // documented, non-deprecated options only
};

Juttle.proc.view = Juttle.proc.sink.extend({
    initialize: function(options, params) {
        this.name = params.name;
        this.options = options;
        var chan = alloc_channel('sink');
        this.channel = chan;
    },

    procName: 'view',

    // When views get points/marks/ticks, they emit events on<commit_msg>procs.js - simpler channel name allocation<commit_after>'use strict';

var _ = require('underscore');
var errors = require('../../errors');

var reducers = require('../reducers').reducers;
var adapters = require('../adapters');

// Juttle namespace
//
// Assign Juttle to module.exports early to satisfy/break a circular dependency
// from base.js
var Juttle = module.exports = {
    channels:0,
    visitGen:0,
    teardown: function(entryNode) {
        var k;
        Juttle.visitGen += 1;
        // loop over the head array to handle the case where
        // the onramp to the graph is a parallel path
        for (k = 0; k < entryNode.head.length; ++k) {
            entryNode.head[k].deactivate(Juttle.visitGen);
        }
    }
};

Juttle.reducers = reducers;
Juttle.adapters = adapters;

// stash the filter compiler in the runtime to enable adapters to
// leverage the filters in their implementation.
var FilterJSCompiler = require('../../compiler/filters/filter-js-compiler.js');
Juttle.FilterJSCompiler = FilterJSCompiler;

var base = require('./base');
var fanin = require('./fanin');

var PASS_INFO = {
    type: 'proc',
    options: {}   // documented, non-deprecated options only
};

var pass = fanin.extend({
    procName: 'pass'
}, {
    info: PASS_INFO
});

Juttle.proc = {
    base: base,
    read: require('./read'),
    write: require('./write'),
    join: require('./join'),
    filter: require('./filter'),
    tail: require('./tail'),
    head: require('./head'),
    skip: require('./skip'),
    sort: require('./sort'),
    source: require('./source'),
    sink: require('./sink'),
    split: require('./split'),
    batch: require('./batch'),
    unbatch: require('./unbatch'),
    put: require('./put'),
    remove: require('./remove'),
    keep: require('./keep'),
    emit: require('./emit'),
    pace: require('./pace'),
    pass: pass,
    sequence: require('./sequence'),
    uniq: require('./uniq'),
    reduce: require('./reduce'),
    fanin: fanin
};


var SINK_INFO = {
    type: 'sink',
    options: {}   // documented, non-deprecated options only
};

Juttle.proc.view = Juttle.proc.sink.extend({
    initialize: function(options, params) {
        this.name = params.name;
        this.options = options;
        this.channel = 'view' + (Juttle.channels++);
    },

    procName: 'view',

    // When views get points/marks/ticks, they emit events on
{'fraction_non_alphanumeric': 0.16867704280155643, 'fraction_numerical': 0.0015564202334630351, 'mean_word_length': 2.711913357400722, 'pattern_counts': {'":': 0, '<': 5, '<?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': '486745', 'n_tokens_mistral': 1579, 'n_tokens_neox': 1529, 'n_words': 418}