Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
cfeaec21
Commit
cfeaec21
authored
Oct 24, 2017
by
Katherine Walker
Committed by
Katherine Walker
Oct 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PHPLIB-266 Support passing index hint to aggregations
parent
929704d9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
0 deletions
+25
-0
apiargs-MongoDBCollection-method-aggregate-option.yaml
...es/apiargs-MongoDBCollection-method-aggregate-option.yaml
+4
-0
Aggregate.php
src/Operation/Aggregate.php
+12
-0
AggregateTest.php
tests/Operation/AggregateTest.php
+9
-0
No files found.
docs/includes/apiargs-MongoDBCollection-method-aggregate-option.yaml
View file @
cfeaec21
...
...
@@ -34,6 +34,10 @@ post: |
Document validation requires MongoDB 3.2 or later: if you are using an earlier
version of MongoDB, this option will be ignored.
---
source
:
file
:
apiargs-MongoDBCollection-method-find-option.yaml
ref
:
hint
---
source
:
file
:
apiargs-common-option.yaml
ref
:
maxTimeMS
...
...
src/Operation/Aggregate.php
View file @
cfeaec21
...
...
@@ -74,6 +74,10 @@ class Aggregate implements Executable
* This is not supported for server versions < 3.4 and will result in an
* exception at execution time if used.
*
* * hint (string|document): The index to use. Specify either the index
* name as a string or the index key pattern as a document. If specified,
* then the query system will only consider plans using the hinted index.
*
* * maxTimeMS (integer): The maximum amount of time to allow the query to
* run.
*
...
...
@@ -146,6 +150,10 @@ class Aggregate implements Executable
throw
InvalidArgumentException
::
invalidType
(
'"collation" option'
,
$options
[
'collation'
],
'array or object'
);
}
if
(
isset
(
$options
[
'hint'
])
&&
!
is_string
(
$options
[
'hint'
])
&&
!
is_array
(
$options
[
'hint'
])
&&
!
is_object
(
$options
[
'hint'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"hint" option'
,
$options
[
'hint'
],
'string or array or object'
);
}
if
(
isset
(
$options
[
'maxTimeMS'
])
&&
!
is_integer
(
$options
[
'maxTimeMS'
]))
{
throw
InvalidArgumentException
::
invalidType
(
'"maxTimeMS" option'
,
$options
[
'maxTimeMS'
],
'integer'
);
}
...
...
@@ -272,6 +280,10 @@ class Aggregate implements Executable
$cmd
[
'collation'
]
=
(
object
)
$this
->
options
[
'collation'
];
}
if
(
isset
(
$this
->
options
[
'hint'
]))
{
$cmd
[
'hint'
]
=
$this
->
options
[
'hint'
];
}
if
(
isset
(
$this
->
options
[
'maxTimeMS'
]))
{
$cmd
[
'maxTimeMS'
]
=
$this
->
options
[
'maxTimeMS'
];
}
...
...
tests/Operation/AggregateTest.php
View file @
cfeaec21
...
...
@@ -44,6 +44,10 @@ class AggregateTest extends TestCase
$options
[][]
=
[
'collation'
=>
$value
];
}
foreach
(
$this
->
getInvalidHintValues
()
as
$value
)
{
$options
[][]
=
[
'hint'
=>
$value
];
}
foreach
(
$this
->
getInvalidIntegerValues
()
as
$value
)
{
$options
[][]
=
[
'maxTimeMS'
=>
$value
];
}
...
...
@@ -98,4 +102,9 @@ class AggregateTest extends TestCase
[
'typeMap'
=>
[
'root'
=>
'array'
],
'useCursor'
=>
false
]
);
}
private
function
getInvalidHintValues
()
{
return
[
123
,
3.14
,
true
];
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment