SlideShare uma empresa Scribd logo
1 de 22
UnQLite
Embeddable NoSQL Database
NEXT 2기 김명찬
NoSQL?
• vs SQL
• 관계형 데이터베이스를 사용하지 않음
• 단순 저장, 검색에 편리.
• Scale-out 가능(vs Scale-up)
• SQL 쿼리처럼 사용할 수도 있음. (Not only SQL)
• ACID 보장성이 떨어짐..
DB-Engine Rangine
http://db-engines.com/en/ranking_trend
NoSQL classification by Data model
• Key – value DB
• Riak, Vodemort, Tokyo
• Wide Columnar Store
• Hbase, Cassandra, Hypertable
• Document DB
• Mongo DB, Couch DB
• Graph DB
• Neo4J, OreientDB
UnQLite
Self-contained C lib
UnQLite
• NoSQL
• Serverless
• Zero configuration
• Single DB file. (no temp files)
• ACID
• Key/value store, Document store
• Support O(1) lookup.
• Thread safe
• Cross-platform file format
Getting started
• https://www.unqlite.org/downloads.html
database open/close
#include <unqlite.h>
…
unqlite *pDb;
int rc;
rc = unqlite_open(&pDb,"test.db",UNQLITE_OPEN_CREATE);
//Auto-commit the transaction and close our handle
unqlite_close(pDb);
Store data
rc = unqlite_kv_store(pDb,"test",-1,"Hello World",11);
//test => 'Hello World'
rc = unqlite_kv_store_fmt(pDb,“date",-1,
“Current date : %d:%d:%d",2016, 05, 16);
//test => 'Hello World'
참고)
-1 : length.
음수일 경우에는 null값 나올때까지 저장.
Append Data
rc = unqlite_kv_append(pDb,"msg",-1,"Hello, ",7);
//msg => 'Hello, '
if( rc == UNQLITE_OK ){
//The second chunk
rc = unqlite_kv_append(pDb,"msg",-1,
"Current time is: ",17);
//msg => 'Hello, Current time is: '
if( rc == UNQLITE_OK ){
//The last formatted chunk
rc = unqlite_kv_append_fmt(pDb,"msg",-1,
"%d:%d:%d",10,16,53);
//msg => 'Hello, Current time is: 10:16:53'
}
}
Get a value by Key
//Extract data size first
rc = unqlite_kv_fetch(pDb, "date", -1, NULL, &nBytes);
if (rc != UNQLITE_OK) { return; }
//Allocate a buffer big enough to hold the record content
zBuf = (char *)malloc(nBytes);
if (zBuf == NULL) { return; }
//Copy record content in our buffer
unqlite_kv_fetch(pDb, "date", -1, zBuf, &nBytes);
//Play with zBuf...
//Close our database handle
unqlite_close(pDb);
Get by a cursor – set range
// Open our database;
rc = unqlite_open(&pDb, "test.db", UNQLITE_OPEN_CREATE);
if (rc != UNQLITE_OK) { return ; }
//Store some records unqlite_kv_store(), unqlite_kv_append()...
/* Allocate a new cursor instance */
rc = unqlite_kv_cursor_init(pDb, &pCursor);
if (rc != UNQLITE_OK) { return ; }
/* Point to the last record */
rc = unqlite_kv_cursor_last_entry(pCursor);
if (rc != UNQLITE_OK) { return ; }
Get by a cursor – get
…
/* Iterate over the records */
while (unqlite_kv_cursor_valid_entry(pCursor)) {
/* Consume the key */
printf("nKey ==> ");
unqlite_kv_cursor_key_callback(pCursor, DataConsumerCallback, 0);
/* Extract data length */
unqlite_kv_cursor_data(pCursor, NULL, &iData);
/* Consume the data */
printf("Data => ");
unqlite_kv_cursor_data_callback(pCursor, DataConsumerCallback, 0);
printf("Data length ==> %lldnt", iData);
/* Point to the previous record */
unqlite_kv_cursor_prev_entry(pCursor);
}
Get by a cursor - realese
…
/* Finally, Release our cursor */
unqlite_kv_cursor_release(pDb, pCursor);
//Auto-commit the transaction and close our handle
unqlite_close(pDb);
Delete Data
unqlite_kv_delete(pDb,"test",-1);
Make random string
char zKey[12]; //Random generated key
char zData[34] = "DATA!!"; //Dummy DATA
unqlite_util_random_string(pDb, zKey, sizeof(zKey));
// Perform the insertion
rc = unqlite_kv_store(pDb, zKey, sizeof(zKey), zData,
sizeof(zData));
if (rc != UNQLITE_OK) {
break;
}
Read File
/********Read File***********/
void *pMap;
unqlite_int64 iSize;
int rc, i;
const char *zName = "license.txt"; //Name of the target file
// Obtain a read-only memory view of the target file;
rc = unqlite_util_load_mmaped_file(zName, &pMap, &iSize);
// Store the whole file in our database;
rc = unqlite_kv_store(pDb, zName, -1, pMap, iSize);
// Discard the memory view;
unqlite_util_release_mmaped_file(pMap, iSize);
Read File
rollback
if( rc != UNQLITE_BUSY && rc != UNQLITE_NOTIMPLEMENTED ){
/* Rollback */
unqlite_rollback(pDb);
}
Jx9 script
/* Create the collection 'users' */
if( !db_exists('users') ){
/* Try to create it */
$rc = db_create('users');
}
//The following is the JSON objects to be stored shortly in our 'users' collection
$zRec = [{
name : 'james',
age : 27,
mail : 'dude@example.com'
}];
//Store our records
$rc = db_store('users',$zRec);
//One more record
$rc = db_store('users',{ name : 'alex', age : 19, mail : 'alex@example.com' });
print "Total number of stored records: ",db_total_records('users'),JX9_EOL;
//Fetch data using db_fetch_all(), db_fetch_by_id() and db_fetch().
Jx9 script
unqlite_vm *pVm;
rc = unqlite_compile(pDb,JX9_PROG,sizeof(JX9_PROG)-1,&pVm);
/* Install a VM output consumer callback */
rc = unqlite_vm_config(pVm,UNQLITE_VM_CONFIG_OUTPUT,OutputConsumer,0);
/* Execute our script */
rc = unqlite_vm_exec(pVm);
/* Finally, release our VM */
unqlite_vm_release(pVm);
감사합니다.

Mais conteúdo relacionado

Mais procurados

Using MongoDB with Kafka - Use Cases and Best Practices
Using MongoDB with Kafka -  Use Cases and Best PracticesUsing MongoDB with Kafka -  Use Cases and Best Practices
Using MongoDB with Kafka - Use Cases and Best PracticesAntonios Giannopoulos
 
Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018 Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018 Antonios Giannopoulos
 
How to upgrade to MongoDB 4.0 - Percona Europe 2018
How to upgrade to MongoDB 4.0 - Percona Europe 2018How to upgrade to MongoDB 4.0 - Percona Europe 2018
How to upgrade to MongoDB 4.0 - Percona Europe 2018Antonios Giannopoulos
 
10 Key MongoDB Performance Indicators
10 Key MongoDB Performance Indicators  10 Key MongoDB Performance Indicators
10 Key MongoDB Performance Indicators iammutex
 
Redis as a message queue
Redis as a message queueRedis as a message queue
Redis as a message queueBrandon Lamb
 
RestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueRestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueGleicon Moraes
 
Redis and its many use cases
Redis and its many use casesRedis and its many use cases
Redis and its many use casesChristian Joudrey
 
Triggers In MongoDB
Triggers In MongoDBTriggers In MongoDB
Triggers In MongoDBJason Terpko
 
glance replicator
glance replicatorglance replicator
glance replicatoririx_jp
 
Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Itamar Haber
 
아파트 정보를 이용한 ELK stack 활용 - 오근문
아파트 정보를 이용한 ELK stack 활용 - 오근문아파트 정보를 이용한 ELK stack 활용 - 오근문
아파트 정보를 이용한 ELK stack 활용 - 오근문NAVER D2
 
HBaseCon 2013: OpenTSDB at Box
HBaseCon 2013: OpenTSDB at BoxHBaseCon 2013: OpenTSDB at Box
HBaseCon 2013: OpenTSDB at BoxCloudera, Inc.
 
Paris Redis Meetup Introduction
Paris Redis Meetup IntroductionParis Redis Meetup Introduction
Paris Redis Meetup IntroductionGregory Boissinot
 
An Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL databaseAn Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL databaseAli MasudianPour
 

Mais procurados (20)

Using MongoDB with Kafka - Use Cases and Best Practices
Using MongoDB with Kafka -  Use Cases and Best PracticesUsing MongoDB with Kafka -  Use Cases and Best Practices
Using MongoDB with Kafka - Use Cases and Best Practices
 
Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018 Elastic 101 tutorial - Percona Europe 2018
Elastic 101 tutorial - Percona Europe 2018
 
How to upgrade to MongoDB 4.0 - Percona Europe 2018
How to upgrade to MongoDB 4.0 - Percona Europe 2018How to upgrade to MongoDB 4.0 - Percona Europe 2018
How to upgrade to MongoDB 4.0 - Percona Europe 2018
 
Caching. api. http 1.1
Caching. api. http 1.1Caching. api. http 1.1
Caching. api. http 1.1
 
10 Key MongoDB Performance Indicators
10 Key MongoDB Performance Indicators  10 Key MongoDB Performance Indicators
10 Key MongoDB Performance Indicators
 
Redis as a message queue
Redis as a message queueRedis as a message queue
Redis as a message queue
 
RestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message QueueRestMQ - HTTP/Redis based Message Queue
RestMQ - HTTP/Redis based Message Queue
 
Redis and its many use cases
Redis and its many use casesRedis and its many use cases
Redis and its many use cases
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Triggers In MongoDB
Triggers In MongoDBTriggers In MongoDB
Triggers In MongoDB
 
MongoDB-SESSION03
MongoDB-SESSION03MongoDB-SESSION03
MongoDB-SESSION03
 
glance replicator
glance replicatorglance replicator
glance replicator
 
Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)Redis Use Patterns (DevconTLV June 2014)
Redis Use Patterns (DevconTLV June 2014)
 
아파트 정보를 이용한 ELK stack 활용 - 오근문
아파트 정보를 이용한 ELK stack 활용 - 오근문아파트 정보를 이용한 ELK stack 활용 - 오근문
아파트 정보를 이용한 ELK stack 활용 - 오근문
 
Mongodb replication
Mongodb replicationMongodb replication
Mongodb replication
 
HBaseCon 2013: OpenTSDB at Box
HBaseCon 2013: OpenTSDB at BoxHBaseCon 2013: OpenTSDB at Box
HBaseCon 2013: OpenTSDB at Box
 
Nginx-lua
Nginx-luaNginx-lua
Nginx-lua
 
Paris Redis Meetup Introduction
Paris Redis Meetup IntroductionParis Redis Meetup Introduction
Paris Redis Meetup Introduction
 
An Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL databaseAn Introduction to REDIS NoSQL database
An Introduction to REDIS NoSQL database
 
Redis introduction
Redis introductionRedis introduction
Redis introduction
 

Destaque

Twitter의 snowflake 소개 및 활용
Twitter의 snowflake 소개 및 활용Twitter의 snowflake 소개 및 활용
Twitter의 snowflake 소개 및 활용흥배 최
 
signal과 slot, 그리고 jl_signal 라이브러리
signal과 slot, 그리고 jl_signal 라이브러리signal과 slot, 그리고 jl_signal 라이브러리
signal과 slot, 그리고 jl_signal 라이브러리JongSung Hwang
 
MsgPack 정리
MsgPack 정리MsgPack 정리
MsgPack 정리Seokmin No
 
KGC2015_C# 스크립트를 사용한 게임서버 모니터링 시스템개발
KGC2015_C# 스크립트를 사용한 게임서버 모니터링 시스템개발KGC2015_C# 스크립트를 사용한 게임서버 모니터링 시스템개발
KGC2015_C# 스크립트를 사용한 게임서버 모니터링 시스템개발흥배 최
 
GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things t...
GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things t...GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things t...
GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things t...Gerke Max Preussner
 

Destaque (8)

Twitter의 snowflake 소개 및 활용
Twitter의 snowflake 소개 및 활용Twitter의 snowflake 소개 및 활용
Twitter의 snowflake 소개 및 활용
 
NLog 소개
NLog 소개NLog 소개
NLog 소개
 
signal과 slot, 그리고 jl_signal 라이브러리
signal과 slot, 그리고 jl_signal 라이브러리signal과 slot, 그리고 jl_signal 라이브러리
signal과 slot, 그리고 jl_signal 라이브러리
 
MsgPack 정리
MsgPack 정리MsgPack 정리
MsgPack 정리
 
KGC2015_C# 스크립트를 사용한 게임서버 모니터링 시스템개발
KGC2015_C# 스크립트를 사용한 게임서버 모니터링 시스템개발KGC2015_C# 스크립트를 사용한 게임서버 모니터링 시스템개발
KGC2015_C# 스크립트를 사용한 게임서버 모니터링 시스템개발
 
Monkey space 2013
Monkey space 2013Monkey space 2013
Monkey space 2013
 
Easyloggingpp
EasyloggingppEasyloggingpp
Easyloggingpp
 
GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things t...
GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things t...GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things t...
GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things t...
 

Semelhante a Unqlite

Adding Riak to your NoSQL Bag of Tricks
Adding Riak to your NoSQL Bag of TricksAdding Riak to your NoSQL Bag of Tricks
Adding Riak to your NoSQL Bag of Trickssiculars
 
Lazy evaluation drupal camp moscow 2014
Lazy evaluation drupal camp moscow 2014Lazy evaluation drupal camp moscow 2014
Lazy evaluation drupal camp moscow 2014Evgeny Nikitin
 
Riak at The NYC Cloud Computing Meetup Group
Riak at The NYC Cloud Computing Meetup GroupRiak at The NYC Cloud Computing Meetup Group
Riak at The NYC Cloud Computing Meetup Groupsiculars
 
Leveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL EnvironmentLeveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL EnvironmentJim Mlodgenski
 
Kerberizing spark. Spark Summit east
Kerberizing spark. Spark Summit eastKerberizing spark. Spark Summit east
Kerberizing spark. Spark Summit eastJorge Lopez-Malla
 
Blocks & GCD
Blocks & GCDBlocks & GCD
Blocks & GCDrsebbe
 
Oracle forensics 101
Oracle forensics 101Oracle forensics 101
Oracle forensics 101fangjiafu
 
Cassandra Java APIs Old and New – A Comparison
Cassandra Java APIs Old and New – A ComparisonCassandra Java APIs Old and New – A Comparison
Cassandra Java APIs Old and New – A Comparisonshsedghi
 
Solr as a Spark SQL Datasource
Solr as a Spark SQL DatasourceSolr as a Spark SQL Datasource
Solr as a Spark SQL DatasourceChitturi Kiran
 
OSMC 2009 | Icinga by Icinga Team
OSMC 2009 | Icinga by Icinga TeamOSMC 2009 | Icinga by Icinga Team
OSMC 2009 | Icinga by Icinga TeamNETWAYS
 
Null Bachaav - May 07 Attack Monitoring workshop.
Null Bachaav - May 07 Attack Monitoring workshop.Null Bachaav - May 07 Attack Monitoring workshop.
Null Bachaav - May 07 Attack Monitoring workshop.Prajal Kulkarni
 
Icinga 2009 at OSMC
Icinga 2009 at OSMCIcinga 2009 at OSMC
Icinga 2009 at OSMCIcinga
 
Fast federated SQL with Apache Calcite
Fast federated SQL with Apache CalciteFast federated SQL with Apache Calcite
Fast federated SQL with Apache CalciteChris Baynes
 
SQL Track: Restoring databases with powershell
SQL Track: Restoring databases with powershellSQL Track: Restoring databases with powershell
SQL Track: Restoring databases with powershellITProceed
 
Attack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and KibanaAttack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and KibanaPrajal Kulkarni
 
Storlets fb session_16_9
Storlets fb session_16_9Storlets fb session_16_9
Storlets fb session_16_9Eran Rom
 

Semelhante a Unqlite (20)

Level DB - Quick Cheat Sheet
Level DB - Quick Cheat SheetLevel DB - Quick Cheat Sheet
Level DB - Quick Cheat Sheet
 
Adding Riak to your NoSQL Bag of Tricks
Adding Riak to your NoSQL Bag of TricksAdding Riak to your NoSQL Bag of Tricks
Adding Riak to your NoSQL Bag of Tricks
 
Lazy evaluation drupal camp moscow 2014
Lazy evaluation drupal camp moscow 2014Lazy evaluation drupal camp moscow 2014
Lazy evaluation drupal camp moscow 2014
 
Riak at The NYC Cloud Computing Meetup Group
Riak at The NYC Cloud Computing Meetup GroupRiak at The NYC Cloud Computing Meetup Group
Riak at The NYC Cloud Computing Meetup Group
 
Leveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL EnvironmentLeveraging Hadoop in your PostgreSQL Environment
Leveraging Hadoop in your PostgreSQL Environment
 
Kerberizing spark. Spark Summit east
Kerberizing spark. Spark Summit eastKerberizing spark. Spark Summit east
Kerberizing spark. Spark Summit east
 
Blocks & GCD
Blocks & GCDBlocks & GCD
Blocks & GCD
 
Oracle forensics 101
Oracle forensics 101Oracle forensics 101
Oracle forensics 101
 
Cassandra Java APIs Old and New – A Comparison
Cassandra Java APIs Old and New – A ComparisonCassandra Java APIs Old and New – A Comparison
Cassandra Java APIs Old and New – A Comparison
 
Solr as a Spark SQL Datasource
Solr as a Spark SQL DatasourceSolr as a Spark SQL Datasource
Solr as a Spark SQL Datasource
 
OSMC 2009 | Icinga by Icinga Team
OSMC 2009 | Icinga by Icinga TeamOSMC 2009 | Icinga by Icinga Team
OSMC 2009 | Icinga by Icinga Team
 
Null Bachaav - May 07 Attack Monitoring workshop.
Null Bachaav - May 07 Attack Monitoring workshop.Null Bachaav - May 07 Attack Monitoring workshop.
Null Bachaav - May 07 Attack Monitoring workshop.
 
Icinga 2009 at OSMC
Icinga 2009 at OSMCIcinga 2009 at OSMC
Icinga 2009 at OSMC
 
Fast federated SQL with Apache Calcite
Fast federated SQL with Apache CalciteFast federated SQL with Apache Calcite
Fast federated SQL with Apache Calcite
 
SQL Track: Restoring databases with powershell
SQL Track: Restoring databases with powershellSQL Track: Restoring databases with powershell
SQL Track: Restoring databases with powershell
 
Attack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and KibanaAttack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and Kibana
 
Perl Programming - 04 Programming Database
Perl Programming - 04 Programming DatabasePerl Programming - 04 Programming Database
Perl Programming - 04 Programming Database
 
Storlets fb session_16_9
Storlets fb session_16_9Storlets fb session_16_9
Storlets fb session_16_9
 
Advance Mobile Application Development class 01
Advance Mobile Application Development class 01Advance Mobile Application Development class 01
Advance Mobile Application Development class 01
 
ERGroupware
ERGroupwareERGroupware
ERGroupware
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 

Último (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 

Unqlite

  • 2. NoSQL? • vs SQL • 관계형 데이터베이스를 사용하지 않음 • 단순 저장, 검색에 편리. • Scale-out 가능(vs Scale-up) • SQL 쿼리처럼 사용할 수도 있음. (Not only SQL) • ACID 보장성이 떨어짐..
  • 4. NoSQL classification by Data model • Key – value DB • Riak, Vodemort, Tokyo • Wide Columnar Store • Hbase, Cassandra, Hypertable • Document DB • Mongo DB, Couch DB • Graph DB • Neo4J, OreientDB
  • 6. UnQLite • NoSQL • Serverless • Zero configuration • Single DB file. (no temp files) • ACID • Key/value store, Document store • Support O(1) lookup. • Thread safe • Cross-platform file format
  • 8. database open/close #include <unqlite.h> … unqlite *pDb; int rc; rc = unqlite_open(&pDb,"test.db",UNQLITE_OPEN_CREATE); //Auto-commit the transaction and close our handle unqlite_close(pDb);
  • 9. Store data rc = unqlite_kv_store(pDb,"test",-1,"Hello World",11); //test => 'Hello World' rc = unqlite_kv_store_fmt(pDb,“date",-1, “Current date : %d:%d:%d",2016, 05, 16); //test => 'Hello World' 참고) -1 : length. 음수일 경우에는 null값 나올때까지 저장.
  • 10. Append Data rc = unqlite_kv_append(pDb,"msg",-1,"Hello, ",7); //msg => 'Hello, ' if( rc == UNQLITE_OK ){ //The second chunk rc = unqlite_kv_append(pDb,"msg",-1, "Current time is: ",17); //msg => 'Hello, Current time is: ' if( rc == UNQLITE_OK ){ //The last formatted chunk rc = unqlite_kv_append_fmt(pDb,"msg",-1, "%d:%d:%d",10,16,53); //msg => 'Hello, Current time is: 10:16:53' } }
  • 11. Get a value by Key //Extract data size first rc = unqlite_kv_fetch(pDb, "date", -1, NULL, &nBytes); if (rc != UNQLITE_OK) { return; } //Allocate a buffer big enough to hold the record content zBuf = (char *)malloc(nBytes); if (zBuf == NULL) { return; } //Copy record content in our buffer unqlite_kv_fetch(pDb, "date", -1, zBuf, &nBytes); //Play with zBuf... //Close our database handle unqlite_close(pDb);
  • 12. Get by a cursor – set range // Open our database; rc = unqlite_open(&pDb, "test.db", UNQLITE_OPEN_CREATE); if (rc != UNQLITE_OK) { return ; } //Store some records unqlite_kv_store(), unqlite_kv_append()... /* Allocate a new cursor instance */ rc = unqlite_kv_cursor_init(pDb, &pCursor); if (rc != UNQLITE_OK) { return ; } /* Point to the last record */ rc = unqlite_kv_cursor_last_entry(pCursor); if (rc != UNQLITE_OK) { return ; }
  • 13. Get by a cursor – get … /* Iterate over the records */ while (unqlite_kv_cursor_valid_entry(pCursor)) { /* Consume the key */ printf("nKey ==> "); unqlite_kv_cursor_key_callback(pCursor, DataConsumerCallback, 0); /* Extract data length */ unqlite_kv_cursor_data(pCursor, NULL, &iData); /* Consume the data */ printf("Data => "); unqlite_kv_cursor_data_callback(pCursor, DataConsumerCallback, 0); printf("Data length ==> %lldnt", iData); /* Point to the previous record */ unqlite_kv_cursor_prev_entry(pCursor); }
  • 14. Get by a cursor - realese … /* Finally, Release our cursor */ unqlite_kv_cursor_release(pDb, pCursor); //Auto-commit the transaction and close our handle unqlite_close(pDb);
  • 16. Make random string char zKey[12]; //Random generated key char zData[34] = "DATA!!"; //Dummy DATA unqlite_util_random_string(pDb, zKey, sizeof(zKey)); // Perform the insertion rc = unqlite_kv_store(pDb, zKey, sizeof(zKey), zData, sizeof(zData)); if (rc != UNQLITE_OK) { break; }
  • 17. Read File /********Read File***********/ void *pMap; unqlite_int64 iSize; int rc, i; const char *zName = "license.txt"; //Name of the target file // Obtain a read-only memory view of the target file; rc = unqlite_util_load_mmaped_file(zName, &pMap, &iSize); // Store the whole file in our database; rc = unqlite_kv_store(pDb, zName, -1, pMap, iSize); // Discard the memory view; unqlite_util_release_mmaped_file(pMap, iSize);
  • 19. rollback if( rc != UNQLITE_BUSY && rc != UNQLITE_NOTIMPLEMENTED ){ /* Rollback */ unqlite_rollback(pDb); }
  • 20. Jx9 script /* Create the collection 'users' */ if( !db_exists('users') ){ /* Try to create it */ $rc = db_create('users'); } //The following is the JSON objects to be stored shortly in our 'users' collection $zRec = [{ name : 'james', age : 27, mail : 'dude@example.com' }]; //Store our records $rc = db_store('users',$zRec); //One more record $rc = db_store('users',{ name : 'alex', age : 19, mail : 'alex@example.com' }); print "Total number of stored records: ",db_total_records('users'),JX9_EOL; //Fetch data using db_fetch_all(), db_fetch_by_id() and db_fetch().
  • 21. Jx9 script unqlite_vm *pVm; rc = unqlite_compile(pDb,JX9_PROG,sizeof(JX9_PROG)-1,&pVm); /* Install a VM output consumer callback */ rc = unqlite_vm_config(pVm,UNQLITE_VM_CONFIG_OUTPUT,OutputConsumer,0); /* Execute our script */ rc = unqlite_vm_exec(pVm); /* Finally, release our VM */ unqlite_vm_release(pVm);