LiteDB source analytic series (1) LiteDB Introduction

  Recent use Dragon Boat Festival holiday, I LiteDB source read it carefully read, hearty, really gain a lot. Later writing a series of articles on LteDB of everyone to share the hope that such a good source not to be buried.

What is 1.LiteDB

  This is a small .NET platform open source NoSQL database file types lightweight. Characterized by small and fast, due entirely 'written by C #, so you can support LINQ, create the database is a single file, similar Sqlite.

  Chinese presentation about it we can look at .net predecessors - the top of the data of the blog: https://www.cnblogs.com/asxinyu/p/dotnet_Opensource_project_LiteDB.html

  Chinese website: http://www.litedb.org/

  The main features are:

1.NoSQL file storage. This is a traditional relational database and the main difference; support for entity class field update;
2. similar MongoDB simple API;
3. completely in C # code written in .NET 4.0 environment, the core dll small, only 168K;
4. support ACID transactions;
5 can recover writing fails;
6. stored in the file or data stream (similar MongoDB of the GridFS);
7. the similar Sqlite single file storage;
8. support file index, can quickly search ; files can be stored directly;

9. Support Linq query; [This is perhaps the most immediate benefits written in C #];
10. Support command line database, provides an official the Command Line Shell;
11. fully open source and free, including commercial use;

  I mainly read the source code is 0.0.8 version, this version is LiteDB original version. Although this version has some bug, but in relation to later releases, this version of the technology is very simple and crude, to start faster. Detailed analysis of the back is carried out according to 0.0.8 version.

2.LiteDB source file structure

  Here posted a 0.0.8 version of the project structure:

  Document: LiteDB serialized to disk using a data format called Bson, only the name implies bson similar json data sequence into a byte array, Bson defined classes, arrays, data types in the Document Module.

  Engine: this module is to interact with the user most LiteEngine class (later versions changed his name LiteDatabase) and LiteCollection class, LiteEngine for users to create or open a database interface, LiteCollection is used to make CRUD operations on a single table we look at the source code, can these two classes as a breakthrough.

  Query: This module provides support for Linq database, the user lambda expression is parsed into a series of expressions such QueryVisitor class in this module: and, or, between, less like.

  Serializer: This module provides a sequence of Bson performed for different types of data, version 0.0.8 using fastBinaryJSON the open source components, later versions are no longer used.

  Shell: This module provides support for the database script.

  Storage: This folder contains the entire core of the three most LiteDB implementation module that is Pages, Structures, Services.

  Pages: definition of a database page: Header Page, Collection Page, Index Page, Data Page, Extend Page.

  Structures: defines the data structure of five CollectionIndex (table index), DataBlock (data block), PageAddress (page address), IndexKey (key index) and IndexNode (inode).

  Services: including the cache, the hard disk read and write, the index query, add or delete data pages to change search operation, a rollback operation and other functions to achieve database.

  Utils: This is some common tools and exception definitions.

3. Follow-up Introduction

  Behind the series I will focus on explaining the following sections:

  1.LiteDB concept on page role, CollectionIndex, DataBlock and IndexNode these data structures.

  How 2.Query module implements linq function, try to answer questions about the way the top of the page of bloggers data presented in the blog.

  3.LiteDB how to use the index query, the index contrast Mysql way, LiteDB jump out with a table index shows visual way.

  This is my first time in the form of blog parsing source code, if flawed, but also look more than correction.

 

Guess you like

Origin www.cnblogs.com/xiaozhangStudent/p/11012060.html