[英]how can i filter data in minute wise or in hour wise or day wise or week wise if data is coming is every 30 seconds ,data is not there for some point
data is present is dynamodb and timestamp is integers and coming in the millisecond存在的数据是 dynamodb,时间戳是整数,以毫秒为单位
I just wanted that how can I solve this, suppose the user ask for minutes wise data and average as an aggregation function for that minutes, and in every minute we are getting two data point but it may be possible there is no data for some point so for that case we have explicitly check and assign 0 for those points.我只是想知道如何解决这个问题,假设用户要求分钟数据和平均值作为该分钟的聚合 function,并且每一分钟我们都会得到两个数据点,但可能某些点没有数据所以对于这种情况,我们已经明确检查并为这些点分配 0。
You cannot do functions such as aggregate on DynamoDB.您不能在 DynamoDB 上执行聚合等功能。 You can get all of the items for the last
timeframe
so long as the timeframe
is your sort-key.只要
timeframe
是您的排序键,您就可以获得最后一个timeframe
的所有项目。
PK ![]() |
SK ![]() |
Data![]() |
---|---|---|
123 ![]() |
1674818685 ![]() |
mydata![]() |
123 ![]() |
1674818656 ![]() |
mydata![]() |
123 ![]() |
1674818632 ![]() |
mydata![]() |
123 ![]() |
1674818611 ![]() |
mydata![]() |
234 ![]() |
1674818600 ![]() |
mydata![]() |
234 ![]() |
1674818612 ![]() |
mydata![]() |
567 ![]() |
1674503932 ![]() |
mydata![]() |
Given the above schema, you want all of the data for item 123
for a 1 minute time frame, you can do so like below:鉴于上述模式,您需要 1 分钟时间范围内项目
123
的所有数据,您可以像下面这样操作:
SELECT * FROM mytable WHERE PK = 123 AND SK BETWEEN time1 AND time2
Note that you can only get the results are only for a given partition key, if you the results for every item in the table you would need a Global Secondary Index.请注意,您只能获得给定分区键的结果,如果您获得表中每个项目的结果,则需要全局二级索引。
GSI_PK ![]() |
SK ![]() |
Data![]() |
PL ![]() |
---|---|---|---|
1 ![]() |
1674818685 ![]() |
mydata![]() |
123 ![]() |
1 ![]() |
1674818656 ![]() |
mydata![]() |
123 ![]() |
1 ![]() |
1674818632 ![]() |
mydata![]() |
123 ![]() |
1 ![]() |
1674818611 ![]() |
mydata![]() |
123 ![]() |
1 ![]() |
1674818600 ![]() |
mydata![]() |
123 ![]() |
1 ![]() |
1674818612 ![]() |
mydata![]() |
123 ![]() |
1 ![]() |
1674503932 ![]() |
mydata![]() |
123 ![]() |
SELECT * FROM mytable.myindex WHERE GSI_PK = 1 AND SK BETWEEN time1 AND time2
Please note, having a single item value for your GSI PK will limit your write requests to 1000 WCU, if your application requires more you will need to shard your index key .请注意,为您的 GSI PK 设置单个项目值会将您的写入请求限制为 1000 WCU,如果您的应用程序需要更多,您将需要对索引键进行分片。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.