当前位置:网站首页>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)))
}
边栏推荐
- Go开发工具GoLand V2022.2 来了——Go 工作区重大升级
- Codeup brushing notes - simple simulation
- Internet user account information management regulations come into effect today: must crack down on account trading and gray products
- Nine ways to teach you to read the file path in the resources directory
- 优化查询(工作中)
- CAS:153162-70-0_N-BOC-6-Biotinamidohexylamine
- L2-041 插松枝
- [N1CTF 2018] eating_cms
- Conditional Statements for Shell Programming
- 封装、包、访问权限修饰符、static变量
猜你喜欢
Causes of Mysql Disk Holes and Several Ways to Rebuild Tables

Bytebase database schema change management tool

直播预告 | 构建业务智联,快速拥抱财务数字化转型

HCIP BGP实验报告

21天打卡挑战学习MySQL——《MySQL工具的使用》第一周 第二篇

LabVIEW code generation error 61056

Summary bug 】 【 Elipse garbled solution project code in Chinese!

嵌入式系统:GPIO

Quickly build a website with static files

嵌入式开发:嵌入式基础——代码和数据空间揭秘
随机推荐
[b01lers2020]Life on Mars
113. 授人以渔 - 如何自行查询任意 SAP UI5 控件属性的文档和技术实现细节
What is the difference between the generator version and the viewer version?
【bug】汇总Elipse项目中代码中文乱码解决方法!
LabVIEW代码生成错误 61056
2022的七夕,奉上7个精美的表白代码,同时教大家快速改源码自用
线上服务器老是卡,该如何优化?
[b01lers2020]Life on Mars
Canvas App中点击图标生成PDF并保存到Dataverse中
【day1】
With 4 years of work experience, the 5 communication methods between multi-threads can't be said, can you believe it?
October 2019 Twice SQL Injection
如何创建一个Web项目
【开源框架】国内首个通用云计算框架,任意程序都可做成云计算。
获国际权威认可 | 云扩科技入选《RPA全球市场格局报告,Q3 2022》
电商秒杀系统
Live Preview | Build Business Intelligence, Quickly Embrace Financial Digital Transformation
藏宝计划TreasureProject(TPC)系统模式开发技术原理
用于流动质押和收益生成的 Web3 基础设施
嵌入式系统:概述