由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - twitter ID 怎么变成 uuid?
相关主题
问个L家 设计题GF面经
问个L家设计题 分布式 inverted index设计讨论一下FB的经典题read和readline吧
招 Staff/StaffResearch Engineer (Networking方向) Location: Bay Area这个G题是DFS还是DP
请教一道经典的dropbox面试题~感谢!请教一道老题目
精通php和shell script的大牛一道google的面试题.
几道微软面试题Internship Position at Mitsubishi Electric Research Labs
请教:string pattern match 题Mobile Packet Core position
分享一道电面题,兼下午Onsite攒人品求祝福回报本版,付A家面经
相关话题的讨论汇总
话题: uuid话题: md5bytes话题: twitter话题: byte话题: array
进入JobHunting版参与讨论
1 (共1页)
b**********5
发帖数: 7881
1
twitter streaming api, status json里的ID 是
64 bit long。 我现在要换成cassandra里的 uuid, 怎么convert?
w**z
发帖数: 8232
2
why do you want to do that?
UUID is an auto generated ID, mostly based on time
http://docs.datastax.com/en/drivers/java/2.0/com/datastax/driver/core/utils
/UUIDs.html
If the ID from twitter is unique and random, use that as partition key

【在 b**********5 的大作中提到】
: twitter streaming api, status json里的ID 是
: 64 bit long。 我现在要换成cassandra里的 uuid, 怎么convert?

b**********5
发帖数: 7881
3
yes, i know. but i still want to convert that twitter ID to a uuid.
actually, there are various version of uuid, time based, name based, random.
twitter gives u the time based unique ID, the first 53 bits or so defines
the time lapsed. But let's say we have a cassandra schema table whose
primary key is uuid (or timeuuid). how can I convert the twitter ID to that
cassandra uuid?

【在 w**z 的大作中提到】
: why do you want to do that?
: UUID is an auto generated ID, mostly based on time
: http://docs.datastax.com/en/drivers/java/2.0/com/datastax/driver/core/utils
: /UUIDs.html
: If the ID from twitter is unique and random, use that as partition key

w**z
发帖数: 8232
4
convert long to byte array, then construct UUID from the byte array?
From Java Source code:
/**
* Static factory to retrieve a type 3 (name based) [email protected]/* */ UUID} based
on
* the specified byte array.
*
* @param name
* A byte array to be used to construct a [email protected]/* */ UUID}
*
* @return A [email protected]/* */ UUID} generated from the specified array
*/
public static UUID nameUUIDFromBytes(byte[] name) {
MessageDigest md;
try {
md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException nsae) {
throw new InternalError("MD5 not supported", nsae);
}
byte[] md5Bytes = md.digest(name);
md5Bytes[6] &= 0x0f; /* clear version */
md5Bytes[6] |= 0x30; /* set to version 3 */
md5Bytes[8] &= 0x3f; /* clear variant */
md5Bytes[8] |= 0x80; /* set to IETF variant */
return new UUID(md5Bytes);
}

random.
defines
that

【在 b**********5 的大作中提到】
: yes, i know. but i still want to convert that twitter ID to a uuid.
: actually, there are various version of uuid, time based, name based, random.
: twitter gives u the time based unique ID, the first 53 bits or so defines
: the time lapsed. But let's say we have a cassandra schema table whose
: primary key is uuid (or timeuuid). how can I convert the twitter ID to that
: cassandra uuid?

1 (共1页)
进入JobHunting版参与讨论
相关主题
回报本版,付A家面经精通php和shell script的大牛
这几个G家的design题怎么做?几道微软面试题
Summer internship at Mitsubishi Electric Research Lab (Boston, MA, USA)请教:string pattern match 题
A家面经求Offer分享一道电面题,兼下午Onsite攒人品求祝福
问个L家 设计题GF面经
问个L家设计题 分布式 inverted index设计讨论一下FB的经典题read和readline吧
招 Staff/StaffResearch Engineer (Networking方向) Location: Bay Area这个G题是DFS还是DP
请教一道经典的dropbox面试题~感谢!请教一道老题目
相关话题的讨论汇总
话题: uuid话题: md5bytes话题: twitter话题: byte话题: array