我試圖用pymongo在mongodb中插入一個64位無符號整數。該整數是CRC64算法的輸出。我試圖:pymongo 64位無符號整數
long(crc64(unicode(kw).encode('unicode-escape'))))
如果我插入到mongodb它開始抱怨只有64位整數是由mongodb支持。接下來,我試圖將其轉換爲一個帶符號64位INT像這樣:
ctypes.c_int64(crc64(unicode(kw).encode('unicode-escape')))).value
哪種作品,MongoDB的停止抱怨我int的長度,但是當我在MongoDB中的數據看我得到這個:
{
"_id" : {
"floatApprox" : -5307924876159732000,
"top" : 3059119730,
"bottom" : 2651469802 },
"keyword" : "redacted",
"normal_hash" : {
"floatApprox" : -671156942315906300,
"top" : 4138701393,
"bottom" : 549001936
}
}
這是怎麼回事?有沒有什麼辦法把64位整型數據作爲一個整數(不關心它是有符號還是無符號)。
你在32位或64位機器上運行mongo嗎? – milan 2012-01-11 11:08:18
你是否試過將它編碼爲二進制文件? – incognick 2012-03-28 15:26:57