Merges a DS header hash into each measurement
 @return [Array] Measurements with header and static metadata merged in
186859
def merge(ds, measurement, cardinality)

      m = ds.select {|k,v| k != :measurements and k != :errors and k != :warn }
      m = m.merge(measurement)
      m = m.merge ({ technology: "argos",
        type: type,
        cardinality: cardinality
        #file: "file://"+filename,
        #source: sha1
      })

      # if not ds[:errors].nil? and ds[:errors].any?
      #   m[:errors] = ds[:errors].clone
      # end
      #
      # if not ds[:warn].nil? and ds[:warn].any?
      #   m[:warn] = ds[:warn].clone
      # end
      #
      # if not m[:sensor_data].nil? and m[:sensor_data].size != ds[:sensors]
      #   if m[:warn].nil?
      #     m[:warn] = []
      #   end
      #   m[:warn] << "sensors-count-mismatch"
      # end

      # Create id as SHA1 hash of measurement minus stuff that may vary (like filename)
      #
      # Possible improvement for is to base id on a static list of keys
      # :program,
      # :platform,
      # :lines,
      # :sensors,
      # :satellite,
      # :lc,
      # :positioned,
      # :latitude,
      # :longitude,
      # :altitude,
      # :headers,
      # :measured,
      # :identical,
      # :sensor_data,
      # :technology,
      # :type,
      # :source

      idbase = m.clone
      idbase.delete :errors
      idbase.delete :file
      idbase.delete :warn

      id = Digest::SHA1.hexdigest(idbase.to_json)

      #m[:parser] = Argos.library_version
      m[:id] = id

      #m[:bundle] = bundle
      m
    end
969932
def mash(h)
      h.merge! @options
      @options.clear
      h.each {|k,v| self[k] = v}
    end
152229
public static Hash merge(Hash a, Hash b) {
        try {
            MessageDigest digest = MessageDigest.getInstance("SHA-256");
            digest.update(a.bytes);
            return Hash.createFromSafeArray(digest.digest(digest.digest(b.bytes)));
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
    }
644901
def extract_measures
      measure_files = MATMeasureFiles.create_from_zip_file(@measure_zip)

      measures = []
      if measure_files.components.present?
        measure, component_measures = create_measure_and_components(measure_files)
        measures.push(*component_measures)
      else
        measure = create_measure(measure_files)
      end
      measure.package = CQM::MeasurePackage.new(file: BSON::Binary.new(@measure_zip.read))
      measures << measure

      measures.each { |m| CqlLoader.update_population_set_and_strat_titles(m, @measure_details[:population_titles]) }
      return measures
    end
796012
def deep_merge!(target, hash)
      hash.each do |key, value|
        target[key] = if value.is_a?(Hash) && target[key].is_a?(Hash)
                        deep_merge(target[key], value)
                      else
                        value
                      end
      end
      target
    end
122665
def deep_merge(h)
      self.merge(h) do |key, v1, v2|
        if v1.is_a?(::Hash) && v2.is_a?(Sycl::Hash)
          self[key].deep_merge(v2)
        elsif v1.is_a?(::Hash) && v2.is_a?(::Hash)
          self[key].deep_merge(Sycl::Hash.from_hash(v2))
        else
          self[key] = Sycl::from_object(v2)
        end
      end
    end
198116
def to_hash_with_values
      keys = table_header_keys
      values = self
      @hash_with_values = {}
      keys.each_with_index {|k,i| v=values[i]; v=v.value if v; @hash_with_values[k]=v}
      return @hash_with_values
    end
174288
def with_headers(self, headers):
        
        return self.replace(headers=_merge_maps(self.headers, headers))
854880
def merge_id_hashes(dist, src, id_references)
      dist = dist.with_indifferent_access
      src = src.with_indifferent_access

      id_references.each do |id_reference|
        array_of_refs = id_reference.split('/')

        merge_id_hashes_helper(dist, array_of_refs, src)
      end

      dist
    end
102966
def merge_files
      @appliance_config.files.each_value { |dirs| dirs.clear }

      included = []

      @appliance_configs.each do |appliance_config|
        next if included.include?(appliance_config)
        appliance_config.files.each do |dir, files|
          @appliance_config.files[dir] = [] if @appliance_config.files[dir].nil?
          files.each { |f| @appliance_config.files[dir] << f }
        end
        included << appliance_config
      end
    end
1303349
def build_header_output
      output = []

      @header.each do |line|
        _data = []
        line.each do |h|
          _data << {:value => h, :color => @style[:header]}
        end
        output << _data
      end
      output
    end
762191
def merge!(other)
      @hooks.merge!(other.dup.hooks) do |key, array, other_array|
        temp_hash, output = {}, []

        (array + other_array).reverse_each do |pair|
          temp_hash[pair.first] ||= output.unshift(pair)
        end

        output
      end

      self
    end
390882
def parse_headers
      s0 = @current_pos
      s1 = []
      s2 = parse_header
      while s2 != :failed
        s1 << s2
        s2 = parse_header
      end
      @reported_pos = s0
      s0 = -> (header) do
        ret = {}
        header.each do |data|
          ret[normalize_header_key(data["k"])] = data["v"]
        end
        ret
      end.call(s1)
      s0
    end
422611
def merge!(rel)
      return self if rel.nil?
      MULTI_VALUE_METHODS.each do |method|
        (@values[method] ||= []).concat(rel.values[method]).uniq! unless rel.values[method].nil?
      end

      MULTI_KEY_METHODS.each do |method|
        (@values[method] ||= {}).merge!(rel.values[method]) unless rel.values[method].nil?
      end

      SINGLE_VALUE_METHODS.each do |method|
        @values[method] = rel.values[method] unless rel.values[method].nil?
      end

      self
    end
532744
def to_s
     data = [@name.concat(Array.new(32-@name.size, 0)), 
             @name_size, 
             @type, 
             @color, 
             @left, 
             @right, 
             @child, 
             @created,
             @modified, 
             @sector, 
             @size].flatten
      data.pack(PACKING)
    end
691546
def _unify_sources_and_hashes(source=None, source_hash=None,
                              sources=None, source_hashes=None):
    '''
    
    '''
    if sources is None:
        sources = []

    if source_hashes is None:
        source_hashes = []

    if source and sources:
        return (False,
                "source and sources are mutually exclusive", [])

    if source_hash and source_hashes:
        return (False,
                "source_hash and source_hashes are mutually exclusive", [])

    if source:
        return (True, '', [(source, source_hash)])

    # Make a nice neat list of tuples exactly len(sources) long..
    return True, '', list(zip_longest(sources, source_hashes[:len(sources)]))
1351165
def combine_diffs(diff_one, diff_two)
      Hash.new { |hash, key| hash[key] = [[], []] }.tap do |combined_diff|
        diff_one.each do |change|
          combined_diff[change.old_position].first << change
        end

        diff_two.each do |change|
          combined_diff[change.old_position].last << change
        end
      end
    end