SlideShare una empresa de 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);
감사합니다.

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Destacado

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
 

Destacado (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...
 

Similar 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
 

Similar 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

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

Último (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

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);