rocksdb ubuntu c++源碼編譯測試

2019獨角獸企業重金招聘Python工程師標準>>> hot3.png

環境: ubuntu16.4 需要安裝 snappy gflage bz2 zstd 以及g++ 其中zstd是facebook開放源代碼里的壓縮的庫

git clone?https://github.com/facebook/rocksdb.git

cd rocksdb?

make static_lib 成功生成 librocksdb.a靜太庫(使用動態庫,make share_lib)

cd examples/

測試?simple_example.cc 編譯命令:

g++ simple_example.cc -o test -I ../include ../librocksdb.a -std=c++11 -lpthread -lrt -lsnappy -lgflags -lz -lbz2 -lzstd 成功后生成test可執行文件

./test

修改simple_example?

// Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.#include <cstdio>
#include <string>
#include <iostream>#include "rocksdb/db.h"
#include "rocksdb/slice.h"
#include "rocksdb/options.h"using namespace rocksdb;
using namespace std;std::string kDBPath = "/tmp/rocksdb_simple_example";int main() {DB* db;Options options;// Optimize RocksDB. This is the easiest way to get RocksDB to perform welloptions.IncreaseParallelism();options.OptimizeLevelStyleCompaction();// create the DB if it's not already presentoptions.create_if_missing = true;// open DBStatus s = DB::Open(options, kDBPath, &db);assert(s.ok());// Put key-values = db->Put(WriteOptions(), "key1", "value");assert(s.ok());std::string value;// get values = db->Get(ReadOptions(), "key1", &value);assert(s.ok());assert(value == "value");std::cout << value << std::endl;// atomically apply a set of updates{WriteBatch batch;batch.Delete("key1");batch.Put("key2", value);s = db->Write(WriteOptions(), &batch);}s = db->Get(ReadOptions(), "key1", &value);assert(s.IsNotFound());db->Get(ReadOptions(), "key2", &value);assert(value == "value");std::cout << value << std::endl;delete db;return 0;
}

再次編譯,輸出value value?

轉載于:https://my.oschina.net/u/198124/blog/908795

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/541321.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541321.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541321.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

vs生成linux服務器程序,從Visual Studio到Linux上調試C++代碼

從Visual Studio到Linux上調試C代碼04/30/20155 分鐘可看完本文內容[原文發表時間] 2015/4/29 10:00 PM正如您可能已經聽說的那樣&#xff0c;Visual Studio 2015新推出了對Android開發的GDB支持。有趣的是&#xff0c;因為這項功能依賴GDB調試&#xff0c;我們完全可能稍加改動…

java clock計時_Java Clock類| 實例的Instant()方法

java clock計時Clock Class Instant()方法 (Clock Class instant() method) instant() method is available in java.time package. Instant()方法在java.time包中可用。 instant() method is used to get the current instant that is used with this Clock. Instant()方法用于…

使用國內DOCKER鏡像源

在國內&#xff0c;通過Docker的pull和push命令訪問hub.docker時&#xff0c;網絡十分慢&#xff0c;而且會出現各種各樣的網絡連接問題。因此這里介紹下如何使用國內的鏡像源&#xff0c;這里以DaoCloud為例。注冊DaoCloud用戶;注冊完成后&#xff0c;會進入dashboard頁面&…

linux命令top查看進程,linux 查看進程的命令(top)

標簽&#xff1a;top操作系統支持多任務并不是計算機同時做很多事情&#xff0c;而是快速的輪換著執行這些任務。linux安排不同的程序等待使用CPU。進程的工作方式&#xff1a;當系統啟動的時候&#xff0c;內核先把自己的程序初始化為進程&#xff0c;然后運行一個init的程序&…

stl vector 函數_vector :: back()函數以及C ++ STL中的示例

stl vector 函數C vector :: back()函數 (C vector::back() function) vector::back() is a library function of "vector" header, it is used to access the last element from the vector, it returns a reference to the last element of the vector. vector ::…

linux udp 端口 抓包,tcpdump之UDP抓包

摘要使用tcpdump抓UDP包&#xff0c;過濾過濾IP和port&#xff0c;并且自動拆分片段。安裝tcpdumpyum install -y tcpdump使用方法tcpdump -i bond0 udp port xxxx and host xxx.x.xx.xxx -s0 -G 600 -w %Y_%m%d_%H%M_%S.pcap參數說明-i 指定監聽的網卡udp 監聽UDP協議port 指定…

Vue版本過渡變化

到了2.0以后&#xff0c;有哪些變化&#xff1a; 在每個組件模板&#xff0c;不在支持片段代碼之前: <template id”aaa”><h3>我是組件</h3><strong>我是加粗標簽</strong></template> 現在: 必須有根元素&#xff0c;包裹住所有的代碼 …

NABARD的完整形式是什么?

NABARD&#xff1a;國家農業和農村發展銀行 (NABARD: National Bank for Agriculture and Rural Development) NABARD is an abbreviation of National Bank for Agriculture and Rural Development. NABARD是國家農業和農村發展銀行的縮寫 。 On 12 July 1982, it was establ…

基于opencv+Dlib的面部合成(Face Morph)

引自&#xff1a;http://blog.csdn.net/wangxing233/article/details/51549880 零、前言 前段時間看到文章【1】和【2】&#xff0c;大概了解了面部合成的基本原理。這兩天空下來了&#xff0c;于是參考【3】自己實現了下。雖然【1】和【2】已經講的很清楚了&#xff0c;但是有…

大腦應對危機的模式_危機的完整形式是什么?

大腦應對危機的模式危機&#xff1a;印度信用評級信息服務有限公司 (CRISIL: Credit Rating Information Services of India Limited) CRISIL is an abbreviation of Credit Rating Information Services of India Limited. It is an international analytic company which off…

linux網絡延遲命令,2. Linux使用ping命令查看網絡延遲

ping命令持續發送少量互聯網流量到遠程地址并報告收到回應的總時間。如果流量因為網絡故障或者錯誤配置而被丟棄&#xff0c;它也會報告。ping命令是最基本和初級的診斷網絡問題的工具之一。ping常被用來測試網絡延遲&#xff0c;但是有時ping的延遲并不是網絡引起的&#xff0…

一、簡單工廠模式

# public class Operation //基類{private double _numberA 0;private double _numberB 0;public double NumberA{get{ return _numberA; }set{_numberA value;}}public double NumberB{get{ return _numberB; }set{_numberB value;}}public virtual double GetResult(){d…

軟件生命周期模型及其類型

A life cycle model is also known as a process model. As the name suggests, the software life cycle model (or the software process model) gives us a pictorial representation of the entire software development process. 生命周期模型也稱為過程模型 。 顧名思義&…

linux查看磁盤io帶寬,[Linux] 磁盤IO性能查看和優化以及iostat命令

iostat命令:%user&#xff1a;CPU處在用戶模式下的時間百分比。%nice&#xff1a;CPU處在帶NICE值的用戶模式下的時間百分比。%system&#xff1a;CPU處在系統模式下的時間百分比。%iowait&#xff1a;CPU等待輸入輸出完成時間的百分比。%steal&#xff1a;管理程序維護另一個虛…

Jsoup 數據修改

2019獨角獸企業重金招聘Python工程師標準>>> 1 設置屬性的值 在解析一個Document之后可能想修改其中的某些屬性值&#xff0c;然后再保存到磁盤或都輸出到前臺頁面。 可以使用屬性設置方法 Element.attr(String key, String value), 和 Elements.attr(String key, S…

軟件靜態架構 軟件組件圖_組件圖| 軟件工程

軟件靜態架構 軟件組件圖什么是組件圖&#xff1f; (What is Component Diagram?) A Component Diagram breaks down the real system under development into different heights of working. Every component is reactive for the main aim in the entire system and only re…

如何卸載非linux系統分區,如何卸載Linux系統分區?卸載Linux系統分區的方法-站長資訊中心...

系統為windows xp sp2和redhat as 5雙系統&#xff0c;其中linux系統后安裝的在D盤&#xff0c;華彩軟件站www.huacolor.com小編今天發現硬盤不夠用了&#xff0c;想干掉linux分區&#xff0c;在虛擬機中用linux。就在windows的磁盤管理(命令為:diskmgmt)下刪除linux分區&#…

順序結構復習

復習一些易錯知識點還有習題 目錄 可能不熟悉的知識點 邏輯表達式的求解 if,else的配隊 條件運算符 運算符優先級的問題 switch的使用 goto和if構成的循環 例題講解 1 2 3 4 ?編輯 5 ?編輯 6賦值 ?編輯 7 可能不熟悉的知識點 邏輯表達式的求解 如果…

模板模式(部分方法延遲到子類實現)

項目中&#xff0c;用到了抽象類作為父類&#xff0c;有部分實現。 提供了了模板方法作為子類公共方法&#xff0c;模板方法中調用了抽象類的抽象方法和部分非抽象方法。 執行代碼時&#xff0c;發現模板方法調用了抽象類的抽象方法&#xff0c;當時比較好奇&#xff0c;后來發…

ruby 集合 分組_在Ruby中找到兩個集合之間的區別

ruby 集合 分組Finding differences simply means that finding elements that are uncommon between two sets as well as are only present in the first set. We can find this, with the help of a – operator. You can also consider the objective as to find the uniqu…