/*
(non-Javadoc)

@see org.apache.lucene.codecs.FieldsConsumer#merge(org.apache.lucene.index.
MergeState)
491797
@Override
  public void merge(MergeState mergeState) throws IOException {
    final List<Fields> fields = new ArrayList<>();
    final List<ReaderSlice> slices = new ArrayList<>();

    int docBase = 0;

    for (int readerIndex = 0; readerIndex < mergeState.fieldsProducers.length; readerIndex++) {
      final FieldsProducer f = mergeState.fieldsProducers[readerIndex];

      final int maxDoc = mergeState.maxDocs[readerIndex];
      f.checkIntegrity();
      slices.add(new ReaderSlice(docBase, maxDoc, readerIndex));
      fields.add(f);
      docBase += maxDoc;
    }

    Fields mergedFields = new MappedMultiFields(mergeState,
        new MultiFields(fields.toArray(Fields.EMPTY_ARRAY),
            slices.toArray(ReaderSlice.EMPTY_ARRAY)));
    write(mergedFields);
  }
751766
public void merge(Object obj) {
        if (obj == null) {
            throw new IllegalArgumentException(
                    "Object to merge cannot be null");
        }

        m_properties.putAll(getPropertyMap(obj));
    }
852906
public void merge(BloomKFilter that)
  {
    if (this != that && this.m == that.m && this.k == that.k) {
      this.bitSet.putAll(that.bitSet);
    } else {
      throw new IllegalArgumentException("BloomKFilters are not compatible for merging." +
                                         " this - " + this + " that - " + that);
    }
  }
223222
public function mergeDevInto(RootPackageInterface $root, PluginState $state)
    {
        $this->mergeDevRequires($root, $state);
        $this->mergeDevAutoload($root);
        $this->mergeReferences($root);
    }
13645
public void merge(Resource resource) {
        if (resource == null) {
            return;
        }

        checkRel(resource);
        checkHrefs(resource);

        if (resource.templated()) {
            this.pathParams.putAll(resource.pathParams);
            this.queryParams.putAll(resource.queryParams);
        }
        if (resource.hints() != null) {
            this.hints.merge(resource.hints());
        }
    }
289745
@Override
    public void merge(Collection<Bean> beans) throws AbortRuntimeException {
        init();
        Map<HBeanRow, HBeanRow> providedRows = new HashMap<>();
        for (Bean bean : beans) {
            HBeanRow row = new HBeanRow(bean, uids);
            providedRows.put(row, row);
            for (BeanId id : bean.getReferences()) {
                HBeanRow refRow = new HBeanRow(id, uids);
                providedRows.put(refRow, refRow);
            }
        }
        HBeanRowCollector storedCollector = null;
        try {
            storedCollector = table.getEager(providedRows);
        } catch (HBeanNotFoundException e) {
            // only throw exception if the bean was not provided
            if (!idsFoundIn(beans, e)) {
                throw Events.CFG301_MISSING_RUNTIME_REF(e.getNotFound().iterator().next());
            }
        }

        Map<HBeanRow, HBeanRow> storedRows = storedCollector.getRowMap();
        Set<RowMutations> mutations = new HashSet<>();

        for (HBeanRow provided : providedRows.keySet()) {
            HBeanRow stored = storedRows.get(provided);
            RowMutations rowMutations = new RowMutations(provided.getRowKey());
            Set<HBeanRow> deleteReferences = stored.merge(provided, rowMutations);
            try {
                deleteReferences = table.getLazy(deleteReferences);
                for (HBeanRow row : deleteReferences) {
                    RowMutations mutation = row.removePredecessor(provided);
                    mutations.add(mutation);
                }
            } catch (HBeanNotFoundException e) {
                throw new IllegalStateException("Broken predecessors");
            }
            mutations.add(rowMutations);
        }
        table.mutate(mutations);
    }
41962
public function mergeInto(RootPackageInterface $root, PluginState $state)
    {
        $this->prependRepositories($root);

        $this->mergeRequires('require', $root, $state);

        $this->mergePackageLinks('conflict', $root);
        $this->mergePackageLinks('replace', $root);
        $this->mergePackageLinks('provide', $root);

        $this->mergeSuggests($root);

        $this->mergeAutoload('autoload', $root);

        $this->mergeExtra($root, $state);

        $this->mergeScripts($root, $state);

        if ($state->isDevMode()) {
            $this->mergeDevInto($root, $state);
        } else {
            $this->mergeReferences($root);
        }
    }
485427
public void addMergePath(PathImpl path)
  {
    if (! (path instanceof MergePath)) {
      // Need to normalize so directory paths ends with a "./"
      // XXX:
      //if (path.isDirectory())
      //  path = path.lookup("./");

      ArrayList<PathImpl> pathList = ((MergePath) _root)._pathList;

      if (! pathList.contains(path))
        pathList.add(path);
    }
    else if (((MergePath) path)._root == _root)
      return;
    else {
      MergePath mergePath = (MergePath) path;
      ArrayList<PathImpl> subPaths = mergePath.getMergePaths();
      String pathName = "./" + mergePath._pathname + "/";

      for (int i = 0; i < subPaths.size(); i++) {
        PathImpl subPath = subPaths.get(i);

        addMergePath(subPath.lookup(pathName));
      }
    }
  }
1164370
private void mergeCompleted(SegmentProperties segmentProperties, UpdateableSegmentMetadata transactionMetadata, MergeSegmentOperation mergeOp) {
        // We have processed a MergeSegmentOperation, pop the first operation off and decrement the counter.
        StorageOperation processedOperation = this.operations.removeFirst();
        assert processedOperation != null && processedOperation instanceof MergeSegmentOperation : "First outstanding operation was not a MergeSegmentOperation";
        MergeSegmentOperation mop = (MergeSegmentOperation) processedOperation;
        assert mop.getSourceSegmentId() == transactionMetadata.getId() : "First outstanding operation was a MergeSegmentOperation for the wrong Transaction id.";
        int newCount = this.mergeTransactionCount.decrementAndGet();
        assert newCount >= 0 : "Negative value for mergeTransactionCount";

        // Post-merger validation. Verify we are still in agreement with the storage.
        long expectedNewLength = this.metadata.getStorageLength() + mergeOp.getLength();
        if (segmentProperties.getLength() != expectedNewLength) {
            throw new CompletionException(new DataCorruptionException(String.format(
                    "Transaction Segment '%s' was merged into parent '%s' but the parent segment has an unexpected StorageLength after the merger. Previous=%d, MergeLength=%d, Expected=%d, Actual=%d",
                    transactionMetadata.getName(),
                    this.metadata.getName(),
                    segmentProperties.getLength(),
                    mergeOp.getLength(),
                    expectedNewLength,
                    segmentProperties.getLength())));
        }

        updateMetadata(segmentProperties);
        updateMetadataForTransactionPostMerger(transactionMetadata, mop.getStreamSegmentId());
    }
1179487
public void merge(final Vector other) {
	for(int i =0; i<other.size(); i++) {
	    this.merge((ByteRange)other.elementAt(i));
	}
    }
1230004
public void merge(ApplicationDefinition appDef, String shard) {
		MergeOptions options = new MergeOptions(null, 0, true);
		merge(appDef, shard, options);
	}
855657
@Override
	protected Properties mergeProperties() throws IOException {
		final PrefixedProperties myProperties = createProperties();
		if (localOverride) {
			loadProperties(myProperties);
		}

		if (localProperties != null) {
			for (int i = 0; i < localProperties.length; i++) {
				CollectionUtils.mergePropertiesIntoMap(localProperties[i], myProperties);
			}
		}

		if (!localOverride) {
			loadProperties(myProperties);
		}

		return myProperties;
	}
97659
public function merge()
    {
        if ($this->_mergeDone) {
            include_once 'Zend/Search/Lucene/Exception.php';
            throw new Zend_Search_Lucene_Exception('Merge is already done.');
        }

        if (count($this->_segmentInfos) < 1) {
            include_once 'Zend/Search/Lucene/Exception.php';
            throw new Zend_Search_Lucene_Exception(
                'Wrong number of segments to be merged ('
                                                 . count($this->_segmentInfos)
                . ').'
            );
        }

        $this->_mergeFields();
        $this->_mergeNorms();
        $this->_mergeStoredFields();
        $this->_mergeTerms();

        $this->_mergeDone = true;

        return $this->_writer->close();
    }
26419
public BuildableType.Builder mergeBuilder(MergeBuilderMethod mergeBuilder) {
    this.mergeBuilder = Objects.requireNonNull(mergeBuilder);
    _unsetProperties.remove(Property.MERGE_BUILDER);
    return (BuildableType.Builder) this;
  }
1011571
public void merge(SrcTree srcTree) {
        mergeTestClassTable(srcTree.rootClassTable, rootClassTable);
        mergeTestClassTable(srcTree.subClassTable, subClassTable);
        mergeTestMethodTable(srcTree.rootMethodTable, rootMethodTable);
        mergeTestMethodTable(srcTree.subMethodTable, subMethodTable);
        mergeTestFieldTable(srcTree.fieldTable, fieldTable);
    }
611827
@Override
    public final Set<IPersonAttributes> mergeResults(final Set<IPersonAttributes> toModify, final Set<IPersonAttributes> toConsider) {
        Validate.notNull(toModify, "toModify cannot be null");
        Validate.notNull(toConsider, "toConsider cannot be null");

        //Convert the toModify Set into a Map to allow for easier lookups
        final Map<String, IPersonAttributes> toModfyPeople = new LinkedHashMap<>();
        for (final IPersonAttributes toModifyPerson : toModify) {
            toModfyPeople.put(toModifyPerson.getName(), toModifyPerson);
        }

        //Merge in the toConsider people
        for (final IPersonAttributes toConsiderPerson : toConsider) {
            final String toConsiderName = toConsiderPerson.getName();
            final IPersonAttributes toModifyPerson = toModfyPeople.get(toConsiderName);

            //No matching toModify person, just add the new person
            if (toModifyPerson == null) {
                toModify.add(toConsiderPerson);
            }
            //Matching toModify person, merge their attributes
            else {
                final Map<String, List<Object>> toModifyAttributes = this.buildMutableAttributeMap(toModifyPerson.getAttributes());
                final Map<String, List<Object>> mergedAttributes = this.mergePersonAttributes(toModifyAttributes, toConsiderPerson.getAttributes());
                final NamedPersonImpl mergedPerson = new NamedPersonImpl(toConsiderName, mergedAttributes);

                //Remove then re-add the mergedPerson entry
                toModify.remove(mergedPerson);
                toModify.add(mergedPerson);
            }
        }

        return toModify;
    }
796958
public void mergeWith(Core o) {
    o.num = this.num = (num < o.num ? num : o.num);
  }