O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting Started with LevelDB

Book Description

Learn how to build a high-performing app with an embedded database on iOS or OS X thanks to this superb, hands-on guide to LevelDB. Designed for beginners, but also a useful reference manual for the more experienced.

  • Understand how a sorted key-value store like LevelDB can support any app
  • Learn to use LevelDB from simple C++ code on iOS and OS/X
  • Use LevelDB as a support for any OS/X, iPhone, or iPad app through a series of practical examples

In Detail

Mobile and standalone desktop apps often need to store and rapidly retrieve data. LevelDB scales from a few simple values up to trillions of records and is flexible enough to store any kind of data.

Getting Started with LevelDB progresses through the sophisticated ways to use databases. It starts by explaining how to install and build LevelDB from the basics, and moves on to explain the different Objective-C layers for LevelDB. It can be used as an introduction to database-backed iOS apps, as well as provides clarification to key-value stores and helps you understand how they relate to SQL.

LevelDB is a flexible data solution that uses key-value stores to allow for the development of highly complex, efficient data storage systems. From the basics of data storage and retrieval to complex cases involving data storage for apps, this book covers a wide range of LevelDB topics

Even relatively simple apps may have the need to search their data using different terms. Getting Started with LevelDB shows how to design keys to retrieve and store data efficiently. You will learn how its “levelled” nature delivers speedy writes and how to tune its settings and design for performance. You will also see a few techniques for debugging and tuning.

Getting Started with LevelDB will leave you as an accomplished LevelDB programmer, confident you can build a complex database-backed app with high performance on iOS or OS/X.

Table of Contents

  1. Getting Started with LevelDB
    1. Table of Contents
    2. Getting Started with LevelDB
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. Downloading LevelDB and Building with OS X
      1. Installing LevelDB
        1. Building the LevelDB libraries
        2. Installing snappy
        3. Removing snappy
      2. Moving to Xcode
      3. Summary
    9. 2. Installing LevelDB and Building for iOS
      1. Building the static LevelDB library for iOS
        1. Creating a minimal iOS Testbed
        2. Adding LevelDB to the iOS Testbed
      2. Summary
    10. 3. Basic Key-value Operations – Creating and Deleting Data
      1. Understanding C++ idioms in LevelDbHelper.h
      2. Using Get and Put for strings
      3. Understanding Slice – the efficient LevelDB parameter object
      4. Using Get and Put with binary values
      5. Using Delete – the final third of key-value operations
      6. Wrapping operations in WriteBatch for increased safety
      7. Summary
    11. 4. Iteration and Searching Keys
      1. Introducing Sample04 to show you loops and searches
        1. Creating test records with a loop
          1. Stepping through all the records with iterators
        2. Searching for ranges of keys
          1. Linking records in a simple relational style
      2. Summary
    12. 5. Using Objective-C
      1. Open source wrappers for LevelDB in Objective-C
      2. Using Objective-C for simple data access
      3. Extending APLevelDB to expose the C++ API
      4. Importing text data to load a database
      5. Summary
    13. 6. Integrating with a Cocoa UI
      1. Meeting the data source needs with LevelDB
      2. Creating the OS X GUI
      3. Connecting the database to the NSTableView
      4. Connecting record details to the editing form
      5. Recommended Xcode books
      6. Summary
    14. 7. Debugging with REPLs and Command Lines
      1. Building and running the LevelDB dump utility
      2. Installing Node.js and the lev utility
        1. Adding a REPL for debugging inside your iOS app
      3. Summary
    15. 8. Richer Keys and Data Structures
      1. Completing the data source for a rich GUI
      2. Extending the OS X GUI to fully support editing
      3. Connecting the database to the NSTableView
      4. Connecting record details to the editing form
      5. Saving data with key updates
      6. Responding to the new and delete commands
        1. Key design for LevelDB versus relational theory and SQL
      7. Deciding when to store one record or split values
      8. Implementing schemas for LevelDB
      9. Dealing with integer key endianness
        1. Using comparators to vary key ordering
      10. Summary
    16. 9. A Document Database
      1. Key design for searching the document database
        1. Defining the schema using APLevelDBSS
      2. Database fields for tracking documents
      3. Databases as documents via packages
      4. Summary
    17. 10. Tuning and Key Policies
      1. Understanding the Level in LevelDB
        1. Understanding that deleting is another form of write
        2. Understanding how reads work from the top down
        3. Understanding how snapshots make reading predictable
      2. Understanding how Bloom filters help guesses
        1. Tuning using Bloom filters or alternatives
      3. Using settings that affect performance
      4. Tuning and structuring data by scenario
        1. Choosing to structure data according to update rate
        2. Caching choices for key performance based on expected access
        3. Using multiple databases depending on role
        4. Reconsidering policies for generating keys
      5. Summary
    18. A. Scripting Languages
      1. Using LevelDB from Node.js
      2. Using LevelDB from Python
      3. Using LevelDB from Ruby
      4. Summary
    19. Index