1

I seem to be getting a different epoch date value in node.js for a thrift object than what is stored in the mongo database and returned by the service

Thrift definition file (thrift v0.9.0), I have

struct Profile {
    ...
    4: i64 createDate,
    5: i64 lastUpdateDate

Mongo record

"createdTimestamp" : NumberLong("1366334385361"),
"lastUpdatedTimestamp" : NumberLong("1366334385361")

Node reports

createDate: 534785233,
lastUpdateDate: 534785233

The generated node thrift client seems to have I64 referenced.

if (this.createDate !== null && this.createDate !== undefined) {
    output.writeFieldBegin('createDate', Thrift.Type.I64, 14);
    output.writeI64(this.createDate);
    output.writeFieldEnd();
}

I appreciate any insight that comes along.

Thanks

4

1 回答 1

1

给定数字的二进制表示是:

1366334385361  ->  10011111000011111111000000010110011010001
534785233      ->  00000000000011111111000000010110011010001

即,如果你取 1366334385361 的低 32 位,你得到 534785233。所以在你正在使用的程序或包的某个地方,它被转换/截断为 32 位整数,例如 int(1366334385361)

于 2013-04-20T08:16:54.133 回答