SlideShare a Scribd company logo
MAPDB
BY DEBMALYA JASH
WHAT IS MAPDB?
• MapDB is an open-source (Apache 2.0 licensed), embedded Java database engine and collection
framework. It provides Maps, Sets, Lists, Queues, Bitmaps with range queries, expiration, compression,
off-heap storage and streaming. MapDB is probably the fastest Java database, with performance
comparable to java.util collections. It also provides advanced features such as ACID transactions,
snapshots, incremental backups and much more.
•
DBMAKER
• Handles database configuration, creation and opening. Using this class we can set different modes and
configuration options provided by MapDB.
DB
• Represents and open database (or a single transaction session). It is used to create, open and collection
storages.
• Handles database's lifecycle methods like commit(), rollback(), and close().
• To open (or create) a store, use one of the DBMaker.xxxDB() static methods.
• memoryDB() - Creates new in-memory database. Changes are lost after JVM exits. serializes data into byte[].
• memoryDirectDB() - Creates new in-memory database. Changes are lost after JVM exits. This will use
DirectByteBuffer outside of Heap, so Garbage Collector is not affected. Increase memory as per your
requirement with option -XX:MaxDirectMemorySize=10G
• fileDB() – stores serialized record in physical file.
• tempFileDB() - new database in temporary folder. Files are deleted after store was closed.
• appendFileDB() opens a database which uses append-only log files and so on.
• heapDB() - Creates new in-memory database which stores all data on heap without serialization. very fast, but
data will affect Garbage Collector the same way as traditional Java Collections.
HTREEMAP
• HTreeMap provides HashMap and HashSet collections for MapDB. It optionally supports entry
expiration and can be used as a cache. It is thread-safe and scales under parallel updates.
HTREEMAP ADVANTAGES
• HTreeMap is a segmented Hash Tree. Unlike other HashMaps it does not use fixed size Hash Table, and does not
rehash all data when Hash Table grows. HTreeMap uses auto-expanding Index Tree, so it never needs resize. It also
occupies less space, since empty hash slots do not consume any space.
• HTreeMap optionally supports entry expiration based on four criteria: maximal map size, maximal storage size, time-
to-live since last modification and time-to-live since last access. Expired entries are automatically removed. This
feature uses FIFO queue and each segment has independent expiration queue.
MAP LAYOUT
• MapDB has different set of parameters to control its access time and maximal size. Those are grouped
under term Map Layout.
• HTreeMap layout is controlled by layout function. It takes three parameters:
• concurrency, number of segments. Default value is 8, it always rounds-up to power of two.
• maximal node size of Index Tree Dir Node. Default value is 16, it always rounds-up to power of two.
Maximal value is 128 entries.
• number of Levels in Index Tree, default value is 4
CONCURRENCY
• Concurrency is implemented by using multiple segments, each with separate read-write lock. Each concurrent
segment is independent, it has its own Size Counter, iterators and Expiration Queues. Number of segments is
configurable. Too small number will cause congestion on concurrent updates, too large will increase memory
overhead.
• HTreeMap uses Index Tree instead of growing Object[] for its Hash Table. Index Tree is sparse array like structure,
which uses tree hierarchy of arrays. It is sparse, so unused entries do not occupy any space. It does not do rehashing
(copy all entries to bigger array), but also it can not grow beyond its initial capacity.
SHARD STORES FOR BETTER CONCURRENCY
• HTreeMap is split into separate segments. Each segment is independent and does not share any state
with other segments. However they still share underlying Store and that affects performance under
concurrent load. It is possible to make segments truly independent, by using separate Store for each
segment.
EXPIRATION
• HTreeMap offers optional entry expiration if some conditions are met. Entry can expire if:
• An entry exists in the map longer time than the expiration period is. The expiration period could be
since the creation, last modification or since the last read access.
• The number of entries in a map would exceed maximal number
• Map consumes more disk space or memory than space limit
EXPIRATION OVERFLOW
• HTreeMap supports Modification Listeners. It notifies listener about inserts, updates and removes from
HTreeMap. It is possible to link two collections together. Usually faster in-memory with limited size, and
slower on-disk with unlimited size. After an entry expires from in-memory, it is automatically moved to
on-disk by Modification Listener. And Value Loader will load values back to in-memory map, if those are
not found by map.get() operation.
BTREEMAP
• BTreeMap provides TreeMap and TreeSet for MapDB. It is based on lock-free concurrent B-Linked-Tree.
It offers great performance for small keys and has good vertical scalability.
• BTrees store all their keys and values as part of a btree node. Node size affects the performance a lot. A
large node means that many keys have to be deserialized on lookup. A smaller node loads faster, but
makes large BTrees deeper and requires more operations. The default maximal node size is 32 entries
and it can be changed in this way.
FRAGMENTATION
• A trade-off for lock-free design is fragmentation after deletion. The B-Linked-Tree does not delete btree
nodes after entry removal, once they become empty. If you fill a BTreeMap and then remove all entries,
about 40% of space will not be released. Any value updates (keys are kept) are not affected by this
fragmentation.
COMPOSITE KEYS AND TUPLES
• MapDB allows composite keys in the form of Object[]. Interval submaps can be used to fetch tuple
subcomponents, or to create a simple form of multimap. Object array is not comparable, so you need to
use specialized serializer which provides comparator.
QUICK TIPS
• Memory mapped files are much faster and should be enabled on 64bit systems for better performance.
• MapDB has Pump for fast bulk import of collections. It is much faster than to Map.put()
• Transactions have a performance overhead, but without them the store gets corrupted if not closed properly.
• Data stored in MapDB (keys and values) should be immutable. MapDB serializes objects on background.
• MapDB needs compaction sometimes. Run DB.compact() or see background compaction options.
• Better to use specific serializer (e.g. Serializer.STRING), otherwise slower generic serializer will be used.
REFERENCE
• MapDB Manual

More Related Content

What's hot

Features of Hadoop
Features of HadoopFeatures of Hadoop
Features of Hadoop
Dr. C.V. Suresh Babu
 
Hadoop data analysis
Hadoop data analysisHadoop data analysis
Hadoop data analysis
Vakul Vankadaru
 
Hadoop - Introduction to HDFS
Hadoop - Introduction to HDFSHadoop - Introduction to HDFS
Hadoop - Introduction to HDFS
Vibrant Technologies & Computers
 
Optimal Execution Of MapReduce Jobs In Cloud - Voices 2015
Optimal Execution Of MapReduce Jobs In Cloud - Voices 2015Optimal Execution Of MapReduce Jobs In Cloud - Voices 2015
Optimal Execution Of MapReduce Jobs In Cloud - Voices 2015
Deanna Kosaraju
 
Study Notes: Apache Spark
Study Notes: Apache SparkStudy Notes: Apache Spark
Study Notes: Apache Spark
Gao Yunzhong
 
Hive
HiveHive
Scaling Storage and Computation with Hadoop
Scaling Storage and Computation with HadoopScaling Storage and Computation with Hadoop
Scaling Storage and Computation with Hadoop
yaevents
 
Hadoop
Hadoop Hadoop
Hadoop
Shamama Kamal
 
Hadoop introduction
Hadoop introductionHadoop introduction
Hadoop introduction
Chirag Ahuja
 
Summary machine learning and model deployment
Summary machine learning and model deploymentSummary machine learning and model deployment
Summary machine learning and model deployment
Novita Sari
 
Big Data and Hadoop - An Introduction
Big Data and Hadoop - An IntroductionBig Data and Hadoop - An Introduction
Big Data and Hadoop - An Introduction
Nagarjuna Kanamarlapudi
 
Sept 17 2013 - THUG - HBase a Technical Introduction
Sept 17 2013 - THUG - HBase a Technical IntroductionSept 17 2013 - THUG - HBase a Technical Introduction
Sept 17 2013 - THUG - HBase a Technical Introduction
Adam Muise
 
Hadoop Technologies
Hadoop TechnologiesHadoop Technologies
Hadoop Technologies
Kannappan Sirchabesan
 
Managing Memory Allocation
Managing Memory AllocationManaging Memory Allocation
Managing Memory Allocation
Meghaj Mallick
 
MapReduce
MapReduceMapReduce
MapReduce
KavyaGo
 
Hadoop tutorial
Hadoop tutorialHadoop tutorial
Hadoop tutorial
Aamir Ameen
 
Hadoop Summit 2010 Data Management On Grid
Hadoop Summit 2010 Data Management On GridHadoop Summit 2010 Data Management On Grid
Hadoop Summit 2010 Data Management On GridYahoo Developer Network
 
Scaling up Machine Learning Algorithms for Classification
Scaling up Machine Learning Algorithms for ClassificationScaling up Machine Learning Algorithms for Classification
Scaling up Machine Learning Algorithms for Classification
smatsus
 

What's hot (20)

Features of Hadoop
Features of HadoopFeatures of Hadoop
Features of Hadoop
 
Anju
AnjuAnju
Anju
 
Hadoop data analysis
Hadoop data analysisHadoop data analysis
Hadoop data analysis
 
Hadoop - Introduction to HDFS
Hadoop - Introduction to HDFSHadoop - Introduction to HDFS
Hadoop - Introduction to HDFS
 
Optimal Execution Of MapReduce Jobs In Cloud - Voices 2015
Optimal Execution Of MapReduce Jobs In Cloud - Voices 2015Optimal Execution Of MapReduce Jobs In Cloud - Voices 2015
Optimal Execution Of MapReduce Jobs In Cloud - Voices 2015
 
Study Notes: Apache Spark
Study Notes: Apache SparkStudy Notes: Apache Spark
Study Notes: Apache Spark
 
Hive
HiveHive
Hive
 
Scaling Storage and Computation with Hadoop
Scaling Storage and Computation with HadoopScaling Storage and Computation with Hadoop
Scaling Storage and Computation with Hadoop
 
Hadoop
Hadoop Hadoop
Hadoop
 
Hadoop introduction
Hadoop introductionHadoop introduction
Hadoop introduction
 
Summary machine learning and model deployment
Summary machine learning and model deploymentSummary machine learning and model deployment
Summary machine learning and model deployment
 
Big Data and Hadoop - An Introduction
Big Data and Hadoop - An IntroductionBig Data and Hadoop - An Introduction
Big Data and Hadoop - An Introduction
 
Sept 17 2013 - THUG - HBase a Technical Introduction
Sept 17 2013 - THUG - HBase a Technical IntroductionSept 17 2013 - THUG - HBase a Technical Introduction
Sept 17 2013 - THUG - HBase a Technical Introduction
 
Hadoop Technologies
Hadoop TechnologiesHadoop Technologies
Hadoop Technologies
 
Managing Memory Allocation
Managing Memory AllocationManaging Memory Allocation
Managing Memory Allocation
 
MapReduce
MapReduceMapReduce
MapReduce
 
Hadoop tutorial
Hadoop tutorialHadoop tutorial
Hadoop tutorial
 
Hadoop Summit 2010 Data Management On Grid
Hadoop Summit 2010 Data Management On GridHadoop Summit 2010 Data Management On Grid
Hadoop Summit 2010 Data Management On Grid
 
Scaling up Machine Learning Algorithms for Classification
Scaling up Machine Learning Algorithms for ClassificationScaling up Machine Learning Algorithms for Classification
Scaling up Machine Learning Algorithms for Classification
 
Introduction to HBase
Introduction to HBaseIntroduction to HBase
Introduction to HBase
 

Similar to Map db

Map db
Map dbMap db
7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth
Fabio Fumarola
 
Bigtable and Boxwood
Bigtable and BoxwoodBigtable and Boxwood
Bigtable and Boxwood
Evan Weaver
 
Introduction To Maxtable
Introduction To MaxtableIntroduction To Maxtable
Introduction To Maxtable
maxtable
 
Designing data intensive applications
Designing data intensive applicationsDesigning data intensive applications
Designing data intensive applications
Hemchander Sannidhanam
 
Computre_Engineering_Introduction_FPGA.ppt
Computre_Engineering_Introduction_FPGA.pptComputre_Engineering_Introduction_FPGA.ppt
Computre_Engineering_Introduction_FPGA.ppt
ghadeer228987
 
8. column oriented databases
8. column oriented databases8. column oriented databases
8. column oriented databases
Fabio Fumarola
 
HBase Sizing Guide
HBase Sizing GuideHBase Sizing Guide
HBase Sizing Guide
larsgeorge
 
A tour of Amazon Redshift
A tour of Amazon RedshiftA tour of Amazon Redshift
A tour of Amazon Redshift
Kel Graham
 
Tez Shuffle Handler: Shuffling at Scale with Apache Hadoop
Tez Shuffle Handler: Shuffling at Scale with Apache HadoopTez Shuffle Handler: Shuffling at Scale with Apache Hadoop
Tez Shuffle Handler: Shuffling at Scale with Apache Hadoop
DataWorks Summit
 
#GeodeSummit - Off-Heap Storage Current and Future Design
#GeodeSummit - Off-Heap Storage Current and Future Design#GeodeSummit - Off-Heap Storage Current and Future Design
#GeodeSummit - Off-Heap Storage Current and Future Design
PivotalOpenSourceHub
 
Big data and hadoop
Big data and hadoopBig data and hadoop
Big data and hadoopMohit Tare
 
Cloudera Impala technical deep dive
Cloudera Impala technical deep diveCloudera Impala technical deep dive
Cloudera Impala technical deep dive
huguk
 
Memory management
Memory managementMemory management
Memory management
PATELARCH
 
Kudu Deep-Dive
Kudu Deep-DiveKudu Deep-Dive
Kudu Deep-Dive
Supriya Sahay
 
A Closer Look at Apache Kudu
A Closer Look at Apache KuduA Closer Look at Apache Kudu
A Closer Look at Apache Kudu
Andriy Zabavskyy
 
Percona FT / TokuDB
Percona FT / TokuDBPercona FT / TokuDB
Percona FT / TokuDB
Vadim Tkachenko
 
Apache Spark
Apache SparkApache Spark
Apache Spark
SugumarSarDurai
 
Apache Geode Offheap Storage
Apache Geode Offheap StorageApache Geode Offheap Storage
Apache Geode Offheap Storage
PivotalOpenSourceHub
 
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
Malin Weiss
 

Similar to Map db (20)

Map db
Map dbMap db
Map db
 
7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth7. Key-Value Databases: In Depth
7. Key-Value Databases: In Depth
 
Bigtable and Boxwood
Bigtable and BoxwoodBigtable and Boxwood
Bigtable and Boxwood
 
Introduction To Maxtable
Introduction To MaxtableIntroduction To Maxtable
Introduction To Maxtable
 
Designing data intensive applications
Designing data intensive applicationsDesigning data intensive applications
Designing data intensive applications
 
Computre_Engineering_Introduction_FPGA.ppt
Computre_Engineering_Introduction_FPGA.pptComputre_Engineering_Introduction_FPGA.ppt
Computre_Engineering_Introduction_FPGA.ppt
 
8. column oriented databases
8. column oriented databases8. column oriented databases
8. column oriented databases
 
HBase Sizing Guide
HBase Sizing GuideHBase Sizing Guide
HBase Sizing Guide
 
A tour of Amazon Redshift
A tour of Amazon RedshiftA tour of Amazon Redshift
A tour of Amazon Redshift
 
Tez Shuffle Handler: Shuffling at Scale with Apache Hadoop
Tez Shuffle Handler: Shuffling at Scale with Apache HadoopTez Shuffle Handler: Shuffling at Scale with Apache Hadoop
Tez Shuffle Handler: Shuffling at Scale with Apache Hadoop
 
#GeodeSummit - Off-Heap Storage Current and Future Design
#GeodeSummit - Off-Heap Storage Current and Future Design#GeodeSummit - Off-Heap Storage Current and Future Design
#GeodeSummit - Off-Heap Storage Current and Future Design
 
Big data and hadoop
Big data and hadoopBig data and hadoop
Big data and hadoop
 
Cloudera Impala technical deep dive
Cloudera Impala technical deep diveCloudera Impala technical deep dive
Cloudera Impala technical deep dive
 
Memory management
Memory managementMemory management
Memory management
 
Kudu Deep-Dive
Kudu Deep-DiveKudu Deep-Dive
Kudu Deep-Dive
 
A Closer Look at Apache Kudu
A Closer Look at Apache KuduA Closer Look at Apache Kudu
A Closer Look at Apache Kudu
 
Percona FT / TokuDB
Percona FT / TokuDBPercona FT / TokuDB
Percona FT / TokuDB
 
Apache Spark
Apache SparkApache Spark
Apache Spark
 
Apache Geode Offheap Storage
Apache Geode Offheap StorageApache Geode Offheap Storage
Apache Geode Offheap Storage
 
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
JavaOne2016 - Microservices: Terabytes in Microseconds [CON4516]
 

Recently uploaded

Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
Google
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
Deuglo Infosystem Pvt Ltd
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 

Recently uploaded (20)

Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
AI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website CreatorAI Genie Review: World’s First Open AI WordPress Website Creator
AI Genie Review: World’s First Open AI WordPress Website Creator
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Empowering Growth with Best Software Development Company in Noida - Deuglo
Empowering Growth with Best Software  Development Company in Noida - DeugloEmpowering Growth with Best Software  Development Company in Noida - Deuglo
Empowering Growth with Best Software Development Company in Noida - Deuglo
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 

Map db

  • 2. WHAT IS MAPDB? • MapDB is an open-source (Apache 2.0 licensed), embedded Java database engine and collection framework. It provides Maps, Sets, Lists, Queues, Bitmaps with range queries, expiration, compression, off-heap storage and streaming. MapDB is probably the fastest Java database, with performance comparable to java.util collections. It also provides advanced features such as ACID transactions, snapshots, incremental backups and much more. •
  • 3. DBMAKER • Handles database configuration, creation and opening. Using this class we can set different modes and configuration options provided by MapDB.
  • 4. DB • Represents and open database (or a single transaction session). It is used to create, open and collection storages. • Handles database's lifecycle methods like commit(), rollback(), and close(). • To open (or create) a store, use one of the DBMaker.xxxDB() static methods. • memoryDB() - Creates new in-memory database. Changes are lost after JVM exits. serializes data into byte[]. • memoryDirectDB() - Creates new in-memory database. Changes are lost after JVM exits. This will use DirectByteBuffer outside of Heap, so Garbage Collector is not affected. Increase memory as per your requirement with option -XX:MaxDirectMemorySize=10G • fileDB() – stores serialized record in physical file. • tempFileDB() - new database in temporary folder. Files are deleted after store was closed. • appendFileDB() opens a database which uses append-only log files and so on. • heapDB() - Creates new in-memory database which stores all data on heap without serialization. very fast, but data will affect Garbage Collector the same way as traditional Java Collections.
  • 5. HTREEMAP • HTreeMap provides HashMap and HashSet collections for MapDB. It optionally supports entry expiration and can be used as a cache. It is thread-safe and scales under parallel updates.
  • 6. HTREEMAP ADVANTAGES • HTreeMap is a segmented Hash Tree. Unlike other HashMaps it does not use fixed size Hash Table, and does not rehash all data when Hash Table grows. HTreeMap uses auto-expanding Index Tree, so it never needs resize. It also occupies less space, since empty hash slots do not consume any space. • HTreeMap optionally supports entry expiration based on four criteria: maximal map size, maximal storage size, time- to-live since last modification and time-to-live since last access. Expired entries are automatically removed. This feature uses FIFO queue and each segment has independent expiration queue.
  • 7. MAP LAYOUT • MapDB has different set of parameters to control its access time and maximal size. Those are grouped under term Map Layout. • HTreeMap layout is controlled by layout function. It takes three parameters: • concurrency, number of segments. Default value is 8, it always rounds-up to power of two. • maximal node size of Index Tree Dir Node. Default value is 16, it always rounds-up to power of two. Maximal value is 128 entries. • number of Levels in Index Tree, default value is 4
  • 8. CONCURRENCY • Concurrency is implemented by using multiple segments, each with separate read-write lock. Each concurrent segment is independent, it has its own Size Counter, iterators and Expiration Queues. Number of segments is configurable. Too small number will cause congestion on concurrent updates, too large will increase memory overhead. • HTreeMap uses Index Tree instead of growing Object[] for its Hash Table. Index Tree is sparse array like structure, which uses tree hierarchy of arrays. It is sparse, so unused entries do not occupy any space. It does not do rehashing (copy all entries to bigger array), but also it can not grow beyond its initial capacity.
  • 9. SHARD STORES FOR BETTER CONCURRENCY • HTreeMap is split into separate segments. Each segment is independent and does not share any state with other segments. However they still share underlying Store and that affects performance under concurrent load. It is possible to make segments truly independent, by using separate Store for each segment.
  • 10. EXPIRATION • HTreeMap offers optional entry expiration if some conditions are met. Entry can expire if: • An entry exists in the map longer time than the expiration period is. The expiration period could be since the creation, last modification or since the last read access. • The number of entries in a map would exceed maximal number • Map consumes more disk space or memory than space limit
  • 11. EXPIRATION OVERFLOW • HTreeMap supports Modification Listeners. It notifies listener about inserts, updates and removes from HTreeMap. It is possible to link two collections together. Usually faster in-memory with limited size, and slower on-disk with unlimited size. After an entry expires from in-memory, it is automatically moved to on-disk by Modification Listener. And Value Loader will load values back to in-memory map, if those are not found by map.get() operation.
  • 12. BTREEMAP • BTreeMap provides TreeMap and TreeSet for MapDB. It is based on lock-free concurrent B-Linked-Tree. It offers great performance for small keys and has good vertical scalability. • BTrees store all their keys and values as part of a btree node. Node size affects the performance a lot. A large node means that many keys have to be deserialized on lookup. A smaller node loads faster, but makes large BTrees deeper and requires more operations. The default maximal node size is 32 entries and it can be changed in this way.
  • 13. FRAGMENTATION • A trade-off for lock-free design is fragmentation after deletion. The B-Linked-Tree does not delete btree nodes after entry removal, once they become empty. If you fill a BTreeMap and then remove all entries, about 40% of space will not be released. Any value updates (keys are kept) are not affected by this fragmentation.
  • 14. COMPOSITE KEYS AND TUPLES • MapDB allows composite keys in the form of Object[]. Interval submaps can be used to fetch tuple subcomponents, or to create a simple form of multimap. Object array is not comparable, so you need to use specialized serializer which provides comparator.
  • 15. QUICK TIPS • Memory mapped files are much faster and should be enabled on 64bit systems for better performance. • MapDB has Pump for fast bulk import of collections. It is much faster than to Map.put() • Transactions have a performance overhead, but without them the store gets corrupted if not closed properly. • Data stored in MapDB (keys and values) should be immutable. MapDB serializes objects on background. • MapDB needs compaction sometimes. Run DB.compact() or see background compaction options. • Better to use specific serializer (e.g. Serializer.STRING), otherwise slower generic serializer will be used.