<bdo id='awBZ3'></bdo><ul id='awBZ3'></ul>
  • <tfoot id='awBZ3'></tfoot>

    <legend id='awBZ3'><style id='awBZ3'><dir id='awBZ3'><q id='awBZ3'></q></dir></style></legend>

      1. <i id='awBZ3'><tr id='awBZ3'><dt id='awBZ3'><q id='awBZ3'><span id='awBZ3'><b id='awBZ3'><form id='awBZ3'><ins id='awBZ3'></ins><ul id='awBZ3'></ul><sub id='awBZ3'></sub></form><legend id='awBZ3'></legend><bdo id='awBZ3'><pre id='awBZ3'><center id='awBZ3'></center></pre></bdo></b><th id='awBZ3'></th></span></q></dt></tr></i><div id='awBZ3'><tfoot id='awBZ3'></tfoot><dl id='awBZ3'><fieldset id='awBZ3'></fieldset></dl></div>

      2. <small id='awBZ3'></small><noframes id='awBZ3'>

        DynamoDB 列表类型

        时间:2023-08-29

          <i id='hDQwI'><tr id='hDQwI'><dt id='hDQwI'><q id='hDQwI'><span id='hDQwI'><b id='hDQwI'><form id='hDQwI'><ins id='hDQwI'></ins><ul id='hDQwI'></ul><sub id='hDQwI'></sub></form><legend id='hDQwI'></legend><bdo id='hDQwI'><pre id='hDQwI'><center id='hDQwI'></center></pre></bdo></b><th id='hDQwI'></th></span></q></dt></tr></i><div id='hDQwI'><tfoot id='hDQwI'></tfoot><dl id='hDQwI'><fieldset id='hDQwI'></fieldset></dl></div>
          • <small id='hDQwI'></small><noframes id='hDQwI'>

              • <bdo id='hDQwI'></bdo><ul id='hDQwI'></ul>
                <legend id='hDQwI'><style id='hDQwI'><dir id='hDQwI'><q id='hDQwI'></q></dir></style></legend>

                1. <tfoot id='hDQwI'></tfoot>
                    <tbody id='hDQwI'></tbody>

                  本文介绍了DynamoDB 列表类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  I have problems understanding how to create a List for dynamoDB from my Android app. I can store and load the { "deviceId": "920e185a-63ed-46ca-bfca-f7a484ccb708" } from my app. But then to add the List and store my JSON objects as Map in the List is were i struggle.

                  The dynamoDB structure I want to create and populate looks like this in a JSON format:

                  { "data": [ { "heartBeatId": 1, "status": 1, "timeStamp": 1502183502711 }, { "heartBeatId": 2, "status": 1, "timeStamp": 1502183502812 } ], "deviceId": "90563daa-63ae-40c5-905e-9e8c02f9624f" } Then I want to populate the data List with the heartbeat object which is of Map type. { "heartBeatId": 2, "status": 1, "timeStamp": 1502183502812 } So im having problems defining the @DynamoDBTable(tableName = "heartbeat") class to create this structure.

                  I have been reading about the List and DynamoDBDocument here:

                  DynamoDBDocument

                  DataType List

                  This how the @DynamoDBTable(tableName = "heartbeat") class looks right now.

                  I hope someone can help me define it or give me clues on how to proceed getting the structure i need.

                  package com.example.android.awsdynamoapp;
                  
                  import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBAttribute;
                  import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBDocument;
                  import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBHashKey;
                  import com.amazonaws.mobileconnectors.dynamodbv2.dynamodbmapper.DynamoDBTable;
                  
                  import java.lang.annotation.Annotation;
                  import java.util.HashMap;
                  import java.util.List;
                  import java.util.Map;
                  
                  @DynamoDBTable(tableName = "heartbeat")
                  public class HeartBeat implements DynamoDBTable {
                  
                  private String deviceId;
                  private Map<String, Integer> data;
                  private List dataList;
                  
                  public HeartBeat(){};
                  public HeartBeat(String deviceId){this.deviceId = deviceId;};
                  
                  public HeartBeat(String deviceId, List dataList) {
                      this.deviceId = deviceId;
                      this.dataList = dataList;
                    //  this.timeStamp = timeStamp;
                  }
                  
                  @DynamoDBHashKey(attributeName = "deviceId")
                  public String getDeviceId() {
                      return deviceId;
                  }
                  
                  public void setDeviceId(String deviceId) {
                      this.deviceId = deviceId;
                  }
                  public void setTimeStamp(String timeStamp) {
                      //this.timeStamp = timeStamp;
                  }
                  
                  
                  public void setData(String deviceId) {
                      Map<String, Integer> data = new HashMap<>();
                  
                  }
                  
                  @DynamoDBAttribute(attributeName = "data")
                  public List getData() {
                      return this.dataList;
                  }
                  
                  @DynamoDBDocument
                  public static class JsonArray {
                      private String heartBeatId;
                      private String status;
                      private String timeStamp;
                  
                  }
                  
                  /**
                   * The name of the table to use for this class.
                   */
                  @Override
                  public String tableName() {
                      return "heartbeat";
                  }
                  
                  @Override
                  public Class<? extends Annotation> annotationType() {
                      return null;
                  }
                  }
                  

                  解决方案

                  The list of map object can be created as follows. The good thing in the above structure is that all the attributes in data is a Number. You can change it to String if needed as well. Based on your expected output, I have defined it as Long.

                  Attribute Definition:-

                  private List<Map<String, Long>> data;
                  
                  @DynamoDBAttribute(attributeName = "data")  
                  public List<Map<String, Long>> getData() {
                      return data;
                  }
                  
                  public void setData(List<Map<String, Long>> data) {
                      this.data = data;
                  }
                  

                  Populate the data:-

                      MoviesWithData movies = new MoviesWithData();
                      movies.setYearKey(1917);
                      movies.setTitle("Tilte with list of map");
                  
                      Map<String, Long> dataMap1 = new HashMap<>();
                      dataMap1.put("heartBeatId", 1L);
                      dataMap1.put("status", 1L);
                      dataMap1.put("timeStamp", 1502183502812L);
                  
                      Map<String, Long> dataMap2 = new HashMap<>();
                      dataMap2.put("heartBeatId", 2L);
                      dataMap2.put("status", 2L);
                      dataMap2.put("timeStamp", 1503183502812L);
                  
                      movies.setData(Arrays.asList(dataMap1, dataMap2));
                      dynamoDBMapper.save(movies, consistentDynamoDBMapperConfig);
                  

                  Sample output:-

                  这篇关于DynamoDB 列表类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 Swift 3 在 DynamoDB 中保留关键字 ExpressionAttr 下一篇:在objective-c中带有扫描过滤器的dynamodb scanexpress

                  相关文章

                  最新文章

                  1. <legend id='5nJqM'><style id='5nJqM'><dir id='5nJqM'><q id='5nJqM'></q></dir></style></legend>
                    <i id='5nJqM'><tr id='5nJqM'><dt id='5nJqM'><q id='5nJqM'><span id='5nJqM'><b id='5nJqM'><form id='5nJqM'><ins id='5nJqM'></ins><ul id='5nJqM'></ul><sub id='5nJqM'></sub></form><legend id='5nJqM'></legend><bdo id='5nJqM'><pre id='5nJqM'><center id='5nJqM'></center></pre></bdo></b><th id='5nJqM'></th></span></q></dt></tr></i><div id='5nJqM'><tfoot id='5nJqM'></tfoot><dl id='5nJqM'><fieldset id='5nJqM'></fieldset></dl></div>

                    <small id='5nJqM'></small><noframes id='5nJqM'>

                    • <bdo id='5nJqM'></bdo><ul id='5nJqM'></ul>
                  2. <tfoot id='5nJqM'></tfoot>