SlideShare a Scribd company logo
Hive in Flutter
Prepared By: Flutter Junction
What is Hive?
Hive is the lightweight, NoSql, key-value database that is used to store the data
locally in flutter and dart applications.
Hive is very helpful and is very simple to utilize.
It consists of the key-value database without numerous relations.
Hive is the offline database.
Box
Hive stores its data in boxes containing key-value sets.
For a small app, a single box might be enough.
For more advanced problems, boxes are a great way to organize your data. Boxes
can also be encrypted to store sensitive data.
Before using the box, the hive box needs to be opened first.
Open Box
var box = await Hive.openBox<DataModel>('hive_box');
Or
var box = await Hive.openBox('hive_box');
Either way, you can open the box.
If the box is already opened, it is returned and all supplied parameters are ignored.
Without opening the hive box, you cannot read, write, and delete the data.
Get opened box
var box = Hive.box('myBox');
This procedure or method is mostly useful for Flutter apps as you
do not have to pass the box between the widgets.
Close box
await box.close();
In case, if you do not need the box again, you should close it. All the cached keys and values of
the box will be dropped from the memory and the box file is closed after all read and write
operations are completed.
You can leave the box open if you need a box again in the future. It is ok to leave a box open until
the app is running.
Write
var box = Hive.box('box_name');
box.put('name', 'John Doe');
box.put('friends', ['Hari', 'Ram', 'Sita']);
box.put(123, 'testdata');
box.putAll({'key1': 'value1', 23: 'process'});
Writing to a box is very easy and is almost like writing to a map.
Read
var box = Hive.box('myBox');
String name = box.get('name');
DateTime birthday = box.get('birthday');
Read
If the key is not present, null is returned. Optionally you can also a defaultValue
that can be returned in the case the key does not exist.
double length=box.get('yourkey',defaultValue:12.5);
Type Adapters
Hive provides us permission to almost all primitive data types such as String, int,
Map, List, DateTime and Uint8List.
Type Adapters convert the object from and to binary form.
You need to generate the TypeAdapter or you can write on your own.
You need to register the adapter before using it.
Register Adapter
Hive.registerAdapter(MyAdapter());
You need two things to register the adapter, i.e an instance of adapter and typeId .
typeId are unique and must be between 0 to 223.
Why Hive Database?
● It is the most efficient database in terms of speed and performance compared
to other databases like SQLite and SharedPreferences.
● It gives a straightforward method to perform CRUD operations.
● Built-in strong encryption
● No native dependencies
When to use Hive
Hive can be used to store almost every sort of data.
● Cart contents
● Blogs/Articles
● Messages
● Categories of products
● Session
● etc
When not to use Hive
Every type of data can be stored in Hive when it is modeled in a correct manner.
Sometimes it would be more convenient to use a relational database like SQLite
as it is more convenient but because it is not faster.
You should consider using SQLite if your data contains complex relations and you
have to rely mostly on indices and complex queries.
As Hive is so lightweight, you can use Hive and other databases together.
Thank You!!!

More Related Content

What's hot

What and Why Flutter? What is a Widget in Flutter?
What and Why Flutter? What is a Widget in Flutter?What and Why Flutter? What is a Widget in Flutter?
What and Why Flutter? What is a Widget in Flutter?
MohammadHussain595488
 
Introduction to Cassandra Basics
Introduction to Cassandra BasicsIntroduction to Cassandra Basics
Introduction to Cassandra Basics
nickmbailey
 
Data Engineering and the Data Science Lifecycle
Data Engineering and the Data Science LifecycleData Engineering and the Data Science Lifecycle
Data Engineering and the Data Science Lifecycle
Adam Doyle
 
From Data Warehouse to Lakehouse
From Data Warehouse to LakehouseFrom Data Warehouse to Lakehouse
From Data Warehouse to Lakehouse
Modern Data Stack France
 
Mysql
MysqlMysql
Mysql
TSUBHASHRI
 
Less08 users
Less08 usersLess08 users
Less08 users
Amit Bhalla
 
Oracle advanced queuing
Oracle advanced queuingOracle advanced queuing
Oracle advanced queuing
Gurpreet singh
 
SQL Server Reporting Services
SQL Server Reporting ServicesSQL Server Reporting Services
SQL Server Reporting Services
Ahmed Elbaz
 
Working with Microsoft Power Business Inteligence Tools - Presented by Atidan
Working with Microsoft Power Business Inteligence Tools - Presented by AtidanWorking with Microsoft Power Business Inteligence Tools - Presented by Atidan
Working with Microsoft Power Business Inteligence Tools - Presented by Atidan
David J Rosenthal
 
Sql ppt
Sql pptSql ppt
Bloc Pattern - Practical Use Cases - Flutter London - 21JAN2019
Bloc Pattern - Practical Use Cases - Flutter London - 21JAN2019Bloc Pattern - Practical Use Cases - Flutter London - 21JAN2019
Bloc Pattern - Practical Use Cases - Flutter London - 21JAN2019
Didier Boelens
 
Graph database
Graph databaseGraph database
Graph database
Achintya Kumar
 
Kafka streams windowing behind the curtain
Kafka streams windowing behind the curtain Kafka streams windowing behind the curtain
Kafka streams windowing behind the curtain
confluent
 
Explain the explain_plan
Explain the explain_planExplain the explain_plan
Explain the explain_plan
Maria Colgan
 
Tableau
TableauTableau
GraphQL Introduction with Spring Boot
GraphQL Introduction with Spring BootGraphQL Introduction with Spring Boot
GraphQL Introduction with Spring Boot
vipin kumar
 
Hitchhiker's Guide to free Oracle tuning tools
Hitchhiker's Guide to free Oracle tuning toolsHitchhiker's Guide to free Oracle tuning tools
Hitchhiker's Guide to free Oracle tuning tools
Bjoern Rost
 
Sql - Structured Query Language
Sql - Structured Query LanguageSql - Structured Query Language
Sql - Structured Query Language
Wan Hussain Wan Ishak
 
Mysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sqlMysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sql
Aimal Miakhel
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts
Bharat Kalia
 

What's hot (20)

What and Why Flutter? What is a Widget in Flutter?
What and Why Flutter? What is a Widget in Flutter?What and Why Flutter? What is a Widget in Flutter?
What and Why Flutter? What is a Widget in Flutter?
 
Introduction to Cassandra Basics
Introduction to Cassandra BasicsIntroduction to Cassandra Basics
Introduction to Cassandra Basics
 
Data Engineering and the Data Science Lifecycle
Data Engineering and the Data Science LifecycleData Engineering and the Data Science Lifecycle
Data Engineering and the Data Science Lifecycle
 
From Data Warehouse to Lakehouse
From Data Warehouse to LakehouseFrom Data Warehouse to Lakehouse
From Data Warehouse to Lakehouse
 
Mysql
MysqlMysql
Mysql
 
Less08 users
Less08 usersLess08 users
Less08 users
 
Oracle advanced queuing
Oracle advanced queuingOracle advanced queuing
Oracle advanced queuing
 
SQL Server Reporting Services
SQL Server Reporting ServicesSQL Server Reporting Services
SQL Server Reporting Services
 
Working with Microsoft Power Business Inteligence Tools - Presented by Atidan
Working with Microsoft Power Business Inteligence Tools - Presented by AtidanWorking with Microsoft Power Business Inteligence Tools - Presented by Atidan
Working with Microsoft Power Business Inteligence Tools - Presented by Atidan
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
Bloc Pattern - Practical Use Cases - Flutter London - 21JAN2019
Bloc Pattern - Practical Use Cases - Flutter London - 21JAN2019Bloc Pattern - Practical Use Cases - Flutter London - 21JAN2019
Bloc Pattern - Practical Use Cases - Flutter London - 21JAN2019
 
Graph database
Graph databaseGraph database
Graph database
 
Kafka streams windowing behind the curtain
Kafka streams windowing behind the curtain Kafka streams windowing behind the curtain
Kafka streams windowing behind the curtain
 
Explain the explain_plan
Explain the explain_planExplain the explain_plan
Explain the explain_plan
 
Tableau
TableauTableau
Tableau
 
GraphQL Introduction with Spring Boot
GraphQL Introduction with Spring BootGraphQL Introduction with Spring Boot
GraphQL Introduction with Spring Boot
 
Hitchhiker's Guide to free Oracle tuning tools
Hitchhiker's Guide to free Oracle tuning toolsHitchhiker's Guide to free Oracle tuning tools
Hitchhiker's Guide to free Oracle tuning tools
 
Sql - Structured Query Language
Sql - Structured Query LanguageSql - Structured Query Language
Sql - Structured Query Language
 
Mysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sqlMysql Crud, Php Mysql, php, sql
Mysql Crud, Php Mysql, php, sql
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts
 

Similar to Hive in Flutter.pptx

Unit 3
Unit 3Unit 3
Hadoop and object stores can we do it better
Hadoop and object stores  can we do it betterHadoop and object stores  can we do it better
Hadoop and object stores can we do it better
gvernik
 
Hadoop and object stores: Can we do it better?
Hadoop and object stores: Can we do it better?Hadoop and object stores: Can we do it better?
Hadoop and object stores: Can we do it better?
gvernik
 
Hive presentation
Hive presentationHive presentation
Hive presentation
Hitesh Agrawal
 
Apache Hive, data segmentation and bucketing
Apache Hive, data segmentation and bucketingApache Hive, data segmentation and bucketing
Apache Hive, data segmentation and bucketing
earnwithme2522
 
ASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And RepresentationASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And Representation
Randy Connolly
 
Artur Fejklowicz - “Data Lake architecture” AI&BigDataDay 2017
Artur Fejklowicz - “Data Lake architecture” AI&BigDataDay 2017Artur Fejklowicz - “Data Lake architecture” AI&BigDataDay 2017
Artur Fejklowicz - “Data Lake architecture” AI&BigDataDay 2017
Lviv Startup Club
 
Powering Rails Application With PostgreSQL
Powering Rails Application With PostgreSQLPowering Rails Application With PostgreSQL
Powering Rails Application With PostgreSQL
icicletech
 
6.hive
6.hive6.hive
.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community
Rohit Radhakrishnan
 
Certification preparation - Net classses and functions.pptx
Certification preparation - Net classses and functions.pptxCertification preparation - Net classses and functions.pptx
Certification preparation - Net classses and functions.pptx
Rohit Radhakrishnan
 
Redis Indices (#RedisTLV)
Redis Indices (#RedisTLV)Redis Indices (#RedisTLV)
Redis Indices (#RedisTLV)
Itamar Haber
 
JavaOne 2013: Memory Efficient Java
JavaOne 2013: Memory Efficient JavaJavaOne 2013: Memory Efficient Java
JavaOne 2013: Memory Efficient Java
Chris Bailey
 
Mongo db Quick Guide
Mongo db Quick GuideMongo db Quick Guide
Mongo db Quick Guide
Sourabh Sahu
 
מיכאל
מיכאלמיכאל
מיכאל
sqlserver.co.il
 
Unit V.pdf
Unit V.pdfUnit V.pdf
Unit V.pdf
KennyPratheepKumar
 
Hive_An Brief Introduction to HIVE_BIGDATAANALYTICS
Hive_An Brief Introduction to HIVE_BIGDATAANALYTICSHive_An Brief Introduction to HIVE_BIGDATAANALYTICS
Hive_An Brief Introduction to HIVE_BIGDATAANALYTICS
RUHULAMINHAZARIKA
 
Hive with HDInsight
Hive with HDInsightHive with HDInsight
Hive with HDInsight
Khalid Salama
 
Tthornton code4lib
Tthornton code4libTthornton code4lib
Tthornton code4lib
trevorthornton
 
Big Data & Analytics (CSE6005) L6.pptx
Big Data & Analytics (CSE6005) L6.pptxBig Data & Analytics (CSE6005) L6.pptx
Big Data & Analytics (CSE6005) L6.pptx
Anonymous9etQKwW
 

Similar to Hive in Flutter.pptx (20)

Unit 3
Unit 3Unit 3
Unit 3
 
Hadoop and object stores can we do it better
Hadoop and object stores  can we do it betterHadoop and object stores  can we do it better
Hadoop and object stores can we do it better
 
Hadoop and object stores: Can we do it better?
Hadoop and object stores: Can we do it better?Hadoop and object stores: Can we do it better?
Hadoop and object stores: Can we do it better?
 
Hive presentation
Hive presentationHive presentation
Hive presentation
 
Apache Hive, data segmentation and bucketing
Apache Hive, data segmentation and bucketingApache Hive, data segmentation and bucketing
Apache Hive, data segmentation and bucketing
 
ASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And RepresentationASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And Representation
 
Artur Fejklowicz - “Data Lake architecture” AI&BigDataDay 2017
Artur Fejklowicz - “Data Lake architecture” AI&BigDataDay 2017Artur Fejklowicz - “Data Lake architecture” AI&BigDataDay 2017
Artur Fejklowicz - “Data Lake architecture” AI&BigDataDay 2017
 
Powering Rails Application With PostgreSQL
Powering Rails Application With PostgreSQLPowering Rails Application With PostgreSQL
Powering Rails Application With PostgreSQL
 
6.hive
6.hive6.hive
6.hive
 
.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community.Net Classes and Objects | UiPath Community
.Net Classes and Objects | UiPath Community
 
Certification preparation - Net classses and functions.pptx
Certification preparation - Net classses and functions.pptxCertification preparation - Net classses and functions.pptx
Certification preparation - Net classses and functions.pptx
 
Redis Indices (#RedisTLV)
Redis Indices (#RedisTLV)Redis Indices (#RedisTLV)
Redis Indices (#RedisTLV)
 
JavaOne 2013: Memory Efficient Java
JavaOne 2013: Memory Efficient JavaJavaOne 2013: Memory Efficient Java
JavaOne 2013: Memory Efficient Java
 
Mongo db Quick Guide
Mongo db Quick GuideMongo db Quick Guide
Mongo db Quick Guide
 
מיכאל
מיכאלמיכאל
מיכאל
 
Unit V.pdf
Unit V.pdfUnit V.pdf
Unit V.pdf
 
Hive_An Brief Introduction to HIVE_BIGDATAANALYTICS
Hive_An Brief Introduction to HIVE_BIGDATAANALYTICSHive_An Brief Introduction to HIVE_BIGDATAANALYTICS
Hive_An Brief Introduction to HIVE_BIGDATAANALYTICS
 
Hive with HDInsight
Hive with HDInsightHive with HDInsight
Hive with HDInsight
 
Tthornton code4lib
Tthornton code4libTthornton code4lib
Tthornton code4lib
 
Big Data & Analytics (CSE6005) L6.pptx
Big Data & Analytics (CSE6005) L6.pptxBig Data & Analytics (CSE6005) L6.pptx
Big Data & Analytics (CSE6005) L6.pptx
 

Hive in Flutter.pptx

  • 1. Hive in Flutter Prepared By: Flutter Junction
  • 2. What is Hive? Hive is the lightweight, NoSql, key-value database that is used to store the data locally in flutter and dart applications. Hive is very helpful and is very simple to utilize. It consists of the key-value database without numerous relations. Hive is the offline database.
  • 3. Box Hive stores its data in boxes containing key-value sets. For a small app, a single box might be enough. For more advanced problems, boxes are a great way to organize your data. Boxes can also be encrypted to store sensitive data. Before using the box, the hive box needs to be opened first.
  • 4. Open Box var box = await Hive.openBox<DataModel>('hive_box'); Or var box = await Hive.openBox('hive_box'); Either way, you can open the box. If the box is already opened, it is returned and all supplied parameters are ignored. Without opening the hive box, you cannot read, write, and delete the data.
  • 5. Get opened box var box = Hive.box('myBox'); This procedure or method is mostly useful for Flutter apps as you do not have to pass the box between the widgets.
  • 6. Close box await box.close(); In case, if you do not need the box again, you should close it. All the cached keys and values of the box will be dropped from the memory and the box file is closed after all read and write operations are completed. You can leave the box open if you need a box again in the future. It is ok to leave a box open until the app is running.
  • 7. Write var box = Hive.box('box_name'); box.put('name', 'John Doe'); box.put('friends', ['Hari', 'Ram', 'Sita']); box.put(123, 'testdata'); box.putAll({'key1': 'value1', 23: 'process'}); Writing to a box is very easy and is almost like writing to a map.
  • 8. Read var box = Hive.box('myBox'); String name = box.get('name'); DateTime birthday = box.get('birthday');
  • 9. Read If the key is not present, null is returned. Optionally you can also a defaultValue that can be returned in the case the key does not exist. double length=box.get('yourkey',defaultValue:12.5);
  • 10. Type Adapters Hive provides us permission to almost all primitive data types such as String, int, Map, List, DateTime and Uint8List. Type Adapters convert the object from and to binary form. You need to generate the TypeAdapter or you can write on your own. You need to register the adapter before using it.
  • 11. Register Adapter Hive.registerAdapter(MyAdapter()); You need two things to register the adapter, i.e an instance of adapter and typeId . typeId are unique and must be between 0 to 223.
  • 12. Why Hive Database? ● It is the most efficient database in terms of speed and performance compared to other databases like SQLite and SharedPreferences. ● It gives a straightforward method to perform CRUD operations. ● Built-in strong encryption ● No native dependencies
  • 13. When to use Hive Hive can be used to store almost every sort of data. ● Cart contents ● Blogs/Articles ● Messages ● Categories of products ● Session ● etc
  • 14. When not to use Hive Every type of data can be stored in Hive when it is modeled in a correct manner. Sometimes it would be more convenient to use a relational database like SQLite as it is more convenient but because it is not faster. You should consider using SQLite if your data contains complex relations and you have to rely mostly on indices and complex queries. As Hive is so lightweight, you can use Hive and other databases together.