2

I am migrating an application from Cassandra to DynamoDB. On Cassandra we used as key a combination of (entityName,TimeUUID), with DynamoDB as far as I have read I could use a Hash+Range Primary Key.

To mantain the same data structure of the Cassandra Database I have been thinking of using entityName as Hash and timestamp as range. Then, I thought that maybe the timestamps might not be Unique: I am speaking of corner cases, but the Cassandra Primary Key (entityName,TimeUUID) is more powerful than the DynamoDB Hash+Range (entityName, timestamp), since it allows the existence of elements with the same entityName and timestamp.

Can I use Cassandra's TimeUUID as DynamoDb's range? Are there any reason why I should not use this approach?

4

1 回答 1

2

你可以(并且应该,如果你认为你可以在 上发生碰撞timestamp)。我能想到的唯一问题是您可能必须between time_x and time_y Query自己处理。

例如,假设您的表中有以下 5 个项目:

  • 香港:h1。RK:t1_uuid1
  • 香港:h1。RK:t1_uuid2
  • 香港:h1。RK:t2_uuid3
  • 香港:h1。RK:t3_uuid4
  • 香港:h2。RK:t4_uuid5

此外,假设t1< t2<t3和 UUID 是 4 个字符串,介于aaaazzzz

现在,如果您需要 HKh1和 RK 在t1和之间的所有项目t2,那么您Query将包含类似between t1_aaaa and t2_zzzz.

这是因为 DynamoDB 本身并不像 Cassandra 那样理解 TimeUUID 的概念。因此,您必须在应用程序层中处理上述情况。

于 2016-06-15T08:53:49.793 回答