Make a small contribution to the C #. Net brothers-nosql leveldb. Net transplanted general PC 1 million data inserts cannot exceed 4 seconds

Source: Internet
Author: User
Tags key string

Make a small contribution to the C #. Net brothers-nosql leveldb. Net transplanted version of the general PC 1 million data insertion does not exceed 4 seconds

Multi-thread and concurrent Security

Solution:
Http://pan.baidu.com/share/link? Consumer id = 508379 & UK = 201606611

If you have any questions, please contact: QQ chat group 204725117

Leveldb is a key/value pair (key/Value Pair) embedded database management system programming library developed by Google. It is released with an open-source BSD license [1.

High Performance and simple architecture: Only API calls are supported, and SQL languages are not supported.
Free software and open source software
Data can be compressed by the snappy library to reduce disk I/O and improve efficiency.

Currently, only Linux is fully developed by C ++ and supports TB-level data. This project will be transplanted to Windows and. Net platforms!

Example of calling code:

Using system; using system. collections. generic; using system. LINQ; using system. text; using system. io; using websystem. framework. dao. leveldb; namespace leveldbdemo {class program {static DB database {Get; set;} static string databasepath {Get; set;} static void main (string [] ARGs) {var temppath = path. gettemppath (); var randname = path. getrandomfilename (); databasepath = path. combine (temppath, randname); cache c = new cache (100*1024*1024); var Options = new options () {blockcache = C, createifmissing = true ,}; database = new dB (options, "mylevel. DB "); // start time timespan runtime = new timespan (datetime. now. ticks); // insert 1 million K, V for (INT I = 0; I <1000000; I ++) {database. put (I. tostring (), I. tostring () + "A");} // retrieve all data by iteration // var entries = new list <keyvaluepair <string, string> (); // try // {// foreach (VAR entry in Database) // {// entries. add (entry); //} // catch {} // obtain the value of a key string value = database. get ("123455"); // around 0.00x seconds // End Time timespan timenow = new timespan (datetime. now. ticks); // time interval timespan Ts = timenow. subtract (runtime ). duration (); console. writeline ("time used:" + ts. totalseconds. tostring () + "seconds" + ts. totalmilliseconds. tostring () + "millisecond ");}}}

Copyright: Alibaba Cloud search Development Team

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.