com.amazonaws.services.dynamodbv2.model.QueryRequest.getExpressionAttributeNames()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(12.2k)|赞(0)|评价(0)|浏览(66)

本文整理了Java中com.amazonaws.services.dynamodbv2.model.QueryRequest.getExpressionAttributeNames方法的一些代码示例,展示了QueryRequest.getExpressionAttributeNames的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。QueryRequest.getExpressionAttributeNames方法的具体详情如下:
包路径:com.amazonaws.services.dynamodbv2.model.QueryRequest
类名称:QueryRequest
方法名:getExpressionAttributeNames

QueryRequest.getExpressionAttributeNames介绍

[英]One or more substitution tokens for attribute names in an expression. The following are some use cases for using ExpressionAttributeNames:

  • To access an attribute whose name conflicts with a DynamoDB reserved word.
  • To create a placeholder for repeating occurrences of an attribute name in an expression.
  • To prevent special characters in an attribute name from being misinterpreted in an expression.

Use the # character in an expression to dereference an attribute name. For example, consider the following attribute name:

  • Percentile

The name of this attribute conflicts with a reserved word, so it cannot be used directly in an expression. (For the complete list of reserved words, see Reserved Words in the Amazon DynamoDB Developer Guide). To work around this, you could specify the following for ExpressionAttributeNames:

  • {"#P":"Percentile"}

You could then use this substitution in an expression, as in this example:

  • #P = :val

Tokens that begin with the : character are expression attribute values, which are placeholders for the actual value at runtime.

For more information on expression attribute names, see Accessing Item Attributes in the Amazon DynamoDB Developer Guide.
[中]表达式中属性名称的一个或多个替换标记。以下是使用ExpressionAttributeNames的一些用例:
*访问名称与DynamoDB保留字冲突的属性。
*为表达式中重复出现的属性名称创建占位符。
*防止属性名称中的特殊字符在表达式中被误解。
在表达式中使用#字符取消对属性名称的引用。例如,考虑下面的属性名称:

  • Percentile
    此属性的名称与保留字冲突,因此不能直接在表达式中使用。(有关保留字的完整列表,请参阅《Amazon DynamoDB开发人员指南》中的{$0$})。要解决这个问题,您可以为ExpressionAttributeNames指定以下内容:
  • {"#P":"Percentile"}
    然后可以在表达式中使用此替换,如本例所示:
  • #P = :val
    以:字符开头的标记是表达式属性值,它是运行时实际值的占位符。
    有关表达式属性名称的更多信息,请参阅《Amazon DynamoDB开发人员指南》中的Accessing Item Attributes

代码示例

代码示例来源:origin: aws/aws-sdk-java

if (getKeyConditionExpression() != null)
  sb.append("KeyConditionExpression: ").append(getKeyConditionExpression()).append(",");
if (getExpressionAttributeNames() != null)
  sb.append("ExpressionAttributeNames: ").append(getExpressionAttributeNames()).append(",");
if (getExpressionAttributeValues() != null)
  sb.append("ExpressionAttributeValues: ").append(getExpressionAttributeValues());

代码示例来源:origin: aws/aws-sdk-java

@Override
public int hashCode() {
  final int prime = 31;
  int hashCode = 1;
  hashCode = prime * hashCode + ((getTableName() == null) ? 0 : getTableName().hashCode());
  hashCode = prime * hashCode + ((getIndexName() == null) ? 0 : getIndexName().hashCode());
  hashCode = prime * hashCode + ((getSelect() == null) ? 0 : getSelect().hashCode());
  hashCode = prime * hashCode + ((getAttributesToGet() == null) ? 0 : getAttributesToGet().hashCode());
  hashCode = prime * hashCode + ((getLimit() == null) ? 0 : getLimit().hashCode());
  hashCode = prime * hashCode + ((getConsistentRead() == null) ? 0 : getConsistentRead().hashCode());
  hashCode = prime * hashCode + ((getKeyConditions() == null) ? 0 : getKeyConditions().hashCode());
  hashCode = prime * hashCode + ((getQueryFilter() == null) ? 0 : getQueryFilter().hashCode());
  hashCode = prime * hashCode + ((getConditionalOperator() == null) ? 0 : getConditionalOperator().hashCode());
  hashCode = prime * hashCode + ((getScanIndexForward() == null) ? 0 : getScanIndexForward().hashCode());
  hashCode = prime * hashCode + ((getExclusiveStartKey() == null) ? 0 : getExclusiveStartKey().hashCode());
  hashCode = prime * hashCode + ((getReturnConsumedCapacity() == null) ? 0 : getReturnConsumedCapacity().hashCode());
  hashCode = prime * hashCode + ((getProjectionExpression() == null) ? 0 : getProjectionExpression().hashCode());
  hashCode = prime * hashCode + ((getFilterExpression() == null) ? 0 : getFilterExpression().hashCode());
  hashCode = prime * hashCode + ((getKeyConditionExpression() == null) ? 0 : getKeyConditionExpression().hashCode());
  hashCode = prime * hashCode + ((getExpressionAttributeNames() == null) ? 0 : getExpressionAttributeNames().hashCode());
  hashCode = prime * hashCode + ((getExpressionAttributeValues() == null) ? 0 : getExpressionAttributeValues().hashCode());
  return hashCode;
}

代码示例来源:origin: aws/aws-sdk-java

if (other.getKeyConditionExpression() != null && other.getKeyConditionExpression().equals(this.getKeyConditionExpression()) == false)
  return false;
if (other.getExpressionAttributeNames() == null ^ this.getExpressionAttributeNames() == null)
  return false;
if (other.getExpressionAttributeNames() != null && other.getExpressionAttributeNames().equals(this.getExpressionAttributeNames()) == false)
  return false;
if (other.getExpressionAttributeValues() == null ^ this.getExpressionAttributeValues() == null)

代码示例来源:origin: aws/aws-sdk-java

/**
 * Marshall the given parameter object.
 */
public void marshall(QueryRequest queryRequest, ProtocolMarshaller protocolMarshaller) {
  if (queryRequest == null) {
    throw new SdkClientException("Invalid argument passed to marshall(...)");
  }
  try {
    protocolMarshaller.marshall(queryRequest.getTableName(), TABLENAME_BINDING);
    protocolMarshaller.marshall(queryRequest.getIndexName(), INDEXNAME_BINDING);
    protocolMarshaller.marshall(queryRequest.getSelect(), SELECT_BINDING);
    protocolMarshaller.marshall(queryRequest.getAttributesToGet(), ATTRIBUTESTOGET_BINDING);
    protocolMarshaller.marshall(queryRequest.getLimit(), LIMIT_BINDING);
    protocolMarshaller.marshall(queryRequest.getConsistentRead(), CONSISTENTREAD_BINDING);
    protocolMarshaller.marshall(queryRequest.getKeyConditions(), KEYCONDITIONS_BINDING);
    protocolMarshaller.marshall(queryRequest.getQueryFilter(), QUERYFILTER_BINDING);
    protocolMarshaller.marshall(queryRequest.getConditionalOperator(), CONDITIONALOPERATOR_BINDING);
    protocolMarshaller.marshall(queryRequest.getScanIndexForward(), SCANINDEXFORWARD_BINDING);
    protocolMarshaller.marshall(queryRequest.getExclusiveStartKey(), EXCLUSIVESTARTKEY_BINDING);
    protocolMarshaller.marshall(queryRequest.getReturnConsumedCapacity(), RETURNCONSUMEDCAPACITY_BINDING);
    protocolMarshaller.marshall(queryRequest.getProjectionExpression(), PROJECTIONEXPRESSION_BINDING);
    protocolMarshaller.marshall(queryRequest.getFilterExpression(), FILTEREXPRESSION_BINDING);
    protocolMarshaller.marshall(queryRequest.getKeyConditionExpression(), KEYCONDITIONEXPRESSION_BINDING);
    protocolMarshaller.marshall(queryRequest.getExpressionAttributeNames(), EXPRESSIONATTRIBUTENAMES_BINDING);
    protocolMarshaller.marshall(queryRequest.getExpressionAttributeValues(), EXPRESSIONATTRIBUTEVALUES_BINDING);
  } catch (Exception e) {
    throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
  }
}

代码示例来源:origin: aws-amplify/aws-sdk-android

if (getKeyConditionExpression() != null)
  sb.append("KeyConditionExpression: " + getKeyConditionExpression() + ",");
if (getExpressionAttributeNames() != null)
  sb.append("ExpressionAttributeNames: " + getExpressionAttributeNames() + ",");
if (getExpressionAttributeValues() != null)
  sb.append("ExpressionAttributeValues: " + getExpressionAttributeValues());

代码示例来源:origin: aws-amplify/aws-sdk-android

hashCode = prime
    + ((getExpressionAttributeNames() == null) ? 0 : getExpressionAttributeNames()
        .hashCode());
hashCode = prime

代码示例来源:origin: aws-amplify/aws-sdk-android

&& other.getKeyConditionExpression().equals(this.getKeyConditionExpression()) == false)
  return false;
if (other.getExpressionAttributeNames() == null
    ^ this.getExpressionAttributeNames() == null)
  return false;
if (other.getExpressionAttributeNames() != null
    && other.getExpressionAttributeNames().equals(this.getExpressionAttributeNames()) == false)
  return false;
if (other.getExpressionAttributeValues() == null

代码示例来源:origin: aws-amplify/aws-sdk-android

jsonWriter.value(keyConditionExpression);
if (queryRequest.getExpressionAttributeNames() != null) {
  java.util.Map<String, String> expressionAttributeNames = queryRequest
      .getExpressionAttributeNames();
  jsonWriter.name("ExpressionAttributeNames");
  jsonWriter.beginObject();

代码示例来源:origin: com.amazonaws/aws-java-sdk-dynamodb

if (getKeyConditionExpression() != null)
  sb.append("KeyConditionExpression: ").append(getKeyConditionExpression()).append(",");
if (getExpressionAttributeNames() != null)
  sb.append("ExpressionAttributeNames: ").append(getExpressionAttributeNames()).append(",");
if (getExpressionAttributeValues() != null)
  sb.append("ExpressionAttributeValues: ").append(getExpressionAttributeValues());

代码示例来源:origin: com.amazonaws/aws-java-sdk-dynamodb

@Override
public int hashCode() {
  final int prime = 31;
  int hashCode = 1;
  hashCode = prime * hashCode + ((getTableName() == null) ? 0 : getTableName().hashCode());
  hashCode = prime * hashCode + ((getIndexName() == null) ? 0 : getIndexName().hashCode());
  hashCode = prime * hashCode + ((getSelect() == null) ? 0 : getSelect().hashCode());
  hashCode = prime * hashCode + ((getAttributesToGet() == null) ? 0 : getAttributesToGet().hashCode());
  hashCode = prime * hashCode + ((getLimit() == null) ? 0 : getLimit().hashCode());
  hashCode = prime * hashCode + ((getConsistentRead() == null) ? 0 : getConsistentRead().hashCode());
  hashCode = prime * hashCode + ((getKeyConditions() == null) ? 0 : getKeyConditions().hashCode());
  hashCode = prime * hashCode + ((getQueryFilter() == null) ? 0 : getQueryFilter().hashCode());
  hashCode = prime * hashCode + ((getConditionalOperator() == null) ? 0 : getConditionalOperator().hashCode());
  hashCode = prime * hashCode + ((getScanIndexForward() == null) ? 0 : getScanIndexForward().hashCode());
  hashCode = prime * hashCode + ((getExclusiveStartKey() == null) ? 0 : getExclusiveStartKey().hashCode());
  hashCode = prime * hashCode + ((getReturnConsumedCapacity() == null) ? 0 : getReturnConsumedCapacity().hashCode());
  hashCode = prime * hashCode + ((getProjectionExpression() == null) ? 0 : getProjectionExpression().hashCode());
  hashCode = prime * hashCode + ((getFilterExpression() == null) ? 0 : getFilterExpression().hashCode());
  hashCode = prime * hashCode + ((getKeyConditionExpression() == null) ? 0 : getKeyConditionExpression().hashCode());
  hashCode = prime * hashCode + ((getExpressionAttributeNames() == null) ? 0 : getExpressionAttributeNames().hashCode());
  hashCode = prime * hashCode + ((getExpressionAttributeValues() == null) ? 0 : getExpressionAttributeValues().hashCode());
  return hashCode;
}

代码示例来源:origin: com.amazonaws/aws-java-sdk-dynamodb

if (other.getKeyConditionExpression() != null && other.getKeyConditionExpression().equals(this.getKeyConditionExpression()) == false)
  return false;
if (other.getExpressionAttributeNames() == null ^ this.getExpressionAttributeNames() == null)
  return false;
if (other.getExpressionAttributeNames() != null && other.getExpressionAttributeNames().equals(this.getExpressionAttributeNames()) == false)
  return false;
if (other.getExpressionAttributeValues() == null ^ this.getExpressionAttributeValues() == null)

代码示例来源:origin: com.amazonaws/aws-java-sdk-dynamodb

/**
 * Marshall the given parameter object.
 */
public void marshall(QueryRequest queryRequest, ProtocolMarshaller protocolMarshaller) {
  if (queryRequest == null) {
    throw new SdkClientException("Invalid argument passed to marshall(...)");
  }
  try {
    protocolMarshaller.marshall(queryRequest.getTableName(), TABLENAME_BINDING);
    protocolMarshaller.marshall(queryRequest.getIndexName(), INDEXNAME_BINDING);
    protocolMarshaller.marshall(queryRequest.getSelect(), SELECT_BINDING);
    protocolMarshaller.marshall(queryRequest.getAttributesToGet(), ATTRIBUTESTOGET_BINDING);
    protocolMarshaller.marshall(queryRequest.getLimit(), LIMIT_BINDING);
    protocolMarshaller.marshall(queryRequest.getConsistentRead(), CONSISTENTREAD_BINDING);
    protocolMarshaller.marshall(queryRequest.getKeyConditions(), KEYCONDITIONS_BINDING);
    protocolMarshaller.marshall(queryRequest.getQueryFilter(), QUERYFILTER_BINDING);
    protocolMarshaller.marshall(queryRequest.getConditionalOperator(), CONDITIONALOPERATOR_BINDING);
    protocolMarshaller.marshall(queryRequest.getScanIndexForward(), SCANINDEXFORWARD_BINDING);
    protocolMarshaller.marshall(queryRequest.getExclusiveStartKey(), EXCLUSIVESTARTKEY_BINDING);
    protocolMarshaller.marshall(queryRequest.getReturnConsumedCapacity(), RETURNCONSUMEDCAPACITY_BINDING);
    protocolMarshaller.marshall(queryRequest.getProjectionExpression(), PROJECTIONEXPRESSION_BINDING);
    protocolMarshaller.marshall(queryRequest.getFilterExpression(), FILTEREXPRESSION_BINDING);
    protocolMarshaller.marshall(queryRequest.getKeyConditionExpression(), KEYCONDITIONEXPRESSION_BINDING);
    protocolMarshaller.marshall(queryRequest.getExpressionAttributeNames(), EXPRESSIONATTRIBUTENAMES_BINDING);
    protocolMarshaller.marshall(queryRequest.getExpressionAttributeValues(), EXPRESSIONATTRIBUTEVALUES_BINDING);
  } catch (Exception e) {
    throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e);
  }
}

相关文章

微信公众号

最新文章

更多

QueryRequest类方法