I examined the data mapping between ArangoDB and Java

Introduction

Some Aucfan use ArangoDB. ArangoDB is a hybrid NoSQL database that takes advantage of DocumentDB and GraphDB.

** I'll leave DocumentDB and GraphDB aside. *

At Aucfan, we create services that utilize data such as product information and sales information.

In the team I belong to, I think that a database like ArangoDB is suitable when you want to handle information (specs etc.) with different properties for each product and data considering the relationship of data such as manufacturer and category. ,I'm using.

On the other hand, Java or Kotlin is used to create software that refers to and aggregates such data. Therefore, when accessing ArangoDB programmatically, use the Java API provided by ArangoDB.

ArangoDB is not Java. The data to be handled is basically in JSON format. Of course, the definition of the data type will be different from the program.

When the data type that is naturally used in Java is put in ArangoDB, it changes to the type that ArangoDB can handle (JSON format), and I tested it so that I would not be bothered by unintended type conversion when using data. ..

Premise

The various versions are as follows.

Java → ArangoDB To store in ArangoDB, use the BaseDocument class and set the data with the ʻaddAttribute ()` method.

Check the stored data with the ArangoDB Web UI and check the stored status.

Java type → Arango DB type Remarks
int Numerical value(integer)
Integer Numerical value(integer)
long Numerical value(integer)
Long Numerical value(integer)
float Numerical value(Decimal) * Data is corrupted
Float Numerical value(Decimal) * Data is corrupted
double Numerical value(Decimal)
Double Numerical value(Decimal)
BigDecimal String
boolean Boolean value(true/false)
Boolean Boolean value(true/false)
LocalDate String ISO 8601 format
LocalDateTime String ISO 8601 format
OffsetDateTime String ISO 8601 format
ZonedDateTime String ISO8601(Expansion)format
List Array
Map object The type in the object is the same as the above mapping

ArangoDB → Java The data type when data is stored in ArangoDB from WebUI and acquired by Java is as follows.

ArangoDB type → Java type Remarks
String String
Numerical value(integer) Long
Numerical value(Decimal) Double
Boolean value(true/false) Boolean
Array ArrayList The inside type is the same as the others
object HashMap The inside type is the same as the others

Java → ArangoDB → Java The flow of data type change when the data stored in ArangoDB in Java is acquired in Java is as follows.

Java type → Arango DB type → Java type Remarks
int Numerical value(integer) Long
Integer Numerical value(integer) Long
long Numerical value(integer) Long
Long Numerical value(integer) Long
float Numerical value(Decimal) Double * Data is corrupted
Float Numerical value(Decimal) Double * Data is corrupted
double Numerical value(Decimal) Double
Double Numerical value(Decimal) Double
BigDecimal String String
boolean Boolean value(true/false) Boolean
Boolean Boolean value(true/false) Boolean
LocalDate String String ISO 8601 format
LocalDateTime String String ISO 8601 format
OffsetDateTime String String ISO 8601 format
ZonedDateTime String String ISO8601(Expansion)format
List Array ArrayList The inside type is the same as the others
Map object HashMap The type in the object is the same as the above mapping

Summary

I found that I need to be a little careful when using ArangoDB with Java API.

You can use it without worrying about it

--Integer is a Long type --Double type decimal --The boolean value is Boolean type --List and Map collection classes

I want to expand a little

--If you want to handle with Big Decimal --If you put it in ArangoDB, it will be serialized to a string. --When fetching from ArangoDB, it is fetched as a character string, so deserialize the character string. --When using DateTime API of Java 8 or later --When you put it in ArangoDB, it is serialized to a string --When fetching from ArangoDB, it is fetched as a character string, so deserialize the character string.

In fact, the calculation of decimal numbers is more complicated. .. .. If you are interested ( ̄ ー  ̄)

Recommended Posts

I examined the data mapping between ArangoDB and Java
I tried to enumerate the differences between java and python
I examined the device tree
I compared Java and Python!
I tried programming the chi-square test in Python and Java.
I personally compared Java and Ruby
I investigated the behavior of the difference between hard links and symbolic links
I investigated the relationship between Keras stateful LSTM and hidden state
Easily exchange data between Python, R and Julia using the Feather format
Differences in syntax between Python and Java
I saved the scraped data in CSV!
The subtle relationship between Gentoo and pip
About the relationship between Git and GitHub
I touched the data preparation tool Paxata
Exchange encrypted data between Python and C #
Let's visualize the relationship between average salary and industry with XBRL data and seaborn! (7/10)
I tried to process and transform the image and expand the data for machine learning
What is the difference between `pip` and` conda`?
Relationship between Firestore and Go data type conversion
I searched for railway senryu from the data
The answer of "1/2" is different between python2 and 3
I tried to save the data with discord
I wrote a class in Python3 and Java
[Python] Conversion memo between time data and numerical data
About the difference between "==" and "is" in python
[Data analysis] Should I buy the Harumi flag?
I read and implemented the Variants of UKR
About the difference between PostgreSQL su and sudo
What is the difference between Unix and Linux?
I had Spotify analyze the difference between the Beatles song and my own song and plotted it
[Challenger Wanted] The fastest Data Loading and Data Augmentation (Kaggle notebook) I can think of
I just wanted to extract the data of the desired date and time with Django