Ankere
Ankere

Reputation: 23

How to remove data from Hive box without leaving null?

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?

Upvotes: 1

Views: 917

Answers (2)

mohammad esmaili
mohammad esmaili

Reputation: 1737

You can try getAt method to get that field

box.getAt(1);

if it is in a builder then

box.getAt(index)

By the way you can pass this value to variable.

Upvotes: 1

manhtuan21
manhtuan21

Reputation: 3455

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

Upvotes: 1

Related Questions