当前位置:网站首页>Storage engine written by golang, based on b+ tree, mmap
Storage engine written by golang, based on b+ tree, mmap
2022-08-03 22:28:00 【InfoQ】
mydb
package main
import (
"fmt"
"github.com/alberliu/mydb"
"strconv"
)
func toBytes(i int) []byte {
return []byte(strconv.Itoa(i))
}
func main() {
db, err := mydb.Open("data")
if err != nil {
panic(err)
}
fmt.Println("init: ", db.Range(mydb.Infinity, mydb.Infinity))
for i := 1; i <= 5; i++ {
db.Add(toBytes(i), toBytes(i))
}
fmt.Println("add: ", db.Range(mydb.Infinity, mydb.Infinity))
db.Update(toBytes(1), toBytes(4))
fmt.Println("update", db.Range(mydb.Infinity, mydb.Infinity))
db.Delete(toBytes(1))
fmt.Println("delete", db.Range(mydb.Infinity, mydb.Infinity))
fmt.Println("range", db.Range(toBytes(3), toBytes(4)))
}
边栏推荐
- navicat 连接 mongodb 报错[13][Unauthorized] command listDatabases requires authentication
- 授人以渔 - 如何自行查询任意 SAP UI5 控件属性的文档和技术实现细节试读版
- 4年工作经验,多线程间的5种通信方式都说不出来,你敢信?
- MiniAPI of .NET6 (14): Cross-domain CORS (Part 1)
- Adobe是什么?
- 113. Teach a Man how to fish - How to query the documentation and technical implementation details of any SAP UI5 control property by yourself
- LabVIEW code generation error 61056
- 线上服务器老是卡,该如何优化?
- HCIP第十五天
- What is Adobe?
猜你喜欢

七夕快乐!

藏宝计划TreasureProject(TPC)系统模式开发技术原理
Causes of Mysql Disk Holes and Several Ways to Rebuild Tables

Diazo Biotin-PEG3-DBCO | Diazo Compound Modified Biotin-Tripolyethylene Glycol-Dibenzocyclooctyne

2022-08-02 mysql/stonedb慢SQL-Q18-内存使用暴涨分析

Cisco ike2 IPSec配置

Go开发工具GoLand V2022.2 来了——Go 工作区重大升级

如何设计 DAO 的 PoW 评判标准 并平衡不可能三角

目标检测技术研究现状及发展趋势

HCIP第十六天
随机推荐
数据一致性:双删为什么要延时?
封装、包、访问权限修饰符、static变量
Cisco ike2 IPSec配置
LabVIEW code generation error 61056
举一个 web worker 的例子
Quickly build a website with static files
Internet user account information management regulations come into effect today: must crack down on account trading and gray products
FinClip最易用的智能电视小程序
Teach a Man How to Fish - How to Query the Properties of Any SAP UI5 Control by Yourself Documentation and Technical Implementation Details Demo
CAS:153162-70-0_N-BOC-6-Biotinamidohexylamine
Codeup brushing notes - simple simulation
Cloud platform construction solutions
21天打卡挑战学习MySQL——《MySQL工具的使用》第一周 第二篇
目标检测技术研究现状及发展趋势
log4j-slf4j-impl cannot be present with log4j-to-slf4j
Network basic learning series four (network layer, data link layer and some other important protocols or technologies)
UVa 1025 - A Spy in the Metro (White Book)
.NET6之MiniAPI(十四):跨域CORS(上)
386. Lexicographical Numbers
480. Sliding Window Median