Skip to content

Commit 21a2ef8

Browse files
committed
PHPLIB-1513: Remove the mapReduce helper
1 parent 8694edf commit 21a2ef8

File tree

12 files changed

+9
-1061
lines changed

12 files changed

+9
-1061
lines changed

UPGRADE-2.0.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ UPGRADE FROM 1.x to 2.0
1010
`MongoDB\Model\IndexInfo` class.
1111
* The `maxScan`, `modifiers`, `oplogReplay`, and `snapshot` options for `find`
1212
and `findOne` operations have been removed.
13+
* The `MongoDB\Collection::mapReduce` method has been removed. Use aggregation
14+
pipeline instead.
1315
* The following classes and interfaces have been removed without replacement:
14-
* `MongoDB\Operation\Executable`
16+
* `MongoDB\MapReduceResult`
1517
* `MongoDB\Model\CollectionInfoCommandIterator`
1618
* `MongoDB\Model\CollectionInfoIterator`
1719
* `MongoDB\Model\DatabaseInfoIterator`
1820
* `MongoDB\Model\DatabaseInfoLegacyIterator`
1921
* `MongoDB\Model\IndexInfoIterator`
2022
* `MongoDB\Model\IndexInfoIteratorIterator`
23+
* `MongoDB\Operation\Executable`
2124

2225
GridFS
2326
------

psalm-baseline.xml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -744,23 +744,6 @@
744744
<code><![CDATA[$options['session']]]></code>
745745
</MixedAssignment>
746746
</file>
747-
<file src="src/Operation/MapReduce.php">
748-
<MixedArgument>
749-
<code><![CDATA[$result->result->collection]]></code>
750-
<code><![CDATA[$result->result->db]]></code>
751-
<code><![CDATA[$this->options['typeMap']]]></code>
752-
</MixedArgument>
753-
<MixedAssignment>
754-
<code><![CDATA[$cmd[$option]]]></code>
755-
<code><![CDATA[$options['readConcern']]]></code>
756-
<code><![CDATA[$options['readPreference']]]></code>
757-
<code><![CDATA[$options['session']]]></code>
758-
<code><![CDATA[$options['writeConcern']]]></code>
759-
</MixedAssignment>
760-
<MixedMethodCall>
761-
<code><![CDATA[isInTransaction]]></code>
762-
</MixedMethodCall>
763-
</file>
764747
<file src="src/Operation/ModifyCollection.php">
765748
<MixedArgument>
766749
<code><![CDATA[$this->options['typeMap']]]></code>

src/Collection.php

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use Countable;
2121
use Iterator;
2222
use MongoDB\BSON\Document;
23-
use MongoDB\BSON\JavascriptInterface;
2423
use MongoDB\BSON\PackedArray;
2524
use MongoDB\Builder\BuilderEncoder;
2625
use MongoDB\Builder\Pipeline;
@@ -63,7 +62,6 @@
6362
use MongoDB\Operation\InsertOne;
6463
use MongoDB\Operation\ListIndexes;
6564
use MongoDB\Operation\ListSearchIndexes;
66-
use MongoDB\Operation\MapReduce;
6765
use MongoDB\Operation\RenameCollection;
6866
use MongoDB\Operation\ReplaceOne;
6967
use MongoDB\Operation\UpdateMany;
@@ -904,46 +902,6 @@ public function listSearchIndexes(array $options = []): Iterator
904902
return $operation->execute($server);
905903
}
906904

907-
/**
908-
* Executes a map-reduce aggregation on the collection.
909-
*
910-
* @see MapReduce::__construct() for supported options
911-
* @see https://mongodb.com/docs/manual/reference/command/mapReduce/
912-
* @param JavascriptInterface $map Map function
913-
* @param JavascriptInterface $reduce Reduce function
914-
* @param string|array|object $out Output specification
915-
* @param array $options Command options
916-
* @throws UnsupportedException if options are not supported by the selected server
917-
* @throws InvalidArgumentException for parameter/option parsing errors
918-
* @throws DriverRuntimeException for other driver errors (e.g. connection errors)
919-
* @throws UnexpectedValueException if the command response was malformed
920-
*/
921-
public function mapReduce(JavascriptInterface $map, JavascriptInterface $reduce, string|array|object $out, array $options = []): MapReduceResult
922-
{
923-
$hasOutputCollection = ! is_mapreduce_output_inline($out);
924-
925-
// Check if the out option is inline because we will want to coerce a primary read preference if not
926-
if ($hasOutputCollection) {
927-
$options['readPreference'] = new ReadPreference(ReadPreference::PRIMARY);
928-
} else {
929-
$options = $this->inheritReadPreference($options);
930-
}
931-
932-
/* A "majority" read concern is not compatible with inline output, so
933-
* avoid providing the Collection's read concern if it would conflict.
934-
*/
935-
if (! $hasOutputCollection || $this->readConcern->getLevel() !== ReadConcern::MAJORITY) {
936-
$options = $this->inheritReadConcern($options);
937-
}
938-
939-
$options = $this->inheritWriteOptions($options);
940-
$options = $this->inheritTypeMap($options);
941-
942-
$operation = new MapReduce($this->databaseName, $this->collectionName, $map, $reduce, $out, $options);
943-
944-
return $operation->execute(select_server_for_write($this->manager, $options));
945-
}
946-
947905
/**
948906
* Renames the collection.
949907
*

src/MapReduceResult.php

Lines changed: 0 additions & 103 deletions
This file was deleted.

0 commit comments

Comments
 (0)