Get the App
SLTechnology News&Howtos  ›  Database  › 

How to specify OID as Date type in Sequoiadb

Shulou Source: shulou.com Published: 2022-05-31 19:23:02 10月24日 Update

Today, I will talk to you about how to specify OID as Date type in Sequoiadb. Many people may not know much about it. In order to let you know more, Xiaobian summarizes the following contents for you. I hope you can gain something according to this article.

[Problem Description]

Specify OID type as Date. Will this cause duplicate oid values in scenarios with high concurrency? For example:

1. Create threads, insert OID of type Date into each thread:

BSONObject obj = new BasicBSONObject();

Date now = new Date();

obj.put("date", now);

2. Start multiple threads at the same time. Is oid repeated in case of multiple concurrent insertions?

[Solution]

1. OID is a 12-byte BSON data type. Generation rule: 4 bytes timestamp accurate to seconds

3 byte system (physical machine) identification

2 byte process ID

3 byte sequence number starting with a random number

2. From the above generation rules, OID is globally unique in a cluster environment

3. Java BSON OID generation rules are slightly different, Java OID 12 byte content consists of three parts:

4 byte timestamp accurate to the second

4 byte system (physical machine) identification

4 byte sequence number starting with a random number

4. Therefore, OIDs generated using java drivers are guaranteed to be unique within a group, not globally in a clustered environment

After reading the above, do you have any further understanding of how to specify OID as Date type in Sequoiadb? If you still want to know more knowledge or related content, please pay attention to the industry information channel, thank you for your support.

Tags: Byte type content generation thread rule precision global sequence sequence number time physics environment system random number cluster guarantee start method at the same time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei OPPO Reno Xiaomi Shulou Information MySQL