简体   繁体   English

如果数据每 30 秒出现一次,我如何按分钟或小时或天或周过滤数据,数据在某些时候不存在

[英]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的所有项目。

Item Collection物品收藏

PK PK SK SK Data数据
123 123 1674818685 1674818685 mydata我的数据
123 123 1674818656 1674818656 mydata我的数据
123 123 1674818632 1674818632 mydata我的数据
123 123 1674818611 1674818611 mydata我的数据
234 234 1674818600 1674818600 mydata我的数据
234 234 1674818612 1674818612 mydata我的数据
567 567 1674503932 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.请注意,您只能获得给定分区键的结果,如果您获得表中每个项目的结果,则需要全局二级索引。

All Items Using an Index使用索引的所有项目

GSI_PK GSI_PK SK SK Data数据 PL PL
1 1个 1674818685 1674818685 mydata我的数据 123 123
1 1个 1674818656 1674818656 mydata我的数据 123 123
1 1个 1674818632 1674818632 mydata我的数据 123 123
1 1个 1674818611 1674818611 mydata我的数据 123 123
1 1个 1674818600 1674818600 mydata我的数据 123 123
1 1个 1674818612 1674818612 mydata我的数据 123 123
1 1个 1674503932 1674503932 mydata我的数据 123 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.

相关问题 Azure Stream 分析:如果作业查询是一天明智的 TUMBLINGWINDOW,stream 分析作业何时实际处理数据? - Azure Stream Analytics: When does a stream analytics job actually process data if the job query is a day wise TUMBLINGWINDOW? 在 BigQuery 中按小时扩展时间范围 - Exploding time range hour-wise in BigQuery 在 Azure App Service 中为 Django 应用程序保存每日日志 - saving day wise logs in Azure App Service for Django Application 如何按日期对 Firestore 文档 ID 进行排序 firebase flutter - How to sort firestore document id date wise firebase flutter Stream 分析:选择自动暂停一天的最佳参数 TUMBLINGWINDOW stream 作业和为该作业设置的最佳触发时间 function - Stream Analytics: Best parameters to choose for the autopause of a day wise TUMBLINGWINDOW stream job and best trigger time to set for that function 用户明智地限制访问 s3 存储桶媒体 URL (AWS) - User wise restricted access of s3 bucket media URL (AWS) 如何访问我的 App Engine 应用程序每小时/每天/每周返回的错误数? - How can I access the number of errors that my App Engine app is returning per hour/day/week? 在这种情况下如何查询和过滤数据? - How can I query and filter data in this case? 在 BigQuery 表中按行有效地外部连接两个数组列 - Efficiently outer join two array columns row-wise in BigQuery table 如何使用 flutter 和 firebase 每天收集有限的数据? - How to collect a limited data every day using flutter and firebase?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM