• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java GetItemRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.services.dynamodbv2.model.GetItemRequest的典型用法代码示例。如果您正苦于以下问题:Java GetItemRequest类的具体用法?Java GetItemRequest怎么用?Java GetItemRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GetItemRequest类属于com.amazonaws.services.dynamodbv2.model包,在下文中一共展示了GetItemRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: fetchTheValue

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
private void fetchTheValue() {

        final GetItemRequest req = new GetItemRequest().withAttributesToGet("value")
                .withTableName(TableName)
                .withKey(Collections.singletonMap("id", new AttributeValue(this.id)));
        try {
            final GetItemResult result = ddb.getItem(req);
            synchronized (this.monitor) {
                if (result.getItem() == null) {
                    this.x = new RuntimeException("not found: id=" + this.id);
                } else {
                    this.v = result.getItem().get("value").getS();
                    if (this.v == null) {
                        this.x = new RuntimeException("found but no value for: id=" + this.id);
                    }
                }
            }
        } catch (final RuntimeException x) {
            synchronized (this.monitor) {
                this.x = x;
            }
        }

    }
 
开发者ID:aztecrex,项目名称:java-translatebot,代码行数:25,代码来源:DBValueRetriever.java


示例2: get

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
/**
 * Get ticket.
 *
 * @param ticketId the ticket id
 * @return the ticket
 */
public Ticket get(final String ticketId) {
    final TicketDefinition metadata = this.ticketCatalog.find(ticketId);
    if (metadata != null) {
        final Map<String, AttributeValue> keys = new HashMap<>();

        keys.put(ColumnNames.ID.getName(), new AttributeValue(ticketId));
        final GetItemRequest request = new GetItemRequest()
                .withKey(keys)
                .withTableName(metadata.getProperties().getStorageName());

        LOGGER.debug("Submitting request [{}] to get ticket item [{}]", request, ticketId);

        final Map<String, AttributeValue> returnItem = amazonDynamoDBClient.getItem(request).getItem();
        if (returnItem != null) {
            final Ticket ticket = deserializeTicket(returnItem);
            LOGGER.debug("Located ticket [{}]", ticket);
            return ticket;
        }
    } else {
        LOGGER.warn("No ticket definition could be found in the catalog to match [{}]", ticketId);
    }
    return null;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:30,代码来源:DynamoDbTicketRegistryFacilitator.java


示例3: fetchChannelLanguages

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
private Collection<String> fetchChannelLanguages(final String channel) {

        final String id = "channel:" + channel + ":languages";
        final GetItemRequest getItemRequest = new GetItemRequest()
                .withAttributesToGet(Collections.singletonList("value"))
                .withKey(Collections.singletonMap("id", new AttributeValue(id)))
                .withTableName(TableName);
        final GetItemResult getItemResult = ddb.getItem(getItemRequest);
        final Optional<String> maybeValue = Optional.ofNullable(getItemResult.getItem())
                .map(i -> i.get("value"))
                .map(AttributeValue::getS);
        if (!maybeValue.isPresent())
            return Collections.emptyList();

        return Arrays.asList(maybeValue.get().trim().split(" +"));
    }
 
开发者ID:aztecrex,项目名称:java-translatebot,代码行数:17,代码来源:CommandHandler.java


示例4: doInBackground

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
protected DDBTaskResult doInBackground(Void... params) {

		Log.i("doInBackground", "Starting DDBGettask");
		
		DDBTaskResult result = new DDBTaskResult();

		try {
			// Need to specify the key of our item, which is a Map of our primary key attribute(s)
			Map<String, AttributeValue> key = new HashMap<String, AttributeValue>();
			key.put("userid", new AttributeValue().withS("user1234"));
			key.put("recordid", new AttributeValue().withS("highScore"));
			 
			GetItemRequest getItemRequest = new GetItemRequest(AWSClientManager.DDB_TABLE_NAME,key);
			GetItemResult getItemResult = ddb.getItem(getItemRequest);
			 
			result.setAttributeNumber(Integer.parseInt(getItemResult.getItem().get("data").getN()));
			
		} catch (AmazonServiceException ex) {
			ex.printStackTrace();
			Log.e("ddb-get-doInBackground", ex.getMessage());
		}
	
		return result;
	}
 
开发者ID:jinman,项目名称:snake-game-aws,代码行数:25,代码来源:DDBGetTask.java


示例5: getRowByKey

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
/**
 * Get item of table with provided key-value.
 * 
 * @param tableName
 * @param combinedKey
 * @return
 */
public static Row getRowByKey(String tableName, Key... combinedKey) {
	Map<String, AttributeValue> transformedKey = new HashMap<>();
	for (Key key : combinedKey) {
		transformedKey.put(key.getName(),
				new AttributeValue().withS(key.getValue()));
	}

	GetItemResult result = DynamoDbHandler.CLIENT
			.getItem(new GetItemRequest(tableName, transformedKey));

	List<Attribute> attributes = new ArrayList<>();
	for (String resultKey : result.getItem().keySet()) {
		attributes.add(new Attribute(resultKey, result.getItem()
				.get(resultKey).getS()));
	}

	return new Row(attributes);
}
 
开发者ID:raethlein,项目名称:ColumnStoreUnifier,代码行数:26,代码来源:DynamoDbQueryHandler.java


示例6: readRow

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
private Map<String, AttributeValue> readRow(String key, String appid) {
	if (StringUtils.isBlank(key) || StringUtils.isBlank(appid)) {
		return null;
	}
	Map<String, AttributeValue> row = null;
	try {
		GetItemRequest getItemRequest = new GetItemRequest(getTableNameForAppid(appid),
				Collections.singletonMap(Config._KEY, new AttributeValue(getKeyForAppid(key, appid))));
		GetItemResult res = client().getItem(getItemRequest);
		if (res != null && res.getItem() != null && !res.getItem().isEmpty()) {
			row = res.getItem();
		}
	} catch (Exception e) {
		logger.error("Could not read row from DB - appid={}, key={}", appid, key, e);
	}
	return (row == null || row.isEmpty()) ? null : row;
}
 
开发者ID:Erudika,项目名称:para,代码行数:18,代码来源:AWSDynamoDAO.java


示例7: get

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
public <T> T get(String tableName, Map<String, AttributeValue> key, final ObjectExtractor<T> extractor, String... columnsToInclude) throws EmptyResultDataAccessException {
    Assert.notNull(tableName, "Table must not be null");
    Assert.notNull(extractor, "ObjectExtractor must not be null");
    if (logger.isDebugEnabled()) {
        logger.debug("Executing query on " + tableName + " for " + renderKey(key));
    }

    GetItemRequest request = new GetItemRequest(tableName, key, true);
    if (columnsToInclude != null && columnsToInclude.length > 0) {
        request.setAttributesToGet(Arrays.asList(columnsToInclude));
    }

    GetItemResult result = client.getItem(request);

    Map<String, AttributeValue> item = result.getItem();
    if (item == null) {
        throw new EmptyResultDataAccessException("No results found in " + tableName + "for " + renderKey(key));
    }

    return extractor.extract(item);
}
 
开发者ID:Vivastream,项目名称:spring-security-oauth2-dynamodb,代码行数:22,代码来源:DynamoDBTemplate.java


示例8: retrieveItem

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
private static void retrieveItem() {
    try {
        
        HashMap<String, AttributeValue> key = new HashMap<String, AttributeValue>();
        key.put("Id", new AttributeValue().withN("120"));
        GetItemRequest getItemRequest = new GetItemRequest()
            .withTableName(tableName)
            .withKey(key)
            .withProjectionExpression("Id, ISBN, Title, Authors");
        
        GetItemResult result = client.getItem(getItemRequest);

        // Check the response.
        System.out.println("Printing item after retrieving it....");
        printItem(result.getItem());            
                    
    }  catch (AmazonServiceException ase) {
                System.err.println("Failed to retrieve item in " + tableName);
    }   

}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:22,代码来源:LowLevelItemCRUDExample.java


示例9: retrieveItem

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
public static void retrieveItem(String threadId, String replyDateTime) throws IOException {
    HashMap<String, AttributeValue> key = new HashMap<String, AttributeValue>();
    key.put("Id", new AttributeValue().withS(threadId));
    key.put("ReplyDateTime", new AttributeValue().withS(replyDateTime));
    
    GetItemRequest getReplyRequest = new GetItemRequest()
        .withTableName(tableName)
        .withKey(key)
        .withConsistentRead(true);
    
    GetItemResult getReplyResult = client.getItem(getReplyRequest);
    
    // Decompress the reply message and print
    Map<String, AttributeValue> reply = getReplyResult.getItem();
    String message = decompressString(reply.get("ExtendedMessage").getB());
    System.out.println("Reply message:\n"
        + " Id: " + reply.get("Id").getS() + "\n" 
        + " ReplyDateTime: " + reply.get("ReplyDateTime").getS() + "\n" 
        + " PostedBy: " + reply.get("PostedBy").getS() + "\n"
        + " Message: " + reply.get("Message").getS() + "\n"
        + " ExtendedMessage (decompressed): " + message);
}
 
开发者ID:awslabs,项目名称:aws-dynamodb-examples,代码行数:23,代码来源:LowLevelItemBinaryExample.java


示例10: describeUser

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
/**
 * Returns the list of usernames stored in the user table.
 */
public void describeUser(String username, String userTable) {
    HashMap<String, AttributeValue> key = new HashMap<String, AttributeValue>();
    key.put("username", new AttributeValue().withS(username));

    GetItemRequest getItemRequest = new GetItemRequest()
            .withTableName(userTable)
            .withKey(key);

    Map<String, AttributeValue> list = ddb.getItem(getItemRequest).getItem();
    if (list.isEmpty()) {
        System.err.println("No record found for username '" + username + "'");
        return;
    }

    for (Entry<String, AttributeValue> entry : list.entrySet()) {
        System.out.println(entry.getKey() + " = " + entry.getValue().getS());
    }
}
 
开发者ID:aws-samples,项目名称:reinvent2013-mobile-photo-share,代码行数:22,代码来源:DescribeUser.java


示例11: executePrimaryKeyLookupQuery

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
@Override
protected Row executePrimaryKeyLookupQuery(Table table, List<SelectItem> selectItems, Column primaryKeyColumn,
        Object keyValue) {
    final List<String> attributeNames = new ArrayList<>();
    for (SelectItem selectItem : selectItems) {
        attributeNames.add(selectItem.getColumn().getName());
    }

    final GetItemRequest getItemRequest = new GetItemRequest(table.getName(), Collections.singletonMap(
            primaryKeyColumn.getName(), DynamoDbUtils.toAttributeValue(keyValue))).withAttributesToGet(
                    attributeNames);
    final GetItemResult item = _dynamoDb.getItem(getItemRequest);

    final Object[] values = new Object[selectItems.size()];
    for (int i = 0; i < values.length; i++) {
        final AttributeValue attributeValue = item.getItem().get(attributeNames.get(i));
        values[i] = DynamoDbUtils.toValue(attributeValue);
    }

    return new DefaultRow(new SimpleDataSetHeader(selectItems), values);
}
 
开发者ID:apache,项目名称:metamodel,代码行数:22,代码来源:DynamoDbDataContext.java


示例12: getPoint

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
public GetPointResult getPoint(GetPointRequest getPointRequest) {
	long geohash = S2Manager.generateGeohash(getPointRequest.getGeoPoint());
	long hashKey = S2Manager.generateHashKey(geohash, config.getHashKeyLength());

	GetItemRequest getItemRequest = getPointRequest.getGetItemRequest();
	getItemRequest.setTableName(config.getTableName());

	AttributeValue hashKeyValue = new AttributeValue().withN(String.valueOf(hashKey));
	getItemRequest.getKey().put(config.getHashKeyAttributeName(), hashKeyValue);
	getItemRequest.getKey().put(config.getRangeKeyAttributeName(), getPointRequest.getRangeKeyValue());

	GetItemResult getItemResult = config.getDynamoDBClient().getItem(getItemRequest);
	GetPointResult getPointResult = new GetPointResult(getItemResult);

	return getPointResult;
}
 
开发者ID:awslabs,项目名称:dynamodb-geo,代码行数:17,代码来源:DynamoDBManager.java


示例13: getRegisteredServiceByKeys

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
private RegisteredService getRegisteredServiceByKeys(final Map<String, AttributeValue> keys) {
    final GetItemRequest request = new GetItemRequest()
            .withKey(keys)
            .withTableName(TABLE_NAME);

    LOGGER.debug("Submitting request [{}] to get service with keys [{}]", request, keys);
    final Map<String, AttributeValue> returnItem = amazonDynamoDBClient.getItem(request).getItem();
    if (returnItem != null) {
        final RegisteredService service = deserializeServiceFromBinaryBlob(returnItem);
        LOGGER.debug("Located service [{}]", service);
        return service;
    }
    return null;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:15,代码来源:DynamoDbServiceRegistryFacilitator.java


示例14: getItemResultMono

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
private Mono<GetItemResult> getItemResultMono(String url) {

        GetItemRequest getItemRequest = new GetItemRequest();
        getItemRequest.setTableName(Utils.table.websites);
        HashMap<String, AttributeValue> key = new HashMap<>();
        key.put(Utils.params.url, new AttributeValue(url));
        getItemRequest.setKey(key);

        return Mono.fromFuture(
                Utils.makeCompletableFuture(
                        dynamoDBAsync.getItemAsync(getItemRequest)))
                .doOnError((throwable -> LOG.error(Utils.error.failed_dynamo_get, url)));
    }
 
开发者ID:hafidsousa,项目名称:webcrawler,代码行数:14,代码来源:CrawlerService.java


示例15: getItemRequest

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
private GetItemRequest getItemRequest(String url) {

        GetItemRequest request = new GetItemRequest();
        request.setTableName(Utils.table.websites);
        HashMap<String, AttributeValue> key = new HashMap<>();
        key.put(Utils.params.url, new AttributeValue(url));
        request.setKey(key);

        return request;
    }
 
开发者ID:hafidsousa,项目名称:webcrawler,代码行数:11,代码来源:CrawlerServiceTest.java


示例16: googleToken

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
private Optional<String> googleToken(final String team) {
    final String id = "team:" + team + ":googletoken";
    final GetItemRequest getItemRequest = new GetItemRequest()
            .withAttributesToGet(Collections.singletonList("value"))
            .withKey(Collections.singletonMap("id", new AttributeValue(id)))
            .withTableName(TableName);
    final GetItemResult getItemResult = ddb.getItem(getItemRequest);
    return Optional.ofNullable(getItemResult.getItem()).map(i -> i.get("value")).map(AttributeValue::getS);
}
 
开发者ID:aztecrex,项目名称:java-translatebot,代码行数:10,代码来源:EventHandler.java


示例17: getItem

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
public CompletableFuture<Map<String, Object>> getItem(final GetItemRequest getItemRequest) {
    return asyncExecutor.execute(new Callable<Map<String, Object>>() {
        @Override
        public Map<String, Object> call() throws Exception {
            return dbExecutor.getItem(getItemRequest);
        }
    });
}
 
开发者ID:landawn,项目名称:AbacusUtil,代码行数:9,代码来源:AsyncDynamoDBExecutor.java


示例18: execute

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
@Override
public void execute() {
    GetItemResult result = ddbClient.getItem(new GetItemRequest()
            .withKey(determineKey())
            .withTableName(determineTableName())
            .withAttributesToGet(determineAttributeNames())
            .withConsistentRead(determineConsistentRead()));
    addAttributesToResult(result.getItem());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:GetItemCommand.java


示例19: getItem

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
GetItemResult getItem(final GetItemRequest request) throws BackendException {
    setUserAgent(request);
    GetItemResult result;
    timedReadThrottle(GET_ITEM, request.getTableName(), estimateCapacityUnits(GET_ITEM, request.getTableName()));
    final Timer.Context apiTimerContext = getTimerContext(GET_ITEM, request.getTableName());
    try {
        result = client.getItem(request);
    } catch (Exception e) {
        throw processDynamoDbApiException(e, GET_ITEM, request.getTableName());
    } finally {
        apiTimerContext.stop();
    }
    meterConsumedCapacity(GET_ITEM, result.getConsumedCapacity());
    return result;
}
 
开发者ID:awslabs,项目名称:dynamodb-janusgraph-storage-backend,代码行数:16,代码来源:DynamoDbDelegate.java


示例20: getSlice

import com.amazonaws.services.dynamodbv2.model.GetItemRequest; //导入依赖的package包/类
@Override
public EntryList getSlice(final KeySliceQuery query, final StoreTransaction txh) throws BackendException {
    log.debug("Entering getSliceKeySliceQuery table:{} query:{} txh:{}", getTableName(), encodeForLog(query), txh);
    final GetItemRequest request = super.createGetItemRequest().withKey(new ItemBuilder().hashKey(query.getKey()).build());
    final GetItemResult result = new ExponentialBackoff.GetItem(request, client.getDelegate()).runWithBackoff();

    final List<Entry> filteredEntries = extractEntriesFromGetItemResult(result, query.getSliceStart(), query.getSliceEnd(), query.getLimit());
    log.debug("Exiting getSliceKeySliceQuery table:{} query:{} txh:{} returning:{}", getTableName(), encodeForLog(query), txh,
              filteredEntries.size());
    return StaticArrayEntryList.of(filteredEntries);
}
 
开发者ID:awslabs,项目名称:dynamodb-janusgraph-storage-backend,代码行数:12,代码来源:DynamoDbSingleRowStore.java



注:本文中的com.amazonaws.services.dynamodbv2.model.GetItemRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CombinedTemplateCreationEntry类代码示例发布时间:2022-05-21
下一篇:
Java AuthTokens类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap