简体   繁体   English

java twitter4j是唯一的tweet ID

[英]java twitter4j are tweet ids unique

Doing some java dev with twitter4j and curious to know if when I make a call to 用twitter4j做一些java开发,好奇地想知道何时我打电话给

Status tweet = blah blah blah.
long tweetID = tweet.getId(); //Is this unique?

I setup a HashSet in order to keep track of tweets I've already received and I have a print statement for duplicates. 我设置一个HashSet来跟踪已经收到的推文,并且有一份打印声明以备重复。 I was under the impression that Twitter used a 64bit long to generate unique keys but I was unable to find any correlation between the twitter4j tweet id and Twitter's tweet id. 我的印象是,Twitter使用64位长来生成唯一密钥,但是我无法找到twitter4j tweet ID与Twitter的tweet ID之间的任何关联。 Main question is: Are the twitter4j Status tweet ids unique? 主要问题是:twitter4j状态推特ID是否唯一?

[Edit] Some elaboration, I have a HashSet of Longs 详细说明,我有一个HashSet的Longs

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
}

I'm fairly certain the twitter4j's Status.getId() returns the unique ID of the Tweet, as determined by Twitter. 我相当确定twitter4j的Status.getId()返回Twitter所确定的Tweet的唯一ID。 It's not creating it's own IDs. 它不是在创建自己的ID。 Perhaps your HashSet is too aggressive with the key space and you're getting a collision, but the getId call is going to give you the Tweet's actual ID. 也许您的HashSet在密钥空间上过于激进,您会遇到冲突,但是getId调用将为您提供Tweet的实际ID。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM