You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@parquet.apache.org by Jianshi Huang <ji...@gmail.com> on 2015/03/06 09:27:30 UTC

Does null value take space in Map?

Hi,

I understand that for columns where value is null, parquet will skip it in
encoding, so it doesn't take storage space.

Does it also the case in a Map column? I think the key will always be
encoded even though values are null.

Is it correct?

-- 
Jianshi Huang

LinkedIn: jianshi
Twitter: @jshuang
Github & Blog: http://huangjs.github.com/

Re: Does null value take space in Map?

Posted by Ryan Blue <bl...@cloudera.com>.
On 03/15/2015 03:42 AM, Cheng Lian wrote:
> I think the question Jianshi intended to ask is whether the null in {
> 'a': null } takes storage space, which I think is no. The key and value
> parts of the map are treated as two separate columns in Parquet. So the
> key 'a' takes space in the key column, while the value null doesn't take
> space in the value column.
>
> Cheng

Most of the time, the answer is that null will take very little space. 
The columns are encoded using definition levels, which takes care of 
tracking what level in a nested scheme is null. The simple case is where 
you have a value that may be null, in which case you have 2 possible 
levels: 0 (null) and 1 (an encoded value). The value is only encoded if 
the definition level is 1, but if it is possible for a column to be null 
there is at least 1 bit for each value, which is then itself run-length 
encoded and bit packed. So some space is required, but *very* little 
space is used.

rb


-- 
Ryan Blue
Software Engineer
Cloudera, Inc.

Re: Does null value take space in Map?

Posted by Cheng Lian <li...@gmail.com>.
I think the question Jianshi intended to ask is whether the null in { 
'a': null } takes storage space, which I think is no. The key and value 
parts of the map are treated as two separate columns in Parquet. So the 
key 'a' takes space in the key column, while the value null doesn't take 
space in the value column.

Cheng

On 3/7/15 1:28 AM, Ryan Blue wrote:
> On 03/06/2015 12:27 AM, Jianshi Huang wrote:
>> Hi,
>>
>> I understand that for columns where value is null, parquet will skip 
>> it in
>> encoding, so it doesn't take storage space.
>>
>> Does it also the case in a Map column? I think the key will always be
>> encoded even though values are null.
>>
>> Is it correct?
>
> That is correct. The keys must be encoded so that the map can be 
> reconstructed. { 'a': null } isn't the same as { } and we would have 
> to encode 'a' even if missing entries and null values are handled the 
> same in your application.
>
> If you don't want to encode them, then you can remove the keys for 
> null values from your map before you store the map.
>
> rb
>
>


Re: Does null value take space in Map?

Posted by Ryan Blue <bl...@cloudera.com>.
On 03/06/2015 12:27 AM, Jianshi Huang wrote:
> Hi,
>
> I understand that for columns where value is null, parquet will skip it in
> encoding, so it doesn't take storage space.
>
> Does it also the case in a Map column? I think the key will always be
> encoded even though values are null.
>
> Is it correct?

That is correct. The keys must be encoded so that the map can be 
reconstructed. { 'a': null } isn't the same as { } and we would have to 
encode 'a' even if missing entries and null values are handled the same 
in your application.

If you don't want to encode them, then you can remove the keys for null 
values from your map before you store the map.

rb


-- 
Ryan Blue
Software Engineer
Cloudera, Inc.