Require some insight regarding Objects & Json
Prakhar Makhija
matcdac at gmail.com
Mon Nov 13 05:49:50 UTC 2017
Corrections :
*Scenario*
Have 1.5 billion json files, Each file is of around 655 bytes, which makes
a total of around 937.5 MB.
*Example*
Or is meaningfulNameOfAttributeOne internally mapped to enum value 0, and
will occupy maybe just 1 byte, depending upon the number of fields?
On Sun, Nov 12, 2017 at 9:56 PM, Prakhar Makhija <matcdac at gmail.com> wrote:
> Hi,
>
>
> *Scenario*
>
> Having 1.5 million json files of same structure (same keys).
> Each file is of around 64 KB, which makes a total of 1 GB.
>
> Created a class MyDummyJsonClass, having the attribute names same as the
> keys in those json files.
>
> Reading the json files, loading them into MyDummyJsonClass, using
> ObjectMapper.
>
>
> *Doubt 1*
>
> Will the objects occupy the same amount of space in Java's Memory, as they
> were occupying earlier as flat files?
>
>
> *Doubt 2*
>
> Does Java convert Objects to Enumerations at Runtime?
>
> What I mean to ask is, does it enumerate the attribute names while
> creating objects, in order to save the memory?
>
> Because the Class is just a blueprint, and we create objects out of it
> over and over again.
>
>
> *Example*
>
>
> class MyDummyJsonClass {
>
> private Object meaningfulNameOfAttributeOne;
> private String meaningfulNameOfAttributeTwo;
> private Integer meaningfulNameOfAttributeThree;
> private Float meaningfulNameOfAttributeFour;
> private Double meaningfulNameOfAttributeFive;
> private Long meaningfulNameOfAttributeSix;
> private Byte meaningfulNameOfAttributeSeven;
> private Boolean meaningfulNameOfAttributeEight;
> private Character meaningfulNameOfAttributeNine;
> private Short meaningfulNameOfAttributeTen;
>
> // Contructors
>
> // Getters & Setters
>
> }
>
>
> Here the field meaningfulNameOfAttributeOne is of 28 characters, and Java
> uses Unicode, so internally just this attribute name will it be occupying
> 56 bytes of memory in every Object we create?
>
> Or is meaningfulNameOfAttributeOne mapped to enum value 1, and will
> occupy maybe just 1 byte, depending upon the number of fields?
>
> If less than or equal to 256 fields in the class, allocate 1 byte enum,
> else 2 bytes enum.
>
> And some kind of Interceptor decides, to give it logical attribute name
> mapping?
>
>
More information about the core-libs-dev
mailing list