Comments (8)
Interesting, I didn't know that there is no uniqueness guarantee on GSI. Changing the signature of retrieve
to Stream[F, T]
is a bit weird since SimpleTable
and local version of SecondarySimpleIndex
use F[Option[T]]
and it fits a bit better in those cases. IMHO, the hierarchy should be:
sealed abstract class SimpleIndex[F[_]: Async, P: Encoder] {
...
def retrieve[T: Decoder](
query: Query[P, Nothing],
consistentRead: Boolean
)(implicit RT: RaiseThrowable[F]): F[Option[T]]
}
case class SimpleLSI[F[_]: Async, P: Encoder](
tableName: String,
indexName: String,
partitionKeyDef: KeyDef[P],
jClient: DynamoDbAsyncClient
) extends SimpleIndex[F, P] {
...
}
case class SimpleGSI[F[_]: Async, P: Encoder](
tableName: String,
indexName: String,
partitionKeyDef: KeyDef[P],
jClient: DynamoDbAsyncClient
) extends SimpleIndex[F, P] {
def retrieveAll[T: Decoder](
query: Query[P, Nothing],
consistentRead: Boolean
)(implicit RT: RaiseThrowable[F]): Stream[F, T]
}
What I'm proposing is to replace SecondarySimpleIndex
with SimpleLSI
and SimpleGSI
so that retrieve
's signature doesn't change and retrieveAll
can be introduced to SimpleGSI
. WDYT?
from meteor.
Is a SimpleLSI actually possible? I believe an LSI has to have a sort key.
from meteor.
I could see either side for only having retrieve return a stream vs have a retrieve/retrieveAll. Allowing a retrieve that returns F[Option[T]]
that might actually arbitrarily select the last element (and if accidentally really mis-used, only after streaming through many records -- perhaps the implementation should change to be .head.compile.last
...). But it's also true that someone may have a GSI with a guaranteed-to-be-unique partition key (I have such use-cases myself) and that retrieve
would read more clearly than having to add .compile.last
.
from meteor.
Is a SimpleLSI actually possible? I believe an LSI has to have a sort key.
that is a good point, I think I've found a fix for this. I moved SecondarySimpleIndex
to extends CompositeIndex
in this branch, the signature of retrieve
fits better there, the only downside is naming. WDYT? https://github.com/d2a4u/meteor/pull/234/files#diff-06c5a4f5c02eebaa484b12addf3b0efc009b69d1e93124501aac37d7dbf31183R59
from meteor.
Seems ok to me, let's me do what I need:
byAuthorIndex.retrieve[Book](
Query(partitionKey = "Jules Verne"),
limit = 100
)
The hacky SecondaryCompositeIndex in my original post has the nicer ergonomics of not needing to wrap in a query though which would be nice for SecondarySimpleIndex
:
byAuthorIndexFixed.retrieve[Book](
"Jules Verne", limit = 100
)
from meteor.
it is a overloading method so the signature has been changed to this
from meteor.
Looks good to me!
from meteor.
This is now fixed in latest version: v1.0.14. It should have been bumped to 1.1.0 but there seems to be an issue with CI versioning bump. Apologies.
from meteor.
Related Issues (14)
- Publish scaladoc HOT 2
- The default Encoder[Instant] instance fails for dates very far in the future HOT 1
- Consider Removing Limit From Query Interface HOT 4
- Any plan to support scala 3? HOT 11
- scalajs support
- Composite sort key ergonomics HOT 1
- Add support for `scanIndexForward`
- Why is the jClient a member of the tables? HOT 1
- Support ConditionExpression for DeleteItem HOT 3
- On Decoding error, the Dynosaur Conversions do not propagate error message
- Please publish meteor-dynosaur 1.0.55 for Scala 2.13
- ExpressionAttributeValues must not be empty
- Support BatchWriteItem
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor.