使用twitter4j执行一些java dev,并且好奇地想知道当我调用
Status tweet = blah blah blah.
long tweetID = tweet.getId(); //Is this unique?我设置了一个HashSet,以跟踪我已经收到的tweet,并且我有一个副本的打印语句。我的印象是,Twitter用了64位长来生成唯一的键,但我无法找到twitter4j tweet id和Twitter的tweet id之间的任何关联。主要问题是: twitter4j状态tweet ids是否是唯一的?
编辑一些精化,我有一个HashSet的隆斯
HashSet<Long> usedIds = new HashSet<Long>();
//Get new twitter4j Status
if(!usedIds.contains(tweetID)) {
//this is not a duplicate
//Place id into set
usedIds.add(tweetID);
//do work
} else {
//This is duplicate and my program is printing stuff
//From what I've learned this condition should never be met but it is
}发布于 2013-08-13 17:53:41
我相当肯定twitter4j的Status.getId()返回Tweet的唯一ID,这是由Twitter确定的。它没有创建自己的ID。也许您的HashSet在键空间上太咄咄逼人了,并且正在发生冲突,但是getId调用将给您Tweet的实际ID。
https://stackoverflow.com/questions/18215773
复制相似问题