簡體   English   中英

如何使用java對Amazon dynamodb中的數據進行排序

[英]How to sort the data in Amazon dynamodb using java

如何使用java在amazon dynamodb中按升序或降序對countryCode列數據進行排序

如何在代碼中使用SortOrder enum

SortOrder枚舉在com.amazonaws.services.codedeploy.model.SortOrder包中com.amazonaws.services.codedeploy.model.SortOrder

import java.io.Serializable;

import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAutoGeneratedKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;

@DynamoDBTable(tableName = "cd_country")
public class Country implements Serializable {

    private static final long serialVersionUID = 5698425418072128936L;

    @DynamoDBAutoGeneratedKey
    @DynamoDBHashKey
    private String countryId;

    private String countryCode;

    private String countryName;

    private Long isActive;

    public String getCountryId() {
        return countryId;
    }

    public void setCountryId(String countryId) {
        this.countryId = countryId;
    }

    public String getCountryCode() {
        return countryCode;
    }

    public void setCountryCode(String countryCode) {
        this.countryCode = countryCode;
    }

    public String getCountryName() {
        return countryName;
    }

    public void setCountryName(String countryName) {
        this.countryName = countryName;
    }

    public Long getIsActive() {
        return isActive;
    }

    public void setIsActive(Long isActive) {
        this.isActive = isActive;
    }

}

您無法對countryCode排序,因為其上沒有索引 您必須使用Scan來獲取所有行並對應用程序中的數據進行排序。

旁注: countryCode不是 DynamoDB 中的列 - 它是一個屬性。 有關更多信息,請參閱DynamoDB數據模型。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM