[英]How to do arithmetic operations (+,-,/,*,%) inside a AWS cloud with the Data in a DynamoDB table
Can some one help me and please let me know,Which tool in AWS I should use to perform math operations such as add/sub/mul/div/mod etc with data inside a dynamodb table? 有人可以帮我吗,请让我知道,我应该使用哪个AWS工具来对dynamodb表中的数据执行数学运算,例如add / sub / mul / div / mod等? Currently I am hosting my data inside DynamoDB via raspberry Pi using python as my programming language.
目前,我正在使用python作为编程语言通过raspberry Pi将数据托管在DynamoDB中。 But with that raw data I need to do some computations.
但是,利用这些原始数据,我需要进行一些计算。 Initially,I want to start with trying small computations.
最初,我想从尝试小型计算开始。
So Which tool is helpful to do computations inside cloud such as doing some math and finding whether the number is even number or not ,giving some input and performing some algorithm and finding the result? 那么,哪个工具对在云内部进行计算(例如做一些数学运算以及查找数字是否为偶数,给出一些输入并执行一些算法并找到结果)有用呢? I just want to pick data from my table residing in DynamoDB and do these computations.I saw Redshift in google but its little expensive,will it be possible to use that and load the data from dynamoDB to redshift and do the math operations or there any better alternate options?
我只想从驻留在DynamoDB中的表中选择数据并进行这些计算。我在Google中看到Redshift,但是它有点贵,是否可以使用它并从dynamoDB加载数据以进行redshift并进行数学运算或进行任何其他操作更好的替代选择? Will you please share me any links that will help me to start with?
您能否分享给我任何可以帮助我入手的链接?
Thank you very much . 非常感谢你 。
In DynamoDB, you can only increment and decrement numeric attributes using the + (plus) and - (minus) operators in the SET
action of an UpdateExpression
in update_item or the ADD
action if only both; 在DynamoDB,你只能增加或减少使用+(加号)和数字属性- (减号)运营商在
SET
的作用UpdateExpression
在update_item或ADD
动作如果只有两个; the existing attribute is a number and the value is also a number. 现有属性是数字,值也是数字。
Otherwise, you should perform your desired math operations against attribute values before updating them in DynamoDB. 否则,您应该在DynamoDB中更新属性值之前对属性值执行所需的数学运算。
Note on ADD
: 注意
ADD
:
If you use
ADD
to increment or decrement a number value for an item that doesn't exist before the update, DynamoDB uses 0 as the initial value.如果使用
ADD
递增或递减更新前不存在的项目的数值,则DynamoDB使用0作为初始值。 Similarly, if you useADD
for an existing item to increment or decrement an attribute value that doesn't exist before the update, DynamoDB uses 0 as the initial value.同样,如果对现有项目使用
ADD
来增加或减少更新之前不存在的属性值,则DynamoDB会将0用作初始值。
For example: 例如:
response = client.update_item(
ExpressionAttributeNames={
'#C': 'Count'
},
ExpressionAttributeValues={
':val': {
'N': '1'
}
},
Key={
'ItemId': {
'S': 'BC3AB494-EDD8-4F47-B80F-32ACA92D8C5C'
}
},
ReturnValues='ALL_NEW',
TableName='MyTable',
UpdateExpression='SET #C = #C - :val'
)
print(response)
See also: Incrementing and Decrementing Numeric Attributes . 另请参阅: 递增和递减数值属性 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.