<commit_before>require 'multi_json'

module Dumbo
  class Segment
    def self.all(db, druid)
      @all ||= all!(db, druid)
    end

    def self.all!(db, druid)
      segments = db[:druid_segments]
      segments.where(used: true)
      data = segments.map do |row|
        new(MultiJson.load(row[:payload]), druid)
      end

      $log.info("found #{data.length} segments in metadata store")
      data
    end

    attr_reader :source, :interval, :version, :dimensions, :metrics, :loadSpec, :shardSpec

    def initialize(payload, druid)
      @payload = payload
      @source = payload['dataSource']
      @interval = payload['interval'].split('/').map { |str| Time.parse(str) }
      @version = Time.parse(payload['version'])
      @dimensions = Set.new(payload['dimensions'].split(','))
      @metrics = Set.new(payload['metrics'].split(','))<commit_msg>fixup sequel segment scanner<commit_after>require 'multi_json'

module Dumbo
  class Segment
    def self.all(db, druid)
      @all ||= all!(db, druid)
    end

    def self.all!(db, druid)
      segments = db[:druid_segments].where(used: true).map do |row|
        new(MultiJson.load(row[:payload]), druid)
      end

      $log.info("found #{segments.length} segments in metadata store")
      segments
    end

    attr_reader :source, :interval, :version, :dimensions, :metrics, :loadSpec, :shardSpec

    def initialize(payload, druid)
      @payload = payload
      @source = payload['dataSource']
      @interval = payload['interval'].split('/').map { |str| Time.parse(str) }
      @version = Time.parse(payload['version'])
      @dimensions = Set.new(payload['dimensions'].split(','))
      @metrics = Set.new(payload['metrics'].split(','))
{'fraction_non_alphanumeric': 0.1584795321637427, 'fraction_numerical': 0.0, 'mean_word_length': 3.3426395939086295, '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': '3583773', 'n_tokens_mistral': 542, 'n_tokens_neox': 537, 'n_words': 119}