<commit_before>'use strict'

var co = require('co')
var omit = require('mout/object/omit')

var WriteStream = require('./WriteStream')
var ReadStream = require('./ReadStream')

var includes = function (list, item) {
  return list.indexOf(item) !== -1
}

var defaultConf = {
  fileTable: 'rethinkdbfs_files',
  chunkTable: 'rethinkdbfs_chunks',
  chunkIndex: 'chunk_lookup',
  chunkSize: 1024 * 255,
  discovery: true,
  servers: [
    {host: 'localhost', port: 28015}
  ]
}

var RethinkDBFSBase = {

  prepDB () {
    var self = this
    return co(function *() {
      var tableList = yield self.r.tableList()

      // Create tables if they don't exist.
      if (!includes(tableList, self.conf.fileTable)) {
        yield self.r.tableCreate(self.conf.fileTable)
      }
      if (!includes(tableList, self.conf.chunkTable)) {
        yield self.r.tableCreate(self.conf.chunkTable)
      }

      var chunkIndexList = yield self.r.table(self.conf.chunkTable).indexList()

      // Create indexes if they don't exist.
      if (!includes(chunkIndexList, self.conf.chunkIndex)) {
        yield self.r.table(self.conf.chunkTable).indexCreate(self.conf.chunkIndex, [self.r.row('file_id'), self.r.row('num')])
        yield self.r.table(self.conf.chunkTable).indexWait(self.conf.chunkIndex)
      }
    }).catch(function (err) {
      console.log(err)
    })
  },

  writeFile (meta) {
    return new WriteStream(this.r, this.conf, meta)
  },

  readFile (meta) {
    return new ReadStream(this.r, this.conf, meta)
  }

}

var RethinkDBFS = function (conf) {<commit_msg>just bind this<commit_after>'use strict'

var co = require('co')
var omit = require('mout/object/omit')

var WriteStream = require('./WriteStream')
var ReadStream = require('./ReadStream')

var includes = function (list, item) {
  return list.indexOf(item) !== -1
}

var defaultConf = {
  fileTable: 'rethinkdbfs_files',
  chunkTable: 'rethinkdbfs_chunks',
  chunkIndex: 'chunk_lookup',
  chunkSize: 1024 * 255,
  discovery: true,
  servers: [
    {host: 'localhost', port: 28015}
  ]
}

var RethinkDBFSBase = {

  prepDB () {
    return co(function *() {
      var tableList = yield this.r.tableList()

      // Create tables if they don't exist.
      if (!includes(tableList, this.conf.fileTable)) {
        yield this.r.tableCreate(this.conf.fileTable)
      }
      if (!includes(tableList, this.conf.chunkTable)) {
        yield this.r.tableCreate(this.conf.chunkTable)
      }

      var chunkIndexList = yield this.r.table(this.conf.chunkTable).indexList()

      // Create indexes if they don't exist.
      if (!includes(chunkIndexList, this.conf.chunkIndex)) {
        yield this.r.table(this.conf.chunkTable).indexCreate(this.conf.chunkIndex, [this.r.row('file_id'), this.r.row('num')])
        yield this.r.table(this.conf.chunkTable).indexWait(this.conf.chunkIndex)
      }
    }.bind(this)).catch(function (err) {
      console.log(err)
    })
  },

  writeFile (meta) {
    return new WriteStream(this.r, this.conf, meta)
  },

  readFile (meta) {
    return new ReadStream(this.r, this.conf, meta)
  }

}

var RethinkDBFS = function (conf) {
{'fraction_non_alphanumeric': 0.146606914212548, 'fraction_numerical': 0.008322663252240717, 'mean_word_length': 3.200268817204301, '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': '48389', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1042, 'n_words': 215}