Home > Enterprise >  How do you remove data from Hive box without leaving null?
How do you remove data from Hive box without leaving null?

Time:08-26

I'm trying to remove information from a Hive Box without returning null and instead reform the list with the updated indexes.

e.g

Data in Box ( [1,2,3,4,5,6,7] )

box.deleteAt(1);

Current Outcome: ( [1,null,3,4,5,6,7] )
box.length // Outcome 8

WANTED OUTCOME:  ( [1,3,4,5,6,7] )
box.length // Outcome 7

How would I achieve the Wanted Outcome?

CodePudding user response:

You can try getAt method to get that field

box.getAt(1);

By the way you can pass this value to variable.

CodePudding user response:

I have checked and currenty Hive doesn't have the remove method as you expect, maybe you can filter list from box.values by this way:

final List<int> boxValueWithoutNull = box.values.whereType<int>().toList();
print(boxValueWithoutNull.length) // Outcome 7
  • Related