Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVI Formatting README with hints of linter markdown #424

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 41 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
# goLevelDB

This is an implementation of the [LevelDB key/value database](https://github.com/google/leveldb) in the [Go programming language](https://go.dev).

[![Build Status](https://app.travis-ci.com/syndtr/goleveldb.svg?branch=master)](https://app.travis-ci.com/syndtr/goleveldb)

Installation
-----------
## Other language

[ru_RU.UTF-8](./docs/README_ru.md)

go get github.com/syndtr/goleveldb/leveldb
## Installation

Requirements
-----------
```bash
go get github.com/syndtr/goleveldb/leveldb
```

* Need at least `go1.14` or newer.
## Requirements

Usage
-----------
Need at least `go1.14` or newer.

## Usage

Create or open a database:

```go
// The returned DB instance is safe for concurrent use. Which mean that all
// DB's methods may be called concurrently from multiple goroutine.
Expand All @@ -24,7 +30,9 @@ db, err := leveldb.OpenFile("path/to/db", nil)
defer db.Close()
...
```

Read or modify the database content:

```go
// Remember that the contents of the returned slice should not be modified.
data, err := db.Get([]byte("key"), nil)
Expand All @@ -36,53 +44,62 @@ err = db.Delete([]byte("key"), nil)
```

Iterate over database content:

```go
iter := db.NewIterator(nil, nil)
for iter.Next() {
// Remember that the contents of the returned slice should not be modified, and
// only valid until the next call to Next.
key := iter.Key()
value := iter.Value()
...
// Remember that the contents of the returned slice should not be modified, and
// only valid until the next call to Next.
key := iter.Key()
value := iter.Value()
...
}
iter.Release()
err = iter.Error()
...
```

Seek-then-Iterate:

```go
iter := db.NewIterator(nil, nil)
for ok := iter.Seek(key); ok; ok = iter.Next() {
// Use key/value.
...
// Use key/value.
...
}
iter.Release()
err = iter.Error()
...
```

Iterate over subset of database content:

```go
iter := db.NewIterator(&util.Range{Start: []byte("foo"), Limit: []byte("xoo")}, nil)
for iter.Next() {
// Use key/value.
...
// Use key/value.
...
}
iter.Release()
err = iter.Error()
...
```

Iterate over subset of database content with a particular prefix:

```go
iter := db.NewIterator(util.BytesPrefix([]byte("foo-")), nil)
for iter.Next() {
// Use key/value.
...
// Use key/value.
..
}
iter.Release()
err = iter.Error()
...
```

Batch writes:

```go
batch := new(leveldb.Batch)
batch.Put([]byte("foo"), []byte("value"))
Expand All @@ -91,17 +108,19 @@ batch.Delete([]byte("baz"))
err = db.Write(batch, nil)
...
```

Use bloom filter:

```go
o := &opt.Options{
Filter: filter.NewBloomFilter(10),
Filter: filter.NewBloomFilter(10),
}
db, err := leveldb.OpenFile("path/to/db", o)
...
defer db.Close()
...
```
Documentation
-----------

## Documentation

You can read package documentation [here](https://pkg.go.dev/github.com/syndtr/goleveldb).
123 changes: 123 additions & 0 deletions docs/README_ru.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# goLevelDB

Этот проект является реализацией [LevelDB key/value database](https://github.com/google/leveldb) на языке программирования [Go](https://go.dev).

[![Build Status](https://app.travis-ci.com/syndtr/goleveldb.svg?branch=master)](https://app.travis-ci.com/syndtr/goleveldb)

## Установка

```bash
go get github.com/syndtr/goleveldb/leveldb
```

## Требования

Необходим компилятор `go1.14` или новее.

## Использование

Cjplfybt yjdjq ,fps lfyys[]:

```go
// Возвращает новый экземпляр DB, безопасный для конкурентного использования. Which mean that all
// DB's methods may be called concurrently from multiple goroutine.
db, err := leveldb.OpenFile("path/to/db", nil)
...
defer db.Close()
...
```

Чтение или изменение содержимого базы данных:

```go
// Remember that the contents of the returned slice should not be modified.
data, err := db.Get([]byte("key"), nil)
...
err = db.Put([]byte("key"), []byte("value"), nil)
...
err = db.Delete([]byte("key"), nil)
...
```

Итерация по содержимому базы данных:

```go
iter := db.NewIterator(nil, nil)
for iter.Next() {
// Remember that the contents of the returned slice should not be modified, and
// only valid until the next call to Next.
key := iter.Key()
value := iter.Value()
...
}
iter.Release()
err = iter.Error()
...
```

Поиск через итерацию:

```go
iter := db.NewIterator(nil, nil)
for ok := iter.Seek(key); ok; ok = iter.Next() {
// Use key/value.
...
}
iter.Release()
err = iter.Error()
...
```

Iterate over subset of database content:
Итерация по подмножеству ключей по содержимому базы данных:

```go
iter := db.NewIterator(&util.Range{Start: []byte("foo"), Limit: []byte("xoo")}, nil)
for iter.Next() {
// Use key/value.
...
}
iter.Release()
err = iter.Error()
...
```

Итерация по подмножеству ключей с указанным префиксом:

```go
iter := db.NewIterator(util.BytesPrefix([]byte("foo-")), nil)
for iter.Next() {
// Use key/value.
..
}
iter.Release()
err = iter.Error()
...
```

Пакетная запись

```go
batch := new(leveldb.Batch)
batch.Put([]byte("foo"), []byte("value"))
batch.Put([]byte("bar"), []byte("another value"))
batch.Delete([]byte("baz"))
err = db.Write(batch, nil)
...
```

С использованием фильтра Блума:

```go
o := &opt.Options{
Filter: filter.NewBloomFilter(10),
}
db, err := leveldb.OpenFile("path/to/db", o)
...
defer db.Close()
...
```

## Документация

Вы можете прочитать документацию [здесь](https://pkg.go.dev/github.com/syndtr/goleveldb).