Skip to content

Commit

Permalink
Added support for querying indexed collections
Browse files Browse the repository at this point in the history
  • Loading branch information
mtabacman committed Jan 11, 2024
1 parent e2c5836 commit 7e0ce12
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,67 @@ GemStoneRepositoryProviderTest >> setUpRepositoryWith: aConflictCheckingStrategy
checkingConflictsAccordingTo: aConflictCheckingStrategy
]

{ #category : 'tests' }
GemStoneRepositoryProviderTest >> testFindApplyingWhenCollectionIsLarge [

4 timesRepeat: [
1000 timesRepeat: [
self extraterrestrials
store: self johnTravolta;
store: self johnLock;
store: self ellaTravolta
].

self extraterrestrials store: self silvesterStallone.

1000 timesRepeat: [
self extraterrestrials
store: self johnTravolta;
store: self johnLock;
store: self ellaTravolta
]
].
self
should: [
self
assert: ( self extraterrestrials findApplying: 'each.firstName = ''Silvester''' ) size
equals: 4
]
notTakeMoreThanMilliseconds: 1
]

{ #category : 'tests' }
GemStoneRepositoryProviderTest >> testFindApplyingWhenCollectionIsLargeAndNotIndexed [

| notIndexed |

notIndexed := GemStoneRepositoryProvider new
createRepositoryStoringObjectsOfType: Extraterrestrial
checkingConflictsAccordingTo: DoNotCheckForConflictsStrategy new.

4 timesRepeat: [
1000 timesRepeat: [
notIndexed
store: self johnTravolta;
store: self johnLock;
store: self ellaTravolta
].

notIndexed store: self silvesterStallone.

1000 timesRepeat: [
notIndexed
store: self johnTravolta;
store: self johnLock;
store: self ellaTravolta
]
].
self
should: [
self assert: ( notIndexed findApplying: 'each.firstName = ''Silvester''' ) size equals: 4 ]
notTakeMoreThanMilliseconds: 17
]

{ #category : 'tests' }
GemStoneRepositoryProviderTest >> testSpaceshipQueryingForPositiveFirepower [

Expand Down
10 changes: 9 additions & 1 deletion source/Sagan-GemStone/GemStoneRepository.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ GemStoneRepository >> findAllMatching: aCriteriaOrBlock sortedBy: aSortFunction
^ ( self findAllMatching: aCriteriaOrBlock ) sorted: aSortFunction
]

{ #category : 'querying' }
GemStoneRepository >> findApplying: aQueryString [

^ ( GsQuery fromString: aQueryString )
on: contents;
queryResult
]

{ #category : 'configuring' }
GemStoneRepository >> indexByEquality: aPath typed: aType [

Expand All @@ -84,7 +92,7 @@ GemStoneRepository >> indexByIdentity: aPath [
GemStoneRepository >> initializeCheckingConflictsAccordingTo: aConflictCheckingStrategy [

conflictCheckingStrategy := aConflictCheckingStrategy.
contents := Set new
contents := RcIdentitySet new
]

{ #category : 'private - accessing' }
Expand Down

0 comments on commit 7e0ce12

Please sign in to comment.