<commit_before>import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import TreeView from '../components/TreeView';
import { getZeroAt, selectedThreadSelectors, getSelectedThreadIndex } from '../selectors/';
import * as actions from '../actions';

class MarkerTree {
  constructor(thread, zeroAt) {
    this._thread = thread;
    this._zeroAt = zeroAt;
    this._nodes = new Map();
  }

  getRoots() {
    const markerIndices = [];
    for (let i = 0; i < this._thread.markers.length; i++) {
      markerIndices.push(i);
    }
    return markerIndices;
  }

  getChildren(markerIndex) {
    return markerIndex === -1 ? this.getRoots() : [];
  }

  hasChildren(markerIndex) {
    const { markers } = this._thread;
    return markers.data[markerIndex] !== null &&
           ('stack' in markers.data[markerIndex]);
  }

  getParent() {
    return null;
  }

  getDepth() {
    return 0;
  }

  hasSameNodeIds(tree) {
    return this._thread.markers === tree._thread.markers;
  }

  /**
   * Return an object with information about the node with index markerIndex.
   * @param  {[type]} markerIndex [description]
   * @return {[type]}             [description]
   */
  getNode(markerIndex) {
    let node = this._nodes.get(markerIndex);
    if (node === undefined) {
      const { markers, stringTable } = this._thread;
      let category = 'unknown';
      let name = stringTable.getString(markers.name[markerIndex]);
      if (markers.data[markerIndex]) {
        if ('category' in markers.data[markerIndex]) {
          category = markers.data[markerIndex].category;
        }
        if (markers.data[markerIndex].type === 'tracing') {
          name = `[${markers.data[markerIndex].interval}] ${name}`;
        }
      }
      node = {
        timestamp: `${((markers.time[markerIndex] - this._zeroAt) / 1000).toFixed(3)}s`,
        name,
        category,
      };
      this._nodes.set(markerIndex, node);<commit_msg>Truncate log markers.<commit_after>import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import TreeView from '../components/TreeView';
import { getZeroAt, selectedThreadSelectors, getSelectedThreadIndex } from '../selectors/';
import * as actions from '../actions';

class MarkerTree {
  constructor(thread, zeroAt) {
    this._thread = thread;
    this._zeroAt = zeroAt;
    this._nodes = new Map();
  }

  getRoots() {
    const markerIndices = [];
    for (let i = 0; i < this._thread.markers.length; i++) {
      markerIndices.push(i);
    }
    return markerIndices;
  }

  getChildren(markerIndex) {
    return markerIndex === -1 ? this.getRoots() : [];
  }

  hasChildren(markerIndex) {
    const { markers } = this._thread;
    return markers.data[markerIndex] !== null &&
           ('stack' in markers.data[markerIndex]);
  }

  getParent() {
    return null;
  }

  getDepth() {
    return 0;
  }

  hasSameNodeIds(tree) {
    return this._thread.markers === tree._thread.markers;
  }

  /**
   * Return an object with information about the node with index markerIndex.
   * @param  {[type]} markerIndex [description]
   * @return {[type]}             [description]
   */
  getNode(markerIndex) {
    let node = this._nodes.get(markerIndex);
    if (node === undefined) {
      const { markers, stringTable } = this._thread;
      let category = 'unknown';
      let name = stringTable.getString(markers.name[markerIndex]);
      if (markers.data[markerIndex]) {
        if ('category' in markers.data[markerIndex]) {
          category = markers.data[markerIndex].category;
        }
        if (markers.data[markerIndex].type === 'tracing') {
          if (category === 'log') {
            // name is actually the whole message that was sent to fprintf_stderr. Would you consider that.
            if (name.length > 100) {
              name = name.substring(0, 100) + '...';
            }
          } else {
            name = `[${markers.data[markerIndex].interval}] ${name}`;
          }
        }
      }
      node = {
        timestamp: `${((markers.time[markerIndex] - this._zeroAt) / 1000).toFixed(3)}s`,
        name,
        category,
      };
      this._nodes.set(markerIndex, node);
{'fraction_non_alphanumeric': 0.14404563822201094, 'fraction_numerical': 0.005467078678393154, 'mean_word_length': 2.608919382504288, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '5509015', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1258, 'n_words': 290}