java getvalue_Java Value.getValue方法代码示例

import oracle.kv.Value; //导入方法依赖的package包/类

/**

* Displays information about a movie

* @param movieName

*/

public void showMovieValue(String movieName) {

KeyValueVersion keyValue = null;

Value value = null;

String movieIdStr = null;

Key movieIdKey = null;

MovieTO movieTO = null;

// The DB has an index on Movie Name. You will use this index to

// retrieve the ID for the Movie Name. Note, there may be multiple

// movies with the same name

Key movieNameKey = getMovieKey(movieName, KeyConstant.MOVIE_NAME_TABLE);

// Find movie id's for this movie name

Iterator keyIter = kvstore.multiGetIterator(

Direction.FORWARD, 0,

movieNameKey, null, null);

// Are there any movies available?

if (!keyIter.hasNext()) {

System.out.println("Movie \"" + movieName + "\" not found.");

System.out.println("");

return;

}

String snippet="";

System.out.println("Movie Information");

System.out.println("--------------------");

System.out.println("(Note: there may be multiple movies w/the same name.)");

System.out.println("");

System.out.println("Movie Name Key : " + movieNameKey.toString());

// Will loop over all movies with the same name

while (keyIter.hasNext()) {

keyValue = keyIter.next();

// the value is the movie id

value = keyValue.getValue();

movieIdStr = new String(value.getValue());

// get the movieid key for this movieid value

movieIdKey = getMovieKey(movieIdStr, KeyConstant.MOVIE_TABLE);

long start = Calendar.getInstance().getTimeInMillis();

ValueVersion vv = kvstore.get(movieIdKey);

long elapsed = Calendar.getInstance().getTimeInMillis() - start;

// Get the information about the movie

movieTO = movieDAO.getMovieTO(vv.getValue());

System.out.println("Movie Name Value : " + movieIdStr);

System.out.println("");

System.out.println("Movie ID Key : " + movieIdKey.toString());

System.out.println("Movie ID Value : " + movieTO.getMovieJsonTxt());

System.out.println();

System.out.println("elapsed: " + elapsed + "ms");

System.out.println("");

snippet = snippet + " movieIdKey = Key.fromString(\"" + movieIdKey.toString() + "\");\n";

snippet = snippet + " movieIdValue = kvstore.get(movieIdKey);\n";

} //EOF while

System.out.println("snippet:");

System.out.println(" movieNameKey = Key.fromString(\"" + movieNameKey.toString() + "\");");

System.out.println(" movieNameVal = kvstore.get(movieNameKey);");

System.out.println();

System.out.println(snippet);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值