-
-
Notifications
You must be signed in to change notification settings - Fork 506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for timeseries #2597
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5e6e40d
ClassMetadata mapping for timeseries
cyildirim a66e407
AnnotationDriver class is set as timeseries
cyildirim 9733bad
createCollection time series support
cyildirim 3cf0a52
timeseries support in xml metadata driver
cyildirim 80f4977
removing secondary index check as timeseries support secondary index
cyildirim 87792b4
removed redundant duplicate variables in ClassMetadata
cyildirim 2997f03
SchemaManager test fix after timeseries functionality
cyildirim 651028c
add test creating a time series collection
PReimers 8b49208
fix failing CS
PReimers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -339,7 +339,7 @@ public function updateValidators(?int $maxTimeMs = null, ?WriteConcern $writeCon | |
public function updateDocumentValidator(string $documentName, ?int $maxTimeMs = null, ?WriteConcern $writeConcern = null): void | ||
{ | ||
$class = $this->dm->getClassMetadata($documentName); | ||
if ($class->isMappedSuperclass || $class->isEmbeddedDocument || $class->isQueryResultDocument || $class->isView() || $class->isFile) { | ||
if ($class->isMappedSuperclass || $class->isEmbeddedDocument || $class->isQueryResultDocument || $class->isView() || $class->isFile || $class->isTimeSeriesDocument) { | ||
throw new InvalidArgumentException('Cannot update validators for files, views, mapped super classes, embedded documents or aggregation result documents.'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Message needs to be changed |
||
} | ||
|
||
|
@@ -447,6 +447,8 @@ public function createDocumentCollection(string $documentName, ?int $maxTimeMs = | |
} | ||
|
||
$options = [ | ||
'timeseries' => $class->getCollectionTimeseries(), | ||
'expireAfterSeconds' => $class->getCollectionExpireAfterSeconds(), | ||
'capped' => $class->getCollectionCapped(), | ||
'size' => $class->getCollectionSize(), | ||
'max' => $class->getCollectionMax(), | ||
|
64 changes: 64 additions & 0 deletions
64
tests/Doctrine/ODM/MongoDB/Tests/Functional/TimeseriesCollectionsTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\ODM\MongoDB\Tests\Functional; | ||
|
||
use DateTime; | ||
use DateTimeInterface; | ||
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; | ||
use Doctrine\ODM\MongoDB\Tests\BaseTestCase; | ||
|
||
class TimeseriesCollectionsTest extends BaseTestCase | ||
{ | ||
public function testCreateTimeseriesCollectionsCapped(): void | ||
{ | ||
$sm = $this->dm->getSchemaManager(); | ||
$sm->dropDocumentCollection(TimeseriesCollectionTestDocument::class); | ||
$sm->createDocumentCollection(TimeseriesCollectionTestDocument::class); | ||
|
||
$coll = $this->dm->getDocumentCollection(TimeseriesCollectionTestDocument::class); | ||
$document = new TimeseriesCollectionTestDocument(); | ||
$document->createdAt = new DateTime('2023-12-09 00:00:00'); | ||
$document->metaData = ['foo' => 'bar']; | ||
$document->value = 1337; | ||
$this->dm->persist($document); | ||
$this->dm->flush(); | ||
|
||
$data = $coll->find()->toArray(); | ||
self::assertCount(1, $data); | ||
} | ||
} | ||
|
||
/** | ||
* @ODM\Document(collection={ | ||
* "name"="TimeseriesCollectionTest", | ||
* "capped"=true, | ||
* "size"=1000, | ||
* "max"=1, | ||
* "timeseries"={ | ||
* "timeField"="createdAt", | ||
* "metaField"="metaData", | ||
* "granularity"="seconds", | ||
* }, | ||
* "expireAfterSeconds"=60 | ||
* }) | ||
*/ | ||
class TimeseriesCollectionTestDocument | ||
{ | ||
/** @ODM\Id */ | ||
public ?string $id; | ||
|
||
/** @ODM\Field(type="date") */ | ||
public ?DateTimeInterface $createdAt; | ||
|
||
/** | ||
* @ODM\Field(type="hash") | ||
* | ||
* @var array|null | ||
*/ | ||
public ?array $metaData; | ||
Check failure on line 60 in tests/Doctrine/ODM/MongoDB/Tests/Functional/TimeseriesCollectionsTest.php
|
||
|
||
/** @ODM\Field(type="integer") */ | ||
public ?int $value; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checkout out
updateValidators
, also needs the condition to be extended