chore: align repo conventions (#2158)

This commit is contained in:
Ryan Fox-Tyler
2025-02-05 17:00:32 -05:00
committed by GitHub
parent c8275cdd1d
commit 94498ea84c
199 changed files with 7355 additions and 6411 deletions
-18
View File
@@ -1,18 +0,0 @@
version = 1
test_patterns = [
'integration/testgc/**',
'**/*_test.go'
]
exclude_patterns = [
]
[[analyzers]]
name = 'go'
enabled = true
[analyzers.meta]
import_path = 'github.com/dgraph-io/badger'
+1 -1
View File
@@ -1,4 +1,4 @@
# CODEOWNERS info: https://help.github.com/en/articles/about-code-owners
# Owners are automatically requested for review for PRs that changes code
# that they own.
* @dgraph-io/committers
* @hypermodeinc/database
+38
View File
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ""
labels: bug
assignees: ""
---
## Describe the bug
A clear and concise description of what the bug is.
## To Reproduce
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
## Expected behavior
A clear and concise description of what you expected to happen.
## Screenshots
If applicable, add screenshots to help explain your problem.
## Environment
- OS: [e.g. macOS, Windows, Ubuntu]
- Language [e.g. AssemblyScript, Go]
- Version [e.g. v0.xx]
## Additional context
Add any other context about the problem here.
-62
View File
@@ -1,62 +0,0 @@
name: "🐞 Bug Report"
description: File a bug report
title: "[BUG]: <Title>"
labels: ["kind/bug", "status/triage"]
body:
- type: markdown
attributes:
value: |
Thank you for reporting an issue.
If you suspect this could be a bug, please follow this template.
- type: textarea
attributes:
label: What version of Badger are you using?
description: Copy and paste the tag or commit hash used in your application's go.mod file.
placeholder: |
Paste here.
validations:
required: false
- type: textarea
attributes:
label: What version of Go are you using?
description: Copy and paste all you see using the command 'go version'.
placeholder: |
Paste here.
validations:
required: false
- type: dropdown
attributes:
label: Have you tried reproducing the issue with the latest release?
options:
- "Yes"
- "No"
validations:
required: false
- type: textarea
attributes:
label: What is the hardware spec (RAM, CPU, OS)?
description: Share all possible context of your machine.
placeholder: |
Type here.
validations:
required: true
- type: textarea
attributes:
label: What steps will reproduce the bug?
description: Enter details about your bug (command/config used to set up Ristretto).
placeholder: |
Type here.
validations:
required: true
- type: textarea
attributes:
label: Expected behavior and actual result.
description: Enter details about your expectations.
placeholder: |
Type here.
validations:
required: false
- type: textarea
attributes:
label: Additional information
description: Tell us anything else you think we should know.
+5
View File
@@ -0,0 +1,5 @@
blank_issues_enabled: false
contact_links:
- name: Badger Community Support
url: https://discord.hypermode.com
about: Please ask and answer questions here
@@ -1,30 +0,0 @@
name: "📃 Documentation Request"
description: Suggest improvements, additions, or revisions to Badger documentation
title: "[Documentation]: <Title>"
labels: ["area/documentation", "status/triage"]
body:
- type: markdown
attributes:
value: |
Thank you for reporting an issue.
If you think Badger's documentation is lacking, please explain it here.
- type: textarea
attributes:
label: What version of Badger is the target?
description: Is it the latest version?
placeholder: |
Type here.
validations:
required: false
- type: textarea
attributes:
label: Documentation.
description: Explain which part of the documentation is lacking.
placeholder: |
Type here.
validations:
required: true
- type: textarea
attributes:
label: Additional information.
description: Tell us anything else you think we should know.
+23
View File
@@ -0,0 +1,23 @@
---
name: Feature request
about: Suggest an idea for this project
title: ""
labels: ""
assignees: ""
---
## Is your feature request related to a problem? Please describe
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
## Describe the solution you'd like
A clear and concise description of what you want to happen.
## Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
## Additional context
Add any other context or screenshots about the feature request here.
@@ -1,49 +0,0 @@
name: "⚡ Feature Request"
description: Suggest a new feature
title: "[FEATURE]: <Title>"
labels: ["kind/feature ", "status/triage"]
body:
- type: markdown
attributes:
value: |
Thank you for reporting an issue.
If you think we can make Badger better, describe your feature request here.
Note: Feature requests are judged based on user experience and modeled on
[Go Experience Reports](https://github.com/golang/go/wiki/ExperienceReports).
These reports should focus on the problems - they should not focus on and need not propose solutions.
- type: dropdown
attributes:
label: Have you tried Badger before this proposal? and did not find anything similar?
options:
- "Yes"
- "No"
validations:
required: false
- type: textarea
attributes:
label: What you wanted to do.
description: Enter details about your expectations.
placeholder: |
Type here.
validations:
required: true
- type: textarea
attributes:
label: What you actually did.
description: Enter details about your experience with Badger.
placeholder: |
Type here.
validations:
required: false
- type: textarea
attributes:
label: Why wasn't it great, with examples.
description: Enter details about your expectations.
placeholder: |
Type here.
validations:
required: false
- type: textarea
attributes:
label: Additional information.
description: Any external references to support your case.
-14
View File
@@ -1,14 +0,0 @@
name: "🙋 Question"
description: Question related to Badger
title: "[QUESTION]: <Title>"
labels: ["kind/question ", "status/triage"]
body:
- type: markdown
attributes:
value: |
The issue tracker is primarily for code related issues, bug reports, missing documentation, or feature requests.
- If you have a question, please consider asking it on https://discuss.dgraph.io
- type: textarea
attributes:
label: Question.
description: Ask your Question.
+22 -25
View File
@@ -1,29 +1,26 @@
<!--
Change Github PR Title
**Description**
Your title must be in the following format:
- `topic(Area): Feature`
- `Topic` must be one of `build|ci|docs|feat|fix|perf|refactor|chore|test`
Please explain the changes you made here.
Sample Titles:
- `feat(Enterprise)`: Backups can now get credentials from IAM
- `fix(Query)`: Skipping floats that cannot be Marshalled in JSON
- `perf: [Breaking]` json encoding is now 35% faster if SIMD is present
- `chore`: all chores/tests will be excluded from the CHANGELOG
-->
**Checklist**
## Problem
<!--
Please add a description with these things:
1. Explain the problem by providing a good description.
2. If it fixes any GitHub issues, say "Fixes #GitHubIssue".
3. If it corresponds to a Jira issue, say "Fixes DGRAPH-###".
4. If this is a breaking change, please prefix `[Breaking]` in the title. In the description, please put a note with exactly who these changes are breaking for.
-->
- [ ] Code compiles correctly and linting passes locally
- [ ] For all _code_ changes, an entry added to the `CHANGELOG.md` file describing and linking to
this PR
- [ ] Tests added for new functionality, or regression tests for bug fixes added as applicable
- [ ] For public APIs, new features, etc., PR on
[docs repo](https://github.com/dgraph-io/dgraph-docs) staged and linked here
## Solution
<!--
Please add a description with these things:
1. Explain the solution to make it easier to review the PR.
2. Make it easier for the reviewer by describing complex sections with comments.
-->
**Instructions**
- The PR title should follow the [Conventional Commits](https://www.conventionalcommits.org/)
syntax, leading with `fix:`, `feat:`, `chore:`, `ci:`, etc.
- The description should briefly explain what the PR is about. In the case of a bugfix, describe or
link to the bug.
- In the checklist section, check the boxes in that are applicable, using `[x]` syntax.
- If not applicable, remove the entire line. Only leave the box unchecked if you intend to come
back and check the box later.
- Delete the `Instructions` line and everything below it, to indicate you have read and are
following these instructions. 🙂
Thank you for your contribution to Badger!
+6
View File
@@ -0,0 +1,6 @@
self-hosted-runner:
# Labels of self-hosted runner in array of string
labels:
- warp-ubuntu-latest-x64-4x
- warp-ubuntu-latest-arm64-4x
- warp-ubuntu-latest-x64-16x
-28
View File
@@ -1,28 +0,0 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
day: "wednesday"
time: "16:00"
rebase-strategy: "disabled"
groups:
patch:
update-types: ["patch"]
minor:
update-types: ["minor"]
- package-ecosystem: "github-actions"
# Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.)
directory: "/"
schedule:
interval: "weekly"
day: wednesday
time: "16:00"
groups:
actions:
update-types:
- "patch"
- "minor"
- "major"
+4
View File
@@ -0,0 +1,4 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["local>hypermodeinc/renovate-config"]
}
+13 -5
View File
@@ -1,18 +1,23 @@
name: cd-badger
on:
workflow_dispatch:
inputs:
releasetag:
description: 'releasetag'
description: releasetag
required: true
type: string
permissions:
contents: read
jobs:
badger-build-amd64:
runs-on: warp-ubuntu-latest-x64-4x
steps:
- uses: actions/checkout@v4
with:
ref: '${{ github.event.inputs.releasetag }}'
ref: "${{ github.event.inputs.releasetag }}"
- name: Set up Go
uses: actions/setup-go@v5
with:
@@ -36,7 +41,8 @@ jobs:
- name: Build badger linux/amd64
run: make badger
- name: Generate SHA for Linux Build
run: cd badger && sha256sum badger-linux-amd64 | cut -c-64 > badger-checksum-linux-amd64.sha256
run:
cd badger && sha256sum badger-linux-amd64 | cut -c-64 > badger-checksum-linux-amd64.sha256
- name: Tar Archive for Linux Build
run: cd badger && tar -zcvf badger-linux-amd64.tar.gz badger-linux-amd64
- name: Upload Badger Binary Build Artifacts
@@ -46,12 +52,13 @@ jobs:
path: |
badger/badger-checksum-linux-amd64.sha256
badger/badger-linux-amd64.tar.gz
badger-build-arm64:
runs-on: warp-ubuntu-latest-arm64-4x
steps:
- uses: actions/checkout@v4
with:
ref: '${{ github.event.inputs.releasetag }}'
ref: "${{ github.event.inputs.releasetag }}"
- name: Set up Go
uses: actions/setup-go@v5
with:
@@ -75,7 +82,8 @@ jobs:
- name: Build badger linux/arm64
run: make badger
- name: Generate SHA for Linux Build
run: cd badger && sha256sum badger-linux-arm64 | cut -c-64 > badger-checksum-linux-arm64.sha256
run:
cd badger && sha256sum badger-linux-arm64 | cut -c-64 > badger-checksum-linux-arm64.sha256
- name: Tar Archive for Linux Build
run: cd badger && tar -zcvf badger-linux-arm64.tar.gz badger-linux-arm64
- name: List Artifacts
@@ -1,40 +0,0 @@
name: ci-aqua-security-trivy-tests
on:
pull_request:
paths-ignore:
- '**.md'
- '.github/*'
- '.github/ISSUE_TEMPLATE/*'
- 'docs/**'
- 'images/**'
types:
- opened
- reopened
- synchronize
- ready_for_review
branches:
- main
schedule:
- cron: "0 0 * * *"
permissions:
security-events: write
jobs:
build:
name: trivy-tests
runs-on: warp-ubuntu-latest-x64-4x
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: 'trivy-results.sarif'
@@ -1,17 +1,20 @@
name: ci-badger-bank-tests-nightly
on:
push:
paths-ignore:
- '**.md'
- '.github/*'
- '.github/ISSUE_TEMPLATE/*'
- 'docs/**'
- 'images/**'
- "**.md"
- docs/**
- images/**
branches:
- main
- 'release/v*'
- release/v*
schedule:
- cron: "1 3 * * *"
- cron: 1 3 * * *
permissions:
contents: read
jobs:
badger-bank:
runs-on: warp-ubuntu-latest-x64-4x
+9 -6
View File
@@ -1,15 +1,18 @@
name: ci-badger-bank-tests
on:
pull_request:
paths-ignore:
- '**.md'
- '.github/*'
- '.github/ISSUE_TEMPLATE/*'
- 'docs/**'
- 'images/**'
- "**.md"
- docs/**
- images/**
branches:
- main
- 'release/v*'
- release/v*
permissions:
contents: read
jobs:
badger-bank:
runs-on: warp-ubuntu-latest-x64-4x
@@ -1,33 +0,0 @@
name: ci-badger-tests-coverage
on:
pull_request:
paths-ignore:
- '**.md'
- '.github/*'
- '.github/ISSUE_TEMPLATE/*'
- 'docs/**'
- 'images/**'
branches:
- main
- 'release/v*'
jobs:
badger-tests-coverage:
runs-on: warp-ubuntu-latest-x64-4x
steps:
- uses: actions/checkout@v4 # checkout merge commit
with:
ref: "refs/pull/${{ github.event.number }}/merge"
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install Dependencies
run: make dependency
- name: Run Badger Tests
run: make test
- name: Install Goveralls
run: go install github.com/mattn/goveralls@latest
- name: Send Coverage Results
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLSIO_TOKEN }}
run: goveralls -coverprofile=cover.out
+9 -6
View File
@@ -1,15 +1,18 @@
name: ci-badger-tests
on:
pull_request:
paths-ignore:
- '**.md'
- '.github/*'
- '.github/ISSUE_TEMPLATE/*'
- 'docs/**'
- 'images/**'
- "**.md"
- docs/**
- images/**
branches:
- main
- 'release/v*'
- release/v*
permissions:
contents: read
jobs:
badger-tests:
runs-on: warp-ubuntu-latest-x64-4x
+9 -6
View File
@@ -1,14 +1,17 @@
name: ci-dgraph-tests
on:
push:
paths-ignore:
- '**.md'
- '.github/*'
- '.github/ISSUE_TEMPLATE/*'
- 'docs/**'
- 'images/**'
- "**.md"
- docs/**
- images/**
branches:
- main
permissions:
contents: read
jobs:
dgraph-tests:
runs-on: warp-ubuntu-latest-x64-16x
@@ -16,7 +19,7 @@ jobs:
- name: Checkout Dgraph repo
uses: actions/checkout@v4
with:
repository: dgraph-io/dgraph
repository: hypermodeinc/dgraph
ref: main
- name: Set up Go
uses: actions/setup-go@v5
-30
View File
@@ -1,30 +0,0 @@
name: ci-golang-lint
on:
pull_request:
paths-ignore:
- '**.md'
- '.github/*'
- '.github/ISSUE_TEMPLATE/*'
- 'docs/**'
- 'images/**'
branches:
- main
- 'release/v*'
jobs:
go-lint:
name: lint
runs-on: warp-ubuntu-latest-x64-4x
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: golang-lint
uses: golangci/golangci-lint-action@v6.2.0
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: latest
only-new-issues: true
args: --timeout=10m
skip-cache: true
-20
View File
@@ -1,20 +0,0 @@
name: 'Close stale issues and PRs'
on:
schedule:
- cron: '00 02 * * *'
permissions:
issues: write
pull-requests: write
actions: write
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v9
with:
days-before-issue-stale: 180
stale-issue-message: 'This issue has been stale for 60 days and will be closed automatically in 7 days. Comment to keep it open.'
stale-pr-message: 'This PR has been stale for 60 days and will be closed automatically in 7 days. Comment to keep it open.'
operations-per-run: 100
-32
View File
@@ -1,32 +0,0 @@
run:
skip-dirs:
skip-files:
linters-settings:
lll:
line-length: 120
staticcheck:
checks:
- all
- '-SA1019' # it is okay to use math/rand at times.
gosec:
excludes: # these are not relevant for us right now
- G114
- G204
- G306
- G404
linters:
disable-all: true
enable:
- errcheck
- gofmt
- goimports
- gosec
- gosimple
- govet
- ineffassign
- lll
- staticcheck
- unconvert
- unused
+9
View File
@@ -0,0 +1,9 @@
*out
*logs
*actions
*notifications
*tools
plugins
user_trunk.yaml
user.yaml
tmp
+2
View File
@@ -0,0 +1,2 @@
skip-check:
- CKV_GHA_7
+8
View File
@@ -0,0 +1,8 @@
{
"line-length": { "line_length": 150, "tables": false },
"no-inline-html": false,
"no-bare-urls": false,
"no-space-in-emphasis": false,
"no-emphasis-as-heading": false,
"first-line-heading": false
}
+5
View File
@@ -0,0 +1,5 @@
{
"semi": false,
"proseWrap": "always",
"printWidth": 100
}
+7
View File
@@ -0,0 +1,7 @@
enable=all
source-path=SCRIPTDIR
disable=SC2154
# If you're having issues with shellcheck following source, disable the errors via:
# disable=SC1090
# disable=SC1091
+7
View File
@@ -0,0 +1,7 @@
rules:
quoted-strings:
required: only-when-needed
extra-allowed: ["{|}"]
key-duplicates: {}
octal-values:
forbid-implicit-octal: true
+14
View File
@@ -0,0 +1,14 @@
export default {
plugins: [
{
name: "preset-default",
params: {
overrides: {
removeViewBox: false, // https://github.com/svg/svgo/issues/1128
sortAttrs: true,
removeOffCanvasPaths: true,
},
},
},
],
}
+46
View File
@@ -0,0 +1,46 @@
# This file controls the behavior of Trunk: https://docs.trunk.io/cli
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1
cli:
version: 1.22.9
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins:
sources:
- id: trunk
ref: v1.6.7
uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes:
enabled:
- go@1.23.5
- node@18.20.5
- python@3.10.8
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint:
enabled:
- renovate@39.161.0
- actionlint@1.7.7
- checkov@3.2.365
- git-diff-check
- gofmt@1.20.4
- golangci-lint@1.63.4
- markdownlint@0.44.0
- osv-scanner@1.9.2
- oxipng@9.1.3
- prettier@3.4.2
- shellcheck@0.10.0
- shfmt@3.6.0
- svgo@3.3.2
- taplo@0.9.3
- trufflehog@3.88.4
- yamllint@1.35.1
actions:
enabled:
- trunk-announce
- trunk-check-pre-push
- trunk-fmt-pre-commit
- trunk-upgrade-available
+485 -415
View File
File diff suppressed because it is too large Load Diff
+111 -3
View File
@@ -1,5 +1,113 @@
# Code of Conduct
# Contributor Covenant Code of Conduct
Our Code of Conduct can be found here:
## Our Pledge
https://dgraph.io/conduct
We as members, contributors, and leaders pledge to make participation in our community a
harassment-free experience for everyone, regardless of age, body size, visible or invisible
disability, ethnicity, sex characteristics, gender identity and expression, level of experience,
education, socio-economic status, nationality, personal appearance, race, religion, or sexual
identity and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and
healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our community include:
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the
experience
- Focusing on what is best not just for us as individuals, but for the overall community
Examples of unacceptable behavior include:
- The use of sexualized language or imagery, and sexual attention or advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email address, without their
explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior
and will take appropriate and fair corrective action in response to any behavior that they deem
inappropriate, threatening, offensive, or harmful.
Community leaders have the right and responsibility to remove, edit, or reject comments, commits,
code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and
will communicate reasons for moderation decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when an individual is
officially representing the community in public spaces. Examples of representing our community
include using an official e-mail address, posting via an official social media account, or acting as
an appointed representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community
leaders responsible for enforcement at hello@hypermode.com. All complaints will be reviewed and
investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the reporter of any
incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining the consequences for
any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or
unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing clarity around the
nature of the violation and an explanation of why the behavior was inappropriate. A public apology
may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series of actions.
**Consequence**: A warning with consequences for continued behavior. No interaction with the people
involved, including unsolicited interaction with those enforcing the Code of Conduct, for a
specified period of time. This includes avoiding interactions in community spaces as well as
external channels like social media. Violating these terms may lead to a temporary or permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including sustained inappropriate
behavior.
**Consequence**: A temporary ban from any sort of interaction or public communication with the
community for a specified period of time. No public or private interaction with the people involved,
including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this
period. Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community standards, including
sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement
of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
+36 -35
View File
@@ -1,18 +1,18 @@
# Contribution Guide
* [Before you get started](#before-you-get-started)
* [Code of Conduct](#code-of-conduct)
* [Your First Contribution](#your-first-contribution)
* [Find a good first topic](#find-a-good-first-topic)
* [Setting up your development environment](#setting-up-your-development-environment)
* [Fork the project](#fork-the-project)
* [Clone the project](#clone-the-project)
* [New branch for a new code](#new-branch-for-a-new-code)
* [Test](#test)
* [Commit and push](#commit-and-push)
* [Create a Pull Request](#create-a-pull-request)
* [Sign the CLA](#sign-the-cla)
* [Get a code review](#get-a-code-review)
- [Before you get started](#before-you-get-started)
- [Code of Conduct](#code-of-conduct)
- [Your First Contribution](#your-first-contribution)
- [Find a good first topic](#find-a-good-first-topic)
- [Setting up your development environment](#setting-up-your-development-environment)
- [Fork the project](#fork-the-project)
- [Clone the project](#clone-the-project)
- [New branch for a new code](#new-branch-for-a-new-code)
- [Test](#test)
- [Commit and push](#commit-and-push)
- [Create a Pull Request](#create-a-pull-request)
- [Sign the CLA](#sign-the-cla)
- [Get a code review](#get-a-code-review)
## Before you get started
@@ -25,25 +25,26 @@ Please make sure to read and observe our [Code of Conduct](./CODE_OF_CONDUCT.md)
### Find a good first topic
You can start by finding an existing issue with the
[good first issue](https://github.com/dgraph-io/badger/labels/good%20first%20issue) or [help wanted](https://github.com/dgraph-io/badger/labels/help%20wanted) labels. These issues are well suited for new contributors.
[good first issue](https://github.com/hypermodeinc/badger/labels/good%20first%20issue) or
[help wanted](https://github.com/hypermodeinc/badger/labels/help%20wanted) labels. These issues are
well suited for new contributors.
## Setting up your development environment
Badger uses [`Go Modules`](https://github.com/golang/go/wiki/Modules)
to manage dependencies. The version of Go should be **1.12** or above.
Badger uses [`Go Modules`](https://github.com/golang/go/wiki/Modules) to manage dependencies. The
version of Go should be **1.12** or above.
### Fork the project
- Visit https://github.com/dgraph-io/badger
- Visit https://github.com/hypermodeinc/badger
- Click the `Fork` button (top right) to create a fork of the repository
### Clone the project
```sh
$ git clone https://github.com/$GITHUB_USER/badger
$ cd badger
$ git remote add upstream git@github.com:dgraph-io/badger.git
git clone https://github.com/$GITHUB_USER/badger
cd badger
git remote add upstream git@github.com:hypermodeinc/badger.git
# Never push to the upstream master
git remote set-url --push upstream no_push
@@ -54,15 +55,15 @@ git remote set-url --push upstream no_push
Get your local master up to date:
```sh
$ git fetch upstream
$ git checkout master
$ git rebase upstream/master
git fetch upstream
git checkout master
git rebase upstream/master
```
Create a new branch from the master:
```sh
$ git checkout -b my_new_feature
git checkout -b my_new_feature
```
And now you can finally add your changes to project.
@@ -72,7 +73,7 @@ And now you can finally add your changes to project.
Build and run all tests:
```sh
$ ./test.sh
./test.sh
```
### Commit and push
@@ -80,28 +81,28 @@ $ ./test.sh
Commit your changes:
```sh
$ git commit
git commit
```
When the changes are ready to review:
```sh
$ git push origin my_new_feature
git push origin my_new_feature
```
### Create a Pull Request
Just open `https://github.com/$GITHUB_USER/badger/pull/new/my_new_feature` and
fill the PR description.
Just open `https://github.com/$GITHUB_USER/badger/pull/new/my_new_feature` and fill the PR
description.
### Sign the CLA
Click the **Sign in with Github to agree** button to sign the CLA. [An example](https://cla-assistant.io/dgraph-io/badger?pullRequest=1377).
Click the **Sign in with Github to agree** button to sign the CLA.
[An example](https://cla-assistant.io/hypermodeinc/badger?pullRequest=1377).
### Get a code review
If your pull request (PR) is opened, it will be assigned to one or more
reviewers. Those reviewers will do a code review.
If your pull request (PR) is opened, it will be assigned to one or more reviewers. Those reviewers
will do a code review.
To address review comments, you should commit the changes to the same branch of
the PR on your fork.
To address review comments, you should commit the changes to the same branch of the PR on your fork.
+2 -13
View File
@@ -1,17 +1,6 @@
#
# Copyright 2022 Dgraph Labs, Inc. and Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
# SPDX-License-Identifier: Apache-2.0
#
USER_ID = $(shell id -u)
+72 -66
View File
@@ -2,46 +2,44 @@
[![Go Reference](https://pkg.go.dev/badge/github.com/dgraph-io/badger/v4.svg)](https://pkg.go.dev/github.com/dgraph-io/badger/v4)
[![Go Report Card](https://goreportcard.com/badge/github.com/dgraph-io/badger/v4)](https://goreportcard.com/report/github.com/dgraph-io/badger/v4)
[![Sourcegraph](https://sourcegraph.com/github.com/dgraph-io/badger/-/badge.svg)](https://sourcegraph.com/github.com/dgraph-io/badger?badge)
[![ci-badger-tests](https://github.com/dgraph-io/badger/actions/workflows/ci-badger-tests.yml/badge.svg)](https://github.com/dgraph-io/badger/actions/workflows/ci-badger-tests.yml)
[![ci-badger-bank-tests](https://github.com/dgraph-io/badger/actions/workflows/ci-badger-bank-tests.yml/badge.svg)](https://github.com/dgraph-io/badger/actions/workflows/ci-badger-bank-tests.yml)
[![ci-golang-lint](https://github.com/dgraph-io/badger/actions/workflows/ci-golang-lint.yml/badge.svg)](https://github.com/dgraph-io/badger/actions/workflows/ci-golang-lint.yml)
[![Sourcegraph](https://sourcegraph.com/github.com/hypermodeinc/badger/-/badge.svg)](https://sourcegraph.com/github.com/hypermodeinc/badger?badge)
[![ci-badger-tests](https://github.com/hypermodeinc/badger/actions/workflows/ci-badger-tests.yml/badge.svg)](https://github.com/hypermodeinc/badger/actions/workflows/ci-badger-tests.yml)
[![ci-badger-bank-tests](https://github.com/hypermodeinc/badger/actions/workflows/ci-badger-bank-tests.yml/badge.svg)](https://github.com/hypermodeinc/badger/actions/workflows/ci-badger-bank-tests.yml)
[![ci-golang-lint](https://github.com/hypermodeinc/badger/actions/workflows/ci-golang-lint.yml/badge.svg)](https://github.com/hypermodeinc/badger/actions/workflows/ci-golang-lint.yml)
![Badger mascot](images/diggy-shadow.png)
BadgerDB is an embeddable, persistent and fast key-value (KV) database written
in pure Go. It is the underlying database for [Dgraph](https://dgraph.io), a
fast, distributed graph database. It's meant to be a performant alternative to
non-Go-based key-value stores like RocksDB.
BadgerDB is an embeddable, persistent and fast key-value (KV) database written in pure Go. It is the
underlying database for [Dgraph](https://dgraph.io), a fast, distributed graph database. It's meant
to be a performant alternative to non-Go-based key-value stores like RocksDB.
## Project Status
Badger is stable and is being used to serve data sets worth hundreds of
terabytes. Badger supports concurrent ACID transactions with serializable
snapshot isolation (SSI) guarantees. A Jepsen-style bank test runs nightly for
8h, with `--race` flag and ensures the maintenance of transactional guarantees.
Badger has also been tested to work with filesystem level anomalies, to ensure
persistence and consistency. Badger is being used by a number of projects which
includes Dgraph, Jaeger Tracing, UsenetExpress, and many more.
Badger is stable and is being used to serve data sets worth hundreds of terabytes. Badger supports
concurrent ACID transactions with serializable snapshot isolation (SSI) guarantees. A Jepsen-style
bank test runs nightly for 8h, with `--race` flag and ensures the maintenance of transactional
guarantees. Badger has also been tested to work with filesystem level anomalies, to ensure
persistence and consistency. Badger is being used by a number of projects which includes Dgraph,
Jaeger Tracing, UsenetExpress, and many more.
The list of projects using Badger can be found [here](#projects-using-badger).
Badger v1.0 was released in Nov 2017, and the latest version that is data-compatible
with v1.0 is v1.6.0.
Badger v1.0 was released in Nov 2017, and the latest version that is data-compatible with v1.0 is
v1.6.0.
Badger v2.0 was released in Nov 2019 with a new storage format which won't
be compatible with all of the v1.x. Badger v2.0 supports compression, encryption and uses a cache to speed up lookup.
Badger v2.0 was released in Nov 2019 with a new storage format which won't be compatible with all of
the v1.x. Badger v2.0 supports compression, encryption and uses a cache to speed up lookup.
Badger v3.0 was released in January 2021. This release improves compaction performance.
Badger v3.0 was released in January 2021. This release improves compaction performance.
Please consult the [Changelog] for more detailed information on releases.
For more details on our version naming schema please read [Choosing a version](#choosing-a-version).
[Changelog]:https://github.com/dgraph-io/badger/blob/main/CHANGELOG.md
[Changelog]: https://github.com/hypermodeinc/badger/blob/main/CHANGELOG.md
## Table of Contents
- [BadgerDB](#badgerdb)
- [Project Status](#project-status)
- [Table of Contents](#table-of-contents)
@@ -62,22 +60,26 @@ For more details on our version naming schema please read [Choosing a version](#
## Getting Started
### Installing
To start using Badger, install Go 1.21 or above. Badger v3 and above needs go modules. From your project, run the following command
To start using Badger, install Go 1.21 or above. Badger v3 and above needs go modules. From your
project, run the following command
```sh
$ go get github.com/dgraph-io/badger/v4
go get github.com/dgraph-io/badger/v4
```
This will retrieve the library.
#### Installing Badger Command Line Tool
Badger provides a CLI tool which can perform certain operations like offline backup/restore. To install the Badger CLI,
retrieve the repository and checkout the desired version. Then run
Badger provides a CLI tool which can perform certain operations like offline backup/restore. To
install the Badger CLI, retrieve the repository and checkout the desired version. Then run
```sh
$ cd badger
$ go install .
cd badger
go install .
```
This will install the badger command line utility into your $GOBIN path.
#### Choosing a version
@@ -89,18 +91,17 @@ This is why we follow a version naming schema that differs from Semantic Version
- New major versions are released when the data format on disk changes in an incompatible way.
- New minor versions are released whenever the API changes but data compatibility is maintained.
Note that the changes on the API could be backward-incompatible - unlike Semantic Versioning.
Note that the changes on the API could be backward-incompatible - unlike Semantic Versioning.
- New patch versions are released when there's no changes to the data format nor the API.
Following these rules:
- v1.5.0 and v1.6.0 can be used on top of the same files without any concerns, as their major
version is the same, therefore the data format on disk is compatible.
version is the same, therefore the data format on disk is compatible.
- v1.6.0 and v2.0.0 are data incompatible as their major version implies, so files created with
v1.6.0 will need to be converted into the new format before they can be used by v2.0.0.
- v2.x.x and v3.x.x are data incompatible as their major version implies, so files created with
v2.x.x will need to be converted into the new format before they can be used by v3.0.0.
v1.6.0 will need to be converted into the new format before they can be used by v2.0.0.
- v2.x.x and v3.x.x are data incompatible as their major version implies, so files created with
v2.x.x will need to be converted into the new format before they can be used by v3.0.0.
For a longer explanation on the reasons behind using a new versioning naming schema, you can read
[VERSIONING](VERSIONING.md).
@@ -112,63 +113,66 @@ Badger Documentation is available at https://dgraph.io/docs/badger
## Resources
### Blog Posts
1. [Introducing Badger: A fast key-value store written natively in
Go](https://open.dgraph.io/post/badger/)
1. [Introducing Badger: A fast key-value store written natively in Go](https://open.dgraph.io/post/badger/)
2. [Make Badger crash resilient with ALICE](https://open.dgraph.io/post/alice/)
3. [Badger vs LMDB vs BoltDB: Benchmarking key-value databases in Go](https://open.dgraph.io/post/badger-lmdb-boltdb/)
4. [Concurrent ACID Transactions in Badger](https://open.dgraph.io/post/badger-txn/)
## Design
Badger was written with these design goals in mind:
- Write a key-value database in pure Go.
- Use latest research to build the fastest KV database for data sets spanning terabytes.
- Optimize for SSDs.
Badgers design is based on a paper titled _[WiscKey: Separating Keys from
Values in SSD-conscious Storage][wisckey]_.
Badgers design is based on a paper titled _[WiscKey: Separating Keys from Values in SSD-conscious
Storage][wisckey]_.
[wisckey]: https://www.usenix.org/system/files/conference/fast16/fast16-papers-lu.pdf
### Comparisons
| Feature | Badger | RocksDB | BoltDB |
| ------- | ------ | ------- | ------ |
| Design | LSM tree with value log | LSM tree only | B+ tree |
| High Read throughput | Yes | No | Yes |
| High Write throughput | Yes | Yes | No |
| Designed for SSDs | Yes (with latest research <sup>1</sup>) | Not specifically <sup>2</sup> | No |
| Embeddable | Yes | Yes | Yes |
| Sorted KV access | Yes | Yes | Yes |
| Pure Go (no Cgo) | Yes | No | Yes |
| Transactions | Yes, ACID, concurrent with SSI<sup>3</sup> | Yes (but non-ACID) | Yes, ACID |
| Snapshots | Yes | Yes | Yes |
| TTL support | Yes | Yes | No |
| 3D access (key-value-version) | Yes<sup>4</sup> | No | No |
<sup>1</sup> The [WISCKEY paper][wisckey] (on which Badger is based) saw big
wins with separating values from keys, significantly reducing the write
amplification compared to a typical LSM tree.
| Feature | Badger | RocksDB | BoltDB |
| ----------------------------- | ------------------------------------------ | ----------------------------- | --------- |
| Design | LSM tree with value log | LSM tree only | B+ tree |
| High Read throughput | Yes | No | Yes |
| High Write throughput | Yes | Yes | No |
| Designed for SSDs | Yes (with latest research <sup>1</sup>) | Not specifically <sup>2</sup> | No |
| Embeddable | Yes | Yes | Yes |
| Sorted KV access | Yes | Yes | Yes |
| Pure Go (no Cgo) | Yes | No | Yes |
| Transactions | Yes, ACID, concurrent with SSI<sup>3</sup> | Yes (but non-ACID) | Yes, ACID |
| Snapshots | Yes | Yes | Yes |
| TTL support | Yes | Yes | No |
| 3D access (key-value-version) | Yes<sup>4</sup> | No | No |
<sup>2</sup> RocksDB is an SSD optimized version of LevelDB, which was designed specifically for rotating disks.
As such RocksDB's design isn't aimed at SSDs.
<sup>1</sup> The [WISCKEY paper][wisckey] (on which Badger is based) saw big wins with separating
values from keys, significantly reducing the write amplification compared to a typical LSM tree.
<sup>3</sup> SSI: Serializable Snapshot Isolation. For more details, see the blog post [Concurrent ACID Transactions in Badger](https://blog.dgraph.io/post/badger-txn/)
<sup>2</sup> RocksDB is an SSD optimized version of LevelDB, which was designed specifically for
rotating disks. As such RocksDB's design isn't aimed at SSDs.
<sup>4</sup> Badger provides direct access to value versions via its Iterator API.
Users can also specify how many versions to keep per key via Options.
<sup>3</sup> SSI: Serializable Snapshot Isolation. For more details, see the blog post
[Concurrent ACID Transactions in Badger](https://blog.dgraph.io/post/badger-txn/)
<sup>4</sup> Badger provides direct access to value versions via its Iterator API. Users can also
specify how many versions to keep per key via Options.
### Benchmarks
We have run comprehensive benchmarks against RocksDB, Bolt and LMDB. The
benchmarking code, and the detailed logs for the benchmarks can be found in the
[badger-bench] repo. More explanation, including graphs can be found the blog posts (linked
above).
We have run comprehensive benchmarks against RocksDB, Bolt and LMDB. The benchmarking code, and the
detailed logs for the benchmarks can be found in the [badger-bench] repo. More explanation,
including graphs can be found the blog posts (linked above).
[badger-bench]: https://github.com/dgraph-io/badger-bench
## Projects Using Badger
Below is a list of known projects that use Badger:
* [Dgraph](https://github.com/dgraph-io/dgraph) - Distributed graph database.
* [Dgraph](https://github.com/hypermodeinc/dgraph) - Distributed graph database.
* [Jaeger](https://github.com/jaegertracing/jaeger) - Distributed tracing platform.
* [go-ipfs](https://github.com/ipfs/go-ipfs) - Go client for the InterPlanetary File System (IPFS), a new hypermedia distribution protocol.
* [Riot](https://github.com/go-ego/riot) - An open-source, distributed search engine.
@@ -231,6 +235,8 @@ If you are using Badger in a project please send a pull request to add it to the
If you're interested in contributing to Badger see [CONTRIBUTING](./CONTRIBUTING.md).
## Contact
- Please use [Github issues](https://github.com/dgraph-io/badger/issues) for filing bugs.
- Please use [discuss.dgraph.io](https://discuss.dgraph.io) for questions, discussions, and feature requests.
- Please use [Github issues](https://github.com/hypermodeinc/badger/issues) for filing bugs.
- Please use [discuss.dgraph.io](https://discuss.dgraph.io) for questions, discussions, and feature
requests.
- Follow us on Twitter [@dgraphlabs](https://twitter.com/dgraphlabs).
+9 -9
View File
@@ -5,11 +5,11 @@ a way to decide how to name software versions. The whole concept is very well su
semver.org with the following lines:
> Given a version number MAJOR.MINOR.PATCH, increment the:
>
>
> 1. MAJOR version when you make incompatible API changes,
> 2. MINOR version when you add functionality in a backwards-compatible manner, and
> 3. PATCH version when you make backwards-compatible bug fixes.
>
>
> Additional labels for pre-release and build metadata are available as extensions to the
> MAJOR.MINOR.PATCH format.
@@ -25,9 +25,9 @@ MAJOR.MINOR.PATCH, but the semantics of the numbers are slightly modified:
Given a version number MAJOR.MINOR.PATCH, increment the:
- MAJOR version when you make changes that require a transformation of the dataset before it can be
used again.
used again.
- MINOR version when old datasets are still readable but the API might have changed in
backwards-compatible or incompatible ways.
backwards-compatible or incompatible ways.
- PATCH version when you make backwards-compatible bug fixes.
Additional labels for pre-release and build metadata are available as extensions to the
@@ -35,13 +35,13 @@ MAJOR.MINOR.PATCH format.
Following this naming strategy, migration from v1.x to v2.x requires a migration strategy for your
existing dataset, and as such has to be carefully planned. Migrations in between different minor
versions (e.g. v1.5.x and v1.6.x) might break your build, as the API *might* have changed, but once
versions (e.g. v1.5.x and v1.6.x) might break your build, as the API _might_ have changed, but once
your code compiles there's no need for any data migration. Lastly, changes in between two different
patch versions should never break your build or dataset.
For more background on our decision to adopt Serialization Versioning, read the blog post
[Semantic Versioning, Go Modules, and Databases][blog] and the original proposal on
[this comment on Dgraph's Discuss forum][discuss].
For more background on our decision to adopt Serialization Versioning, read the blog post [Semantic
Versioning, Go Modules, and Databases][blog] and the original proposal on [this comment on Dgraph's
Discuss forum][discuss].
[blog]: https://open.dgraph.io/post/serialization-versioning/
[discuss]: https://discuss.dgraph.io/t/go-modules-on-badger-and-dgraph/4662/7
[discuss]: https://discuss.dgraph.io/t/go-modules-on-badger-and-dgraph/4662/7
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2017 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package badger
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2017 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package badger
+2 -13
View File
@@ -1,17 +1,6 @@
#
# Copyright 2022 Dgraph Labs, Inc. and Contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
# SPDX-License-Identifier: Apache-2.0
#
GOOS ?= $(shell go env GOOS)
BIN
View File
Binary file not shown.
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2017 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package cmd
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2018 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package cmd
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2019 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package cmd
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2018 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package cmd
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2017 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package cmd
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2021 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package cmd
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2019 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package cmd
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2017 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package cmd
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2017 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package cmd
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2019 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package cmd
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2019 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package cmd
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2020 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package cmd
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2019 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package cmd
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2017 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package main
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2018 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package badger
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2018 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package badger
+6 -6
View File
@@ -1,18 +1,18 @@
#!/bin/bash
set -e
GHORG=${GHORG:-dgraph-io}
GHORG=${GHORG:-hypermodeinc}
GHREPO=${GHREPO:-badger}
cat <<EOF
This description was generated using this script:
\`\`\`sh
`cat $0`
$(cat "$0")
\`\`\`
Invoked as:
`echo GHORG=${GHORG} GHREPO=${GHREPO} $(basename $0) ${@:1}`
$(echo GHORG="${GHORG}" GHREPO="${GHREPO}" $(basename "$0") ${@:1})
EOF
git log --oneline --reverse ${@:1} \
| sed -E "s/^(\S{7}\s)//g" \
| sed -E "s/([\s|\(| ])#([0-9]+)/\1${GHORG}\/${GHREPO}#\2/g" \
git log --oneline --reverse ${@:1} |
sed -E "s/^(\S{7}\s)//g" |
sed -E "s/([\s|\(| ])#([0-9]+)/\1${GHORG}\/${GHREPO}#\2/g"
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2017 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package badger
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2017 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package badger
+3 -14
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2018 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package badger
@@ -652,7 +641,7 @@ func TestL0GCBug(t *testing.T) {
require.NoError(t, db2.Close())
}
// Regression test for https://github.com/dgraph-io/badger/issues/1126
// Regression test for https://github.com/hypermodeinc/badger/issues/1126
//
// The test has 3 steps
// Step 1 - Create badger data. It is necessary that the value size is
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2017 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package badger
+2 -13
View File
@@ -2,19 +2,8 @@
// +build js wasip1
/*
* Copyright 2017 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package badger
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2020 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package badger
+2 -13
View File
@@ -2,19 +2,8 @@
// +build !windows,!plan9,!js,!wasip1
/*
* Copyright 2017 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package badger
+3 -14
View File
@@ -2,19 +2,8 @@
// +build windows
/*
* Copyright 2017 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package badger
@@ -107,5 +96,5 @@ func (g *directoryLockGuard) release() error {
}
// Windows doesn't support syncing directories to the file system. See
// https://github.com/dgraph-io/badger/issues/699#issuecomment-504133587 for more details.
// https://github.com/hypermodeinc/badger/issues/699#issuecomment-504133587 for more details.
func syncDir(dir string) error { return nil }
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2020 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package badger
+2 -13
View File
@@ -1,17 +1,6 @@
/*
* Copyright 2020 Dgraph Labs, Inc. and Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-FileCopyrightText: © Hypermode Inc. <hello@hypermode.com>
* SPDX-License-Identifier: Apache-2.0
*/
package badger
+6 -3
View File
@@ -1,6 +1,7 @@
# Badger Docs
If you are looking for Badger's documentation, you might find https://dgraph.io/docs/badger much more readable.
If you are looking for Badger's documentation, you might find https://dgraph.io/docs/badger much
more readable.
## Getting Started
@@ -8,7 +9,8 @@ We use [Hugo](https://gohugo.io/) for our documentation.
### Running locally
1. Download and install the latest patch of Hugo version v0.69.x from [here](https://github.com/gohugoio/hugo/releases/).
1. Download and install the latest patch of Hugo version v0.69.x from
[here](https://github.com/gohugoio/hugo/releases/).
2. Run `hugo server` within the `docs` folder.
3. Visit http://localhost:1313 to see the documentation site.
@@ -18,5 +20,6 @@ If you're interested in contributing to Badger, please review our [guidelines](.
## Contact
- Please use [discuss.dgraph.io](https://discuss.dgraph.io) for questions, feature requests, and discussions.
- Please use [discuss.dgraph.io](https://discuss.dgraph.io) for questions, feature requests, and
discussions.
- Follow us on Twitter [@dgraphlabs](https://twitter.com/dgraphlabs).
-1
View File
@@ -3,4 +3,3 @@ title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
---
+24 -24
View File
@@ -8,36 +8,36 @@ unsafe = true
[markup.highlight]
noClasses = false
[[menu.main]]
name = "Home"
url = "/"
identifier = "home"
weight = -1
name = "Home"
url = "/"
identifier = "home"
weight = -1
[[menu.main]]
name = "Getting Started"
url = "/get-started/"
identifier = "get-started"
weight = 1
name = "Getting Started"
url = "/get-started/"
identifier = "get-started"
weight = 1
[[menu.main]]
name = "Resources"
url = "/resources/"
identifier = "resources"
weight = 2
name = "Resources"
url = "/resources/"
identifier = "resources"
weight = 2
[[menu.main]]
name = "Design"
url = "/design/"
identifier = "design"
weight = 3
name = "Design"
url = "/design/"
identifier = "design"
weight = 3
[[menu.main]]
name = "Projects using Badger"
url = "/projects-using-badger/"
identifier = "project-using-badger"
weight = 4
name = "Projects using Badger"
url = "/projects-using-badger/"
identifier = "project-using-badger"
weight = 4
[[menu.main]]
name = "Frequently Asked Questions"
url = "/faq/"
identifier = "faq"
weight = 5
name = "Frequently Asked Questions"
url = "/faq/"
identifier = "faq"
weight = 5
+3 -2
View File
@@ -82,7 +82,7 @@ non-Go-based key-value stores like RocksDB.
The [Changelog] is kept fairly up-to-date with each release.
[Changelog]:https://github.com/dgraph-io/badger/blob/main/CHANGELOG.md
[Changelog]: https://github.com/dgraph-io/badger/blob/main/CHANGELOG.md
## Contribute
@@ -107,7 +107,8 @@ The [Changelog] is kept fairly up-to-date with each release.
## Our Community
**Badger is made better every day by the growing community and the contributors all over the world.**
**Badger is made better every day by the growing community and the contributors all over the
world.**
<section class="toc">
<div class="container">
+4 -2
View File
@@ -3,6 +3,8 @@ title = "Contact"
aliases = ["/contact"]
+++
- Please use [discuss.dgraph.io](https://discuss.dgraph.io) for questions, feature requests and discussions.
- Please use [Github issue tracker](https://github.com/dgraph-io/badger/issues) for filing bugs or feature requests.
- Please use [discuss.dgraph.io](https://discuss.dgraph.io) for questions, feature requests and
discussions.
- Please use [Github issue tracker](https://github.com/dgraph-io/badger/issues) for filing bugs or
feature requests.
- Follow us on Twitter [@dgraphlabs](https://twitter.com/dgraphlabs).
+28 -27
View File
@@ -9,42 +9,43 @@ Badger was written with these design goals in mind:
- Use latest research to build the fastest KV database for data sets spanning terabytes.
- Optimize for SSDs.
Badgers design is based on a paper titled _[WiscKey: Separating Keys from
Values in SSD-conscious Storage][wisckey]_.
Badgers design is based on a paper titled _[WiscKey: Separating Keys from Values in SSD-conscious
Storage][wisckey]_.
[wisckey]: https://www.usenix.org/system/files/conference/fast16/fast16-papers-lu.pdf
## Comparisons
| Feature | Badger | RocksDB | BoltDB |
| ------- | ------ | ------- | ------ |
| Design | LSM tree with value log | LSM tree only | B+ tree |
| High Read throughput | Yes | No | Yes |
| High Write throughput | Yes | Yes | No |
| Designed for SSDs | Yes (with latest research <sup>1</sup>) | Not specifically <sup>2</sup> | No |
| Embeddable | Yes | Yes | Yes |
| Sorted KV access | Yes | Yes | Yes |
| Pure Go (no Cgo) | Yes | No | Yes |
| Transactions | Yes, ACID, concurrent with SSI<sup>3</sup> | Yes (but non-ACID) | Yes, ACID |
| Snapshots | Yes | Yes | Yes |
| TTL support | Yes | Yes | No |
| 3D access (key-value-version) | Yes<sup>4</sup> | No | No |
<sup>1</sup> The [WISCKEY paper][wisckey] (on which Badger is based) saw big
wins with separating values from keys, significantly reducing the write
amplification compared to a typical LSM tree.
| Feature | Badger | RocksDB | BoltDB |
| ----------------------------- | ------------------------------------------ | ----------------------------- | --------- |
| Design | LSM tree with value log | LSM tree only | B+ tree |
| High Read throughput | Yes | No | Yes |
| High Write throughput | Yes | Yes | No |
| Designed for SSDs | Yes (with latest research <sup>1</sup>) | Not specifically <sup>2</sup> | No |
| Embeddable | Yes | Yes | Yes |
| Sorted KV access | Yes | Yes | Yes |
| Pure Go (no Cgo) | Yes | No | Yes |
| Transactions | Yes, ACID, concurrent with SSI<sup>3</sup> | Yes (but non-ACID) | Yes, ACID |
| Snapshots | Yes | Yes | Yes |
| TTL support | Yes | Yes | No |
| 3D access (key-value-version) | Yes<sup>4</sup> | No | No |
<sup>2</sup> RocksDB is an SSD optimized version of LevelDB, which was designed specifically for rotating disks.
As such RocksDB's design isn't aimed at SSDs.
<sup>1</sup> The [WISCKEY paper][wisckey] (on which Badger is based) saw big wins with separating
values from keys, significantly reducing the write amplification compared to a typical LSM tree.
<sup>3</sup> SSI: Serializable Snapshot Isolation. For more details, see the blog post [Concurrent ACID Transactions in Badger](https://blog.dgraph.io/post/badger-txn/)
<sup>2</sup> RocksDB is an SSD optimized version of LevelDB, which was designed specifically for
rotating disks. As such RocksDB's design isn't aimed at SSDs.
<sup>4</sup> Badger provides direct access to value versions via its Iterator API.
Users can also specify how many versions to keep per key via Options.
<sup>3</sup> SSI: Serializable Snapshot Isolation. For more details, see the blog post
[Concurrent ACID Transactions in Badger](https://blog.dgraph.io/post/badger-txn/)
<sup>4</sup> Badger provides direct access to value versions via its Iterator API. Users can also
specify how many versions to keep per key via Options.
## Benchmarks
We have run comprehensive benchmarks against RocksDB, Bolt and LMDB. The
benchmarking code, and the detailed logs for the benchmarks can be found in the
[badger-bench] repo. More explanation, including graphs can be found the blog posts (linked
above).
We have run comprehensive benchmarks against RocksDB, Bolt and LMDB. The benchmarking code, and the
detailed logs for the benchmarks can be found in the [badger-bench] repo. More explanation,
including graphs can be found the blog posts (linked above).
[badger-bench]: https://github.com/dgraph-io/badger-bench
+66 -59
View File
@@ -5,39 +5,35 @@ aliases = ["/faq"]
## My writes are getting stuck. Why?
**Update: With the new `Value(func(v []byte))` API, this deadlock can no longer
happen.**
**Update: With the new `Value(func(v []byte))` API, this deadlock can no longer happen.**
The following is true for users on Badger v1.x.
This can happen if a long running iteration with `Prefetch` is set to false, but
a `Item::Value` call is made internally in the loop. That causes Badger to
acquire read locks over the value log files to avoid value log GC removing the
file from underneath. As a side effect, this also blocks a new value log GC
file from being created, when the value log file boundary is hit.
This can happen if a long running iteration with `Prefetch` is set to false, but a `Item::Value`
call is made internally in the loop. That causes Badger to acquire read locks over the value log
files to avoid value log GC removing the file from underneath. As a side effect, this also blocks a
new value log GC file from being created, when the value log file boundary is hit.
Please see Github issues [#293](https://github.com/dgraph-io/badger/issues/293)
and [#315](https://github.com/dgraph-io/badger/issues/315).
Please see Github issues [#293](https://github.com/dgraph-io/badger/issues/293) and
[#315](https://github.com/dgraph-io/badger/issues/315).
There are multiple workarounds during iteration:
1. Use `Item::ValueCopy` instead of `Item::Value` when retrieving value.
1. Set `Prefetch` to true. Badger would then copy over the value and release the
file lock immediately.
1. When `Prefetch` is false, don't call `Item::Value` and do a pure key-only
iteration. This might be useful if you just want to delete a lot of keys.
1. Set `Prefetch` to true. Badger would then copy over the value and release the file lock
immediately.
1. When `Prefetch` is false, don't call `Item::Value` and do a pure key-only iteration. This might
be useful if you just want to delete a lot of keys.
1. Do the writes in a separate transaction after the reads.
## My writes are really slow. Why?
Are you creating a new transaction for every single key update, and waiting for
it to `Commit` fully before creating a new one? This will lead to very low
throughput.
Are you creating a new transaction for every single key update, and waiting for it to `Commit` fully
before creating a new one? This will lead to very low throughput.
We have created `WriteBatch` API which provides a way to batch up
many updates into a single transaction and `Commit` that transaction using
callbacks to avoid blocking. This amortizes the cost of a transaction really
well, and provides the most efficient way to do bulk writes.
We have created `WriteBatch` API which provides a way to batch up many updates into a single
transaction and `Commit` that transaction using callbacks to avoid blocking. This amortizes the cost
of a transaction really well, and provides the most efficient way to do bulk writes.
```go
wb := db.NewWriteBatch()
@@ -50,26 +46,31 @@ for i := 0; i < N; i++ {
handle(wb.Flush()) // Wait for all txns to finish.
```
Note that `WriteBatch` API does not allow any reads. For read-modify-write
workloads, you should be using the `Transaction` API.
Note that `WriteBatch` API does not allow any reads. For read-modify-write workloads, you should be
using the `Transaction` API.
## I don't see any disk writes. Why?
If you're using Badger with `SyncWrites=false`, then your writes might not be written to value log
and won't get synced to disk immediately. Writes to LSM tree are done inmemory first, before they
get compacted to disk. The compaction would only happen once `BaseTableSize` has been reached. So, if
you're doing a few writes and then checking, you might not see anything on disk. Once you `Close`
get compacted to disk. The compaction would only happen once `BaseTableSize` has been reached. So,
if you're doing a few writes and then checking, you might not see anything on disk. Once you `Close`
the database, you'll see these writes on disk.
## Reverse iteration doesn't give me the right results.
Just like forward iteration goes to the first key which is equal or greater than the SEEK key, reverse iteration goes to the first key which is equal or lesser than the SEEK key. Therefore, SEEK key would not be part of the results. You can typically add a `0xff` byte as a suffix to the SEEK key to include it in the results. See the following issues: [#436](https://github.com/dgraph-io/badger/issues/436) and [#347](https://github.com/dgraph-io/badger/issues/347).
Just like forward iteration goes to the first key which is equal or greater than the SEEK key,
reverse iteration goes to the first key which is equal or lesser than the SEEK key. Therefore, SEEK
key would not be part of the results. You can typically add a `0xff` byte as a suffix to the SEEK
key to include it in the results. See the following issues:
[#436](https://github.com/dgraph-io/badger/issues/436) and
[#347](https://github.com/dgraph-io/badger/issues/347).
## Which instances should I use for Badger?
We recommend using instances which provide local SSD storage, without any limit
on the maximum IOPS. In AWS, these are storage optimized instances like i3. They
provide local SSDs which clock 100K IOPS over 4KB blocks easily.
We recommend using instances which provide local SSD storage, without any limit on the maximum IOPS.
In AWS, these are storage optimized instances like i3. They provide local SSDs which clock 100K IOPS
over 4KB blocks easily.
## I'm getting a closed channel error. Why?
@@ -78,65 +79,71 @@ panic: close of closed channel
panic: send on closed channel
```
If you're seeing panics like above, this would be because you're operating on a closed DB. This can happen, if you call `Close()` before sending a write, or multiple times. You should ensure that you only call `Close()` once, and all your read/write operations finish before closing.
If you're seeing panics like above, this would be because you're operating on a closed DB. This can
happen, if you call `Close()` before sending a write, or multiple times. You should ensure that you
only call `Close()` once, and all your read/write operations finish before closing.
## Are there any Go specific settings that I should use?
We *highly* recommend setting a high number for `GOMAXPROCS`, which allows Go to
observe the full IOPS throughput provided by modern SSDs. In Dgraph, we have set
it to 128. For more details, [see this
thread](https://groups.google.com/d/topic/golang-nuts/jPb_h3TvlKE/discussion).
We _highly_ recommend setting a high number for `GOMAXPROCS`, which allows Go to observe the full
IOPS throughput provided by modern SSDs. In Dgraph, we have set it to 128. For more details,
[see this thread](https://groups.google.com/d/topic/golang-nuts/jPb_h3TvlKE/discussion).
## Are there any Linux specific settings that I should use?
We recommend setting `max file descriptors` to a high number depending upon the expected size of
your data. On Linux and Mac, you can check the file descriptor limit with `ulimit -n -H` for the
hard limit and `ulimit -n -S` for the soft limit. A soft limit of `65535` is a good lower bound.
You can adjust the limit as needed.
hard limit and `ulimit -n -S` for the soft limit. A soft limit of `65535` is a good lower bound. You
can adjust the limit as needed.
## I see "manifest has unsupported version: X (we support Y)" error.
This error means you have a badger directory which was created by an older version of badger and
you're trying to open in a newer version of badger. The underlying data format can change across
badger versions and users will have to migrate their data directory.
Badger data can be migrated from version X of badger to version Y of badger by following the steps
listed below.
Assume you were on badger v1.6.0 and you wish to migrate to v2.0.0 version.
badger versions and users will have to migrate their data directory. Badger data can be migrated
from version X of badger to version Y of badger by following the steps listed below. Assume you were
on badger v1.6.0 and you wish to migrate to v2.0.0 version.
1. Install badger version v1.6.0
- `cd $GOPATH/src/github.com/dgraph-io/badger`
- `git checkout v1.6.0`
- `cd badger && go install`
This should install the old badger binary in your $GOBIN.
- `cd $GOPATH/src/github.com/dgraph-io/badger`
- `git checkout v1.6.0`
- `cd badger && go install`
This should install the old badger binary in your $GOBIN.
2. Create Backup
- `badger backup --dir path/to/badger/directory -f badger.backup`
- `badger backup --dir path/to/badger/directory -f badger.backup`
3. Install badger version v2.0.0
- `cd $GOPATH/src/github.com/dgraph-io/badger`
- `git checkout v2.0.0`
- `cd badger && go install`
This should install new badger binary in your $GOBIN
- `cd $GOPATH/src/github.com/dgraph-io/badger`
- `git checkout v2.0.0`
- `cd badger && go install`
This should install new badger binary in your $GOBIN
4. Restore data from backup
- `badger restore --dir path/to/new/badger/directory -f badger.backup`
This will create a new directory on `path/to/new/badger/directory` and add badger data in
newer format to it.
- `badger restore --dir path/to/new/badger/directory -f badger.backup`
This will create a new directory on `path/to/new/badger/directory` and add badger data in newer
format to it.
NOTE - The above steps shouldn't cause any data loss but please ensure the new data is valid before
deleting the old badger directory.
## Why do I need gcc to build badger? Does badger need CGO?
Badger does not directly use CGO but it relies on https://github.com/DataDog/zstd library for
zstd compression and the library requires `gcc/cgo`. You can build badger without cgo by running
Badger does not directly use CGO but it relies on https://github.com/DataDog/zstd library for zstd
compression and the library requires `gcc/cgo`. You can build badger without cgo by running
`CGO_ENABLED=0 go build`. This will build badger without the support for ZSTD compression algorithm.
As of Badger versions [v2.2007.4](https://github.com/dgraph-io/badger/releases/tag/v2.2007.4) and
[v3.2103.1](https://github.com/dgraph-io/badger/releases/tag/v3.2103.1) the DataDog ZSTD library
was replaced by pure Golang version and CGO is no longer required. The new library is
[v3.2103.1](https://github.com/dgraph-io/badger/releases/tag/v3.2103.1) the DataDog ZSTD library was
replaced by pure Golang version and CGO is no longer required. The new library is
[backwards compatible in nearly all cases](https://discuss.dgraph.io/t/use-pure-go-zstd-implementation/8670/10):
> Yes they are compatible both ways. The only exception is 0 bytes of input which will give
> 0 bytes output with the Go zstd. But you already have the zstd.WithZeroFrames(true) which
> will wrap 0 bytes in a header so it can be fed to DD zstd. This will of course only be relevant
> when downgrading.
> Yes they are compatible both ways. The only exception is 0 bytes of input which will give
> 0 bytes output with the Go zstd. But you already have the zstd.WithZeroFrames(true) which
> will wrap 0 bytes in a header so it can be fed to DD zstd. This will of course only be relevant
> when downgrading.
+196 -203
View File
@@ -3,13 +3,14 @@ title = "Get Started - Quickstart Guide"
aliases = ["/get-started"]
+++
## Installing
To start using Badger, install Go 1.23 or above. Run the following command to retrieve the library.
```sh
$ go get github.com/dgraph-io/badger/v4
```
This will retrieve the library.
### Installing Badger Command Line Tool
@@ -17,15 +18,17 @@ This will retrieve the library.
```sh
$ go install github.com/dgraph-io/badger/v4/badger@latest
```
This will install the badger command line utility into your $GOBIN path.
## Opening a database
The top-level object in Badger is a `DB`. It represents multiple files on disk
in specific directories, which contain the data for a single database.
To open your database, use the `badger.Open()` function, with the appropriate
options. The `Dir` and `ValueDir` options are mandatory and must be
specified by the client. They can be set to the same value to simplify things.
The top-level object in Badger is a `DB`. It represents multiple files on disk in specific
directories, which contain the data for a single database.
To open your database, use the `badger.Open()` function, with the appropriate options. The `Dir` and
`ValueDir` options are mandatory and must be specified by the client. They can be set to the same
value to simplify things.
```go
package main
@@ -48,14 +51,15 @@ func main() {
}
```
Please note that Badger obtains a lock on the directories so multiple processes
cannot open the same database at the same time.
Please note that Badger obtains a lock on the directories so multiple processes cannot open the same
database at the same time.
### In-Memory Mode/Diskless Mode
By default, Badger ensures all the data is persisted to the disk. It also supports a pure
in-memory mode. When Badger is running in in-memory mode, all the data is stored in the memory.
Reads and writes are much faster in in-memory mode, but all the data stored in Badger will be lost
in case of a crash or close. To open badger in in-memory mode, set the `InMemory` option.
By default, Badger ensures all the data is persisted to the disk. It also supports a pure in-memory
mode. When Badger is running in in-memory mode, all the data is stored in the memory. Reads and
writes are much faster in in-memory mode, but all the data stored in Badger will be lost in case of
a crash or close. To open badger in in-memory mode, set the `InMemory` option.
```go
opt := badger.DefaultOptions("").WithInMemory(true)
@@ -65,9 +69,8 @@ opt := badger.DefaultOptions("").WithInMemory(true)
If you enable encryption on Badger, you also need to set the index cache size.
{{% notice "tip" %}}
Having a cache improves the performance. Otherwise, your reads would be very slow while encryption is enabled.
{{% /notice %}}
{{% notice "tip" %}} Having a cache improves the performance. Otherwise, your reads would be very
slow while encryption is enabled. {{% /notice %}}
For example, to set a `100 Mb` cache:
@@ -78,6 +81,7 @@ opts.IndexCache = 100 << 20 // 100 mb or some other size based on the amount of
## Transactions
### Read-only transactions
To start a read-only transaction, you can use the `DB.View()` method:
```go
@@ -87,12 +91,12 @@ err := db.View(func(txn *badger.Txn) error {
})
```
You cannot perform any writes or deletes within this transaction. Badger
ensures that you get a consistent view of the database within this closure. Any
writes that happen elsewhere after the transaction has started, will not be
seen by calls made within the closure.
You cannot perform any writes or deletes within this transaction. Badger ensures that you get a
consistent view of the database within this closure. Any writes that happen elsewhere after the
transaction has started, will not be seen by calls made within the closure.
### Read-write transactions
To start a read-write transaction, you can use the `DB.Update()` method:
```go
@@ -104,17 +108,16 @@ err := db.Update(func(txn *badger.Txn) error {
All database operations are allowed inside a read-write transaction.
Always check the returned error value. If you return an error
within your closure it will be passed through.
Always check the returned error value. If you return an error within your closure it will be passed
through.
An `ErrConflict` error will be reported in case of a conflict. Depending on the state
of your application, you have the option to retry the operation if you receive
this error.
An `ErrConflict` error will be reported in case of a conflict. Depending on the state of your
application, you have the option to retry the operation if you receive this error.
An `ErrTxnTooBig` will be reported in case the number of pending writes/deletes in
the transaction exceeds a certain limit. In that case, it is best to commit the
transaction and start a new transaction immediately. Here is an example (we are
not checking for errors in some places for simplicity):
An `ErrTxnTooBig` will be reported in case the number of pending writes/deletes in the transaction
exceeds a certain limit. In that case, it is best to commit the transaction and start a new
transaction immediately. Here is an example (we are not checking for errors in some places for
simplicity):
```go
updates := make(map[string]string)
@@ -130,23 +133,20 @@ _ = txn.Commit()
```
### Managing transactions manually
The `DB.View()` and `DB.Update()` methods are wrappers around the
`DB.NewTransaction()` and `Txn.Commit()` methods (or `Txn.Discard()` in case of
read-only transactions). These helper methods will start the transaction,
execute a function, and then safely discard your transaction if an error is
returned. This is the recommended way to use Badger transactions.
However, sometimes you may want to manually create and commit your
transactions. You can use the `DB.NewTransaction()` function directly, which
takes in a boolean argument to specify whether a read-write transaction is
required. For read-write transactions, it is necessary to call `Txn.Commit()`
to ensure the transaction is committed. For read-only transactions, calling
`Txn.Discard()` is sufficient. `Txn.Commit()` also calls `Txn.Discard()`
internally to cleanup the transaction, so just calling `Txn.Commit()` is
sufficient for read-write transaction. However, if your code doesnt call
`Txn.Commit()` for some reason (for e.g it returns prematurely with an error),
then please make sure you call `Txn.Discard()` in a `defer` block. Refer to the
code below.
The `DB.View()` and `DB.Update()` methods are wrappers around the `DB.NewTransaction()` and
`Txn.Commit()` methods (or `Txn.Discard()` in case of read-only transactions). These helper methods
will start the transaction, execute a function, and then safely discard your transaction if an error
is returned. This is the recommended way to use Badger transactions.
However, sometimes you may want to manually create and commit your transactions. You can use the
`DB.NewTransaction()` function directly, which takes in a boolean argument to specify whether a
read-write transaction is required. For read-write transactions, it is necessary to call
`Txn.Commit()` to ensure the transaction is committed. For read-only transactions, calling
`Txn.Discard()` is sufficient. `Txn.Commit()` also calls `Txn.Discard()` internally to cleanup the
transaction, so just calling `Txn.Commit()` is sufficient for read-write transaction. However, if
your code doesnt call `Txn.Commit()` for some reason (for e.g it returns prematurely with an
error), then please make sure you call `Txn.Discard()` in a `defer` block. Refer to the code below.
```go
// Start a writable transaction.
@@ -165,19 +165,19 @@ if err := txn.Commit(); err != nil {
}
```
The first argument to `DB.NewTransaction()` is a boolean stating if the transaction
should be writable.
The first argument to `DB.NewTransaction()` is a boolean stating if the transaction should be
writable.
Badger allows an optional callback to the `Txn.Commit()` method. Normally, the
callback can be set to `nil`, and the method will return after all the writes
have succeeded. However, if this callback is provided, the `Txn.Commit()`
method returns as soon as it has checked for any conflicts. The actual writing
to the disk happens asynchronously, and the callback is invoked once the
writing has finished, or an error has occurred. This can improve the throughput
of the application in some cases. But it also means that a transaction is not
durable until the callback has been invoked with a `nil` error value.
Badger allows an optional callback to the `Txn.Commit()` method. Normally, the callback can be set
to `nil`, and the method will return after all the writes have succeeded. However, if this callback
is provided, the `Txn.Commit()` method returns as soon as it has checked for any conflicts. The
actual writing to the disk happens asynchronously, and the callback is invoked once the writing has
finished, or an error has occurred. This can improve the throughput of the application in some
cases. But it also means that a transaction is not durable until the callback has been invoked with
a `nil` error value.
## Using key/value pairs
To save a key/value pair, use the `Txn.Set()` method:
```go
@@ -187,9 +187,8 @@ err := db.Update(func(txn *badger.Txn) error {
})
```
Key/Value pair can also be saved by first creating `Entry`, then setting this
`Entry` using `Txn.SetEntry()`. `Entry` also exposes methods to set properties
on it.
Key/Value pair can also be saved by first creating `Entry`, then setting this `Entry` using
`Txn.SetEntry()`. `Entry` also exposes methods to set properties on it.
```go
err := db.Update(func(txn *badger.Txn) error {
@@ -199,8 +198,8 @@ err := db.Update(func(txn *badger.Txn) error {
})
```
This will set the value of the `"answer"` key to `"42"`. To retrieve this
value, we can use the `Txn.Get()` method:
This will set the value of the `"answer"` key to `"42"`. To retrieve this value, we can use the
`Txn.Get()` method:
```go
err := db.View(func(txn *badger.Txn) error {
@@ -240,24 +239,23 @@ err := db.View(func(txn *badger.Txn) error {
`Txn.Get()` returns `ErrKeyNotFound` if the value is not found.
Please note that values returned from `Get()` are only valid while the
transaction is open. If you need to use a value outside of the transaction
then you must use `copy()` to copy it to another byte slice.
Please note that values returned from `Get()` are only valid while the transaction is open. If you
need to use a value outside of the transaction then you must use `copy()` to copy it to another byte
slice.
Use the `Txn.Delete()` method to delete a key.
## Monotonically increasing integers
To get unique monotonically increasing integers with strong durability, you can
use the `DB.GetSequence` method. This method returns a `Sequence` object, which
is thread-safe and can be used concurrently via various goroutines.
To get unique monotonically increasing integers with strong durability, you can use the
`DB.GetSequence` method. This method returns a `Sequence` object, which is thread-safe and can be
used concurrently via various goroutines.
Badger would lease a range of integers to hand out from memory, with the
bandwidth provided to `DB.GetSequence`. The frequency at which disk writes are
done is determined by this lease bandwidth and the frequency of `Next`
invocations. Setting a bandwidth too low would do more disk writes, setting it
too high would result in wasted integers if Badger is closed or crashes.
To avoid wasted integers, call `Release` before closing Badger.
Badger would lease a range of integers to hand out from memory, with the bandwidth provided to
`DB.GetSequence`. The frequency at which disk writes are done is determined by this lease bandwidth
and the frequency of `Next` invocations. Setting a bandwidth too low would do more disk writes,
setting it too high would result in wasted integers if Badger is closed or crashes. To avoid wasted
integers, call `Release` before closing Badger.
```go
seq, err := db.GetSequence(key, 1000)
@@ -268,11 +266,11 @@ for {
```
## Merge Operations
Badger provides support for ordered merge operations. You can define a func
of type `MergeFunc` which takes in an existing value, and a value to be
_merged_ with it. It returns a new value which is the result of the _merge_
operation. All values are specified in byte arrays. For e.g., here is a merge
function (`add`) which appends a `[]byte` value to an existing `[]byte` value.
Badger provides support for ordered merge operations. You can define a func of type `MergeFunc`
which takes in an existing value, and a value to be _merged_ with it. It returns a new value which
is the result of the _merge_ operation. All values are specified in byte arrays. For e.g., here is a
merge function (`add`) which appends a `[]byte` value to an existing `[]byte` value.
```go
// Merge function to append one byte slice to another
@@ -281,13 +279,12 @@ func add(originalValue, newValue []byte) []byte {
}
```
This function can then be passed to the `DB.GetMergeOperator()` method, along
with a key, and a duration value. The duration specifies how often the merge
function is run on values that have been added using the `MergeOperator.Add()`
method.
This function can then be passed to the `DB.GetMergeOperator()` method, along with a key, and a
duration value. The duration specifies how often the merge function is run on values that have been
added using the `MergeOperator.Add()` method.
`MergeOperator.Get()` method can be used to retrieve the cumulative value of the key
associated with the merge operation.
`MergeOperator.Get()` method can be used to retrieve the cumulative value of the key associated with
the merge operation.
```go
key := []byte("merge")
@@ -320,7 +317,9 @@ func add(existing, new []byte) []byte {
return uint64ToBytes(bytesToUint64(existing) + bytesToUint64(new))
}
```
It can be used as
```
key := []byte("merge")
@@ -335,10 +334,10 @@ res, _ := m.Get() // res should have value 6 encoded
```
## Setting Time To Live(TTL) and User Metadata on Keys
Badger allows setting an optional Time to Live (TTL) value on keys. Once the TTL has
elapsed, the key will no longer be retrievable and will be eligible for garbage
collection. A TTL can be set as a `time.Duration` value using the `Entry.WithTTL()`
and `Txn.SetEntry()` API methods.
Badger allows setting an optional Time to Live (TTL) value on keys. Once the TTL has elapsed, the
key will no longer be retrievable and will be eligible for garbage collection. A TTL can be set as a
`time.Duration` value using the `Entry.WithTTL()` and `Txn.SetEntry()` API methods.
```go
err := db.Update(func(txn *badger.Txn) error {
@@ -348,10 +347,10 @@ err := db.Update(func(txn *badger.Txn) error {
})
```
An optional user metadata value can be set on each key. A user metadata value
is represented by a single byte. It can be used to set certain bits along
with the key to aid in interpreting or decoding the key-value pair. User
metadata can be set using `Entry.WithMeta()` and `Txn.SetEntry()` API methods.
An optional user metadata value can be set on each key. A user metadata value is represented by a
single byte. It can be used to set certain bits along with the key to aid in interpreting or
decoding the key-value pair. User metadata can be set using `Entry.WithMeta()` and `Txn.SetEntry()`
API methods.
```go
err := db.Update(func(txn *badger.Txn) error {
@@ -361,8 +360,8 @@ err := db.Update(func(txn *badger.Txn) error {
})
```
`Entry` APIs can be used to add the user metadata and TTL for same key. This `Entry`
then can be set using `Txn.SetEntry()`.
`Entry` APIs can be used to add the user metadata and TTL for same key. This `Entry` then can be set
using `Txn.SetEntry()`.
```go
err := db.Update(func(txn *badger.Txn) error {
@@ -373,10 +372,9 @@ err := db.Update(func(txn *badger.Txn) error {
```
## Iterating over keys
To iterate over keys, we can use an `Iterator`, which can be obtained using the
`Txn.NewIterator()` method. Iteration happens in byte-wise lexicographical sorting
order.
To iterate over keys, we can use an `Iterator`, which can be obtained using the `Txn.NewIterator()`
method. Iteration happens in byte-wise lexicographical sorting order.
```go
err := db.View(func(txn *badger.Txn) error {
@@ -399,16 +397,16 @@ err := db.View(func(txn *badger.Txn) error {
})
```
The iterator allows you to move to a specific point in the list of keys and move
forward or backward through the keys one at a time.
The iterator allows you to move to a specific point in the list of keys and move forward or backward
through the keys one at a time.
By default, Badger prefetches the values of the next 100 items. You can adjust
that with the `IteratorOptions.PrefetchSize` field. However, setting it to
a value higher than `GOMAXPROCS` (which we recommend to be 128 or higher)
shouldnt give any additional benefits. You can also turn off the fetching of
values altogether. See section below on key-only iteration.
By default, Badger prefetches the values of the next 100 items. You can adjust that with the
`IteratorOptions.PrefetchSize` field. However, setting it to a value higher than `GOMAXPROCS` (which
we recommend to be 128 or higher) shouldnt give any additional benefits. You can also turn off the
fetching of values altogether. See section below on key-only iteration.
### Prefix scans
To iterate over a key prefix, you can combine `Seek()` and `ValidForPrefix()`:
```go
@@ -433,36 +431,34 @@ db.View(func(txn *badger.Txn) error {
### Possible pagination implementation using Prefix scans
Considering that iteration happens in **byte-wise lexicographical sorting** order,
it's possible to create a sorting-sensitive key. For example, a simple blog post
key might look like:`feed:userUuid:timestamp:postUuid`. Here, the `timestamp` part
of the key is treated as an attribute, and items will be stored in the corresponding order:
Considering that iteration happens in **byte-wise lexicographical sorting** order, it's possible to
create a sorting-sensitive key. For example, a simple blog post key might look
like:`feed:userUuid:timestamp:postUuid`. Here, the `timestamp` part of the key is treated as an
attribute, and items will be stored in the corresponding order:
| Order ASC | Key |
|:-----------:|:-------------------------------------------------------------|
| 1 | feed:tQpnEDVRoCxTFQDvyQEzdo:1733127889:tQpnEDVRoCxTFQDvyQEzdo |
| 2 | feed:tQpnEDVRoCxTFQDvyQEzdo:1733127533:1Mryrou1xoekEaxzrFiHwL |
| 3 | feed:tQpnEDVRoCxTFQDvyQEzdo:1733127486:pprRrNL2WP4yfVXsSNBSx6 |
| Order ASC | Key |
| :-------: | :------------------------------------------------------------ |
| 1 | feed:tQpnEDVRoCxTFQDvyQEzdo:1733127889:tQpnEDVRoCxTFQDvyQEzdo |
| 2 | feed:tQpnEDVRoCxTFQDvyQEzdo:1733127533:1Mryrou1xoekEaxzrFiHwL |
| 3 | feed:tQpnEDVRoCxTFQDvyQEzdo:1733127486:pprRrNL2WP4yfVXsSNBSx6 |
It is important to properly configure keys for lexicographical sorting to avoid
incorrect ordering.
It is important to properly configure keys for lexicographical sorting to avoid incorrect ordering.
A **prefix scan** through the keys above can be achieved using the prefix
A **prefix scan** through the keys above can be achieved using the prefix
`feed:tQpnEDVRoCxTFQDvyQEzdo`. All matching keys will be returned, sorted by `timestamp`.
For the example above, sorting can be done in ascending or descending order based on
`timestamp` or `reversed timestamp` as needed:
For the example above, sorting can be done in ascending or descending order based on `timestamp` or
`reversed timestamp` as needed:
```go
reversedTimestamp := math.MaxInt64-time.Now().Unix()
```
This makes it possible to implement simple pagination by using a limit for
the number of keys and a cursor (the last key from the previous iteration) to
identify where to resume.
This makes it possible to implement simple pagination by using a limit for the number of keys and a
cursor (the last key from the previous iteration) to identify where to resume.
```go
// startCursor may look like 'feed:tQpnEDVRoCxTFQDvyQEzdo:1733127486'.
// A prefix scan with this cursor will locate the specific key where
// startCursor may look like 'feed:tQpnEDVRoCxTFQDvyQEzdo:1733127486'.
// A prefix scan with this cursor will locate the specific key where
// the previous iteration stopped.
err = db.badger.View(func(txn *badger.Txn) error {
it := txn.NewIterator(opts)
@@ -471,22 +467,22 @@ err = db.badger.View(func(txn *badger.Txn) error {
// Prefix example 'feed:tQpnEDVRoCxTFQDvyQEzdo'
// if no cursor provided prefix scan starts from the beginning
p := prefix
if startCursor != nil {
if startCursor != nil {
p = startCursor
}
iterNum := 0 // Tracks the number of iterations to enforce the limit.
for it.Seek(p); it.ValidForPrefix(p); it.Next() {
// The method it.ValidForPrefix ensures that iteration continues
// as long as keys match the prefix.
// For example, if p = 'feed:tQpnEDVRoCxTFQDvyQEzdo:1733127486',
// it matches keys like
// The method it.ValidForPrefix ensures that iteration continues
// as long as keys match the prefix.
// For example, if p = 'feed:tQpnEDVRoCxTFQDvyQEzdo:1733127486',
// it matches keys like
// 'feed:tQpnEDVRoCxTFQDvyQEzdo:1733127889:pprRrNL2WP4yfVXsSNBSx6'.
// Once the starting point for iteration is found, revert the prefix
// Once the starting point for iteration is found, revert the prefix
// back to 'feed:tQpnEDVRoCxTFQDvyQEzdo' to continue iterating sequentially.
// Otherwise, iteration would stop after a single prefix-key match.
p = prefix
p = prefix
item := it.Item()
key := string(item.Key())
@@ -504,7 +500,7 @@ err = db.badger.View(func(txn *badger.Txn) error {
return err
}
}
// If the number of iterations is less than the limit,
// If the number of iterations is less than the limit,
// it means there are no more items for the prefix.
if iterNum < limit {
nextCursor = ""
@@ -515,12 +511,12 @@ return nextCursor, err
```
### Key-only iteration
Badger supports a unique mode of iteration called _key-only_ iteration. It is
several order of magnitudes faster than regular iteration, because it involves
access to the LSM-tree only, which is usually resident entirely in RAM. To
enable key-only iteration, you need to set the `IteratorOptions.PrefetchValues`
field to `false`. This can also be used to do sparse reads for selected keys
during an iteration, by calling `item.Value()` only when required.
Badger supports a unique mode of iteration called _key-only_ iteration. It is several order of
magnitudes faster than regular iteration, because it involves access to the LSM-tree only, which is
usually resident entirely in RAM. To enable key-only iteration, you need to set the
`IteratorOptions.PrefetchValues` field to `false`. This can also be used to do sparse reads for
selected keys during an iteration, by calling `item.Value()` only when required.
```go
err := db.View(func(txn *badger.Txn) error {
@@ -538,28 +534,25 @@ err := db.View(func(txn *badger.Txn) error {
```
## Stream
Badger provides a Stream framework, which concurrently iterates over all or a
portion of the DB, converting data into custom key-values, and streams it out
serially to be sent over network, written to disk, or even written back to
Badger. This is a lot faster way to iterate over Badger than using a single
Iterator. Stream supports Badger in both managed and normal mode.
Stream uses the natural boundaries created by SSTables within the LSM tree, to
quickly generate key ranges. Each goroutine then picks a range and runs an
iterator to iterate over it. Each iterator iterates over all versions of values
and is created from the same transaction, thus working over a snapshot of the
DB. Every time a new key is encountered, it calls `ChooseKey(item)`, followed
by `KeyToList(key, itr)`. This allows a user to select or reject that key, and
if selected, convert the value versions into custom key-values. The goroutine
batches up 4MB worth of key-values, before sending it over to a channel.
Another goroutine further batches up data from this channel using *smart
batching* algorithm and calls `Send` serially.
Badger provides a Stream framework, which concurrently iterates over all or a portion of the DB,
converting data into custom key-values, and streams it out serially to be sent over network, written
to disk, or even written back to Badger. This is a lot faster way to iterate over Badger than using
a single Iterator. Stream supports Badger in both managed and normal mode.
This framework is designed for high throughput key-value iteration, spreading
the work of iteration across many goroutines. `DB.Backup` uses this framework to
provide full and incremental backups quickly. Dgraph is a heavy user of this
framework. In fact, this framework was developed and used within Dgraph, before
getting ported over to Badger.
Stream uses the natural boundaries created by SSTables within the LSM tree, to quickly generate key
ranges. Each goroutine then picks a range and runs an iterator to iterate over it. Each iterator
iterates over all versions of values and is created from the same transaction, thus working over a
snapshot of the DB. Every time a new key is encountered, it calls `ChooseKey(item)`, followed by
`KeyToList(key, itr)`. This allows a user to select or reject that key, and if selected, convert the
value versions into custom key-values. The goroutine batches up 4MB worth of key-values, before
sending it over to a channel. Another goroutine further batches up data from this channel using
_smart batching_ algorithm and calls `Send` serially.
This framework is designed for high throughput key-value iteration, spreading the work of iteration
across many goroutines. `DB.Backup` uses this framework to provide full and incremental backups
quickly. Dgraph is a heavy user of this framework. In fact, this framework was developed and used
within Dgraph, before getting ported over to Badger.
```go
stream := db.NewStream()
@@ -595,51 +588,52 @@ if err := stream.Orchestrate(context.Background()); err != nil {
```
## Garbage Collection
Badger values need to be garbage collected, because of two reasons:
* Badger keeps values separately from the LSM tree. This means that the compaction operations
that clean up the LSM tree do not touch the values at all. Values need to be cleaned up
separately.
- Badger keeps values separately from the LSM tree. This means that the compaction operations that
clean up the LSM tree do not touch the values at all. Values need to be cleaned up separately.
* Concurrent read/write transactions could leave behind multiple values for a single key, because they
are stored with different versions. These could accumulate, and take up unneeded space beyond the
time these older versions are needed.
- Concurrent read/write transactions could leave behind multiple values for a single key, because
they are stored with different versions. These could accumulate, and take up unneeded space beyond
the time these older versions are needed.
Badger relies on the client to perform garbage collection at a time of their choosing. It provides
the following method, which can be invoked at an appropriate time:
* `DB.RunValueLogGC()`: This method is designed to do garbage collection while
Badger is online. Along with randomly picking a file, it uses statistics generated by the
LSM-tree compactions to pick files that are likely to lead to maximum space
reclamation. It is recommended to be called during periods of low activity in
your system, or periodically. One call would only result in removal of at max
one log file. As an optimization, you could also immediately re-run it whenever
- `DB.RunValueLogGC()`: This method is designed to do garbage collection while Badger is online.
Along with randomly picking a file, it uses statistics generated by the LSM-tree compactions to
pick files that are likely to lead to maximum space reclamation. It is recommended to be called
during periods of low activity in your system, or periodically. One call would only result in
removal of at max one log file. As an optimization, you could also immediately re-run it whenever
it returns nil error (indicating a successful value log GC), as shown below.
```go
ticker := time.NewTicker(5 * time.Minute)
defer ticker.Stop()
for range ticker.C {
again:
err := db.RunValueLogGC(0.7)
if err == nil {
goto again
}
}
```
```go
ticker := time.NewTicker(5 * time.Minute)
defer ticker.Stop()
for range ticker.C {
again:
err := db.RunValueLogGC(0.7)
if err == nil {
goto again
}
}
```
* `DB.PurgeOlderVersions()`: This method is **DEPRECATED** since v1.5.0. Now, Badger's LSM tree automatically discards older/invalid versions of keys.
- `DB.PurgeOlderVersions()`: This method is **DEPRECATED** since v1.5.0. Now, Badger's LSM tree
automatically discards older/invalid versions of keys.
{{% notice "note" %}} The RunValueLogGC method would not garbage collect the latest value log.{{% /notice %}}
{{% notice "note" %}} The RunValueLogGC method would not garbage collect the latest value
log.{{% /notice %}}
## Database backup
There are two public API methods `DB.Backup()` and `DB.Load()` which can be
used to do online backups and restores. Badger v0.9 provides a CLI tool
`badger`, which can do offline backup/restore. Make sure you have `$GOPATH/bin`
in your PATH to use this tool.
The command below will create a version-agnostic backup of the database, to a
file `badger.bak` in the current working directory
There are two public API methods `DB.Backup()` and `DB.Load()` which can be used to do online
backups and restores. Badger v0.9 provides a CLI tool `badger`, which can do offline backup/restore.
Make sure you have `$GOPATH/bin` in your PATH to use this tool.
The command below will create a version-agnostic backup of the database, to a file `badger.bak` in
the current working directory
```sh
badger backup --dir <path/to/badgerdb>
@@ -653,19 +647,19 @@ badger restore --dir <path/to/badgerdb>
See `badger --help` for more details.
If you have a Badger database that was created using v0.8 (or below), you can
use the `badger_backup` tool provided in v0.8.1, and then restore it using the
command above to upgrade your database to work with the latest version.
If you have a Badger database that was created using v0.8 (or below), you can use the
`badger_backup` tool provided in v0.8.1, and then restore it using the command above to upgrade your
database to work with the latest version.
```sh
badger_backup --dir <path/to/badgerdb> --backup-file badger.bak
```
We recommend all users to use the `Backup` and `Restore` APIs and tools. However,
Badger is also rsync-friendly because all files are immutable, barring the
latest value log which is append-only. So, rsync can be used as rudimentary way
to perform a backup. In the following script, we repeat rsync to ensure that the
LSM tree remains consistent with the MANIFEST file while doing a full backup.
We recommend all users to use the `Backup` and `Restore` APIs and tools. However, Badger is also
rsync-friendly because all files are immutable, barring the latest value log which is append-only.
So, rsync can be used as rudimentary way to perform a backup. In the following script, we repeat
rsync to ensure that the LSM tree remains consistent with the MANIFEST file while doing a full
backup.
```sh
#!/bin/bash
@@ -678,17 +672,16 @@ while !! | grep -q "(MANIFEST\|\.sst)$"; do :; done
```
## Memory usage
Badger's memory usage can be managed by tweaking several options available in
the `Options` struct that is passed in when opening the database using
`DB.Open`.
Badger's memory usage can be managed by tweaking several options available in the `Options` struct
that is passed in when opening the database using `DB.Open`.
- Number of memtables (`Options.NumMemtables`)
- If you modify `Options.NumMemtables`, also adjust `Options.NumLevelZeroTables` and
`Options.NumLevelZeroTablesStall` accordingly.
`Options.NumLevelZeroTablesStall` accordingly.
- Number of concurrent compactions (`Options.NumCompactors`)
- Size of table (`Options.BaseTableSize`)
- Size of value log file (`Options.ValueLogFileSize`)
If you want to decrease the memory usage of Badger instance, tweak these
options (ideally one at a time) until you achieve the desired
memory usage.
If you want to decrease the memory usage of Badger instance, tweak these options (ideally one at a
time) until you achieve the desired memory usage.
+100 -55
View File
@@ -5,60 +5,105 @@ aliases = ["/project-using-badger"]
Below is a list of known projects that use Badger:
* [Dgraph](https://github.com/dgraph-io/dgraph) - Distributed graph database.
* [Jaeger](https://github.com/jaegertracing/jaeger) - Distributed tracing platform.
* [go-ipfs](https://github.com/ipfs/go-ipfs) - Go client for the InterPlanetary File System (IPFS), a new hypermedia distribution protocol.
* [Riot](https://github.com/go-ego/riot) - An open-source, distributed search engine.
* [emitter](https://github.com/emitter-io/emitter) - Scalable, low latency, distributed pub/sub broker with message storage, uses MQTT, gossip and badger.
* [OctoSQL](https://github.com/cube2222/octosql) - Query tool that allows you to join, analyse and transform data from multiple databases using SQL.
* [Dkron](https://dkron.io/) - Distributed, fault tolerant job scheduling system.
* [smallstep/certificates](https://github.com/smallstep/certificates) - Step-ca is an online certificate authority for secure, automated certificate management.
* [Sandglass](https://github.com/celrenheit/sandglass) - distributed, horizontally scalable, persistent, time sorted message queue.
* [TalariaDB](https://github.com/grab/talaria) - Grab's Distributed, low latency time-series database.
* [Sloop](https://github.com/salesforce/sloop) - Salesforce's Kubernetes History Visualization Project.
* [Usenet Express](https://usenetexpress.com/) - Serving over 300TB of data with Badger.
* [gorush](https://github.com/appleboy/gorush) - A push notification server written in Go.
* [0-stor](https://github.com/zero-os/0-stor) - Single device object store.
* [Dispatch Protocol](https://github.com/dispatchlabs/disgo) - Blockchain protocol for distributed application data analytics.
* [GarageMQ](https://github.com/valinurovam/garagemq) - AMQP server written in Go.
* [RedixDB](https://alash3al.github.io/redix/) - A real-time persistent key-value store with the same redis protocol.
* [BBVA](https://github.com/BBVA/raft-badger) - Raft backend implementation using BadgerDB for Hashicorp raft.
* [Fantom](https://github.com/Fantom-foundation/go-lachesis) - aBFT Consensus platform for distributed applications.
* [decred](https://github.com/decred/dcrdata) - An open, progressive, and self-funding cryptocurrency with a system of community-based governance integrated into its blockchain.
* [OpenNetSys](https://github.com/opennetsys/c3-go) - Create useful dApps in any software language.
* [HoneyTrap](https://github.com/honeytrap/honeytrap) - An extensible and opensource system for running, monitoring and managing honeypots.
* [Insolar](https://github.com/insolar/insolar) - Enterprise-ready blockchain platform.
* [IoTeX](https://github.com/iotexproject/iotex-core) - The next generation of the decentralized network for IoT powered by scalability- and privacy-centric blockchains.
* [go-sessions](https://github.com/kataras/go-sessions) - The sessions manager for Go net/http and fasthttp.
* [Babble](https://github.com/mosaicnetworks/babble) - BFT Consensus platform for distributed applications.
* [Tormenta](https://github.com/jpincas/tormenta) - Embedded object-persistence layer / simple JSON database for Go projects.
* [BadgerHold](https://github.com/timshannon/badgerhold) - An embeddable NoSQL store for querying Go types built on Badger
* [Goblero](https://github.com/didil/goblero) - Pure Go embedded persistent job queue backed by BadgerDB
* [Surfline](https://www.surfline.com) - Serving global wave and weather forecast data with Badger.
* [Cete](https://github.com/mosuka/cete) - Simple and highly available distributed key-value store built on Badger. Makes it easy bringing up a cluster of Badger with Raft consensus algorithm by hashicorp/raft.
* [Volument](https://volument.com/) - A new take on website analytics backed by Badger.
* [KVdb](https://kvdb.io/) - Hosted key-value store and serverless platform built on top of Badger.
* [Terminotes](https://gitlab.com/asad-awadia/terminotes) - Self hosted notes storage and search server - storage powered by BadgerDB
* [Pyroscope](https://github.com/pyroscope-io/pyroscope) - Open source continuous profiling platform built with BadgerDB
* [Veri](https://github.com/bgokden/veri) - A distributed feature store optimized for Search and Recommendation tasks.
* [bIter](https://github.com/MikkelHJuul/bIter) - A library and Iterator interface for working with the `badger.Iterator`, simplifying from-to, and prefix mechanics.
* [ld](https://github.com/MikkelHJuul/ld) - (Lean Database) A very simple gRPC-only key-value database, exposing BadgerDB with key-range scanning semantics.
* [Souin](https://github.com/darkweak/Souin) - A RFC compliant HTTP cache with lot of other features based on Badger for the storage. Compatible with all existing reverse-proxies.
* [Xuperchain](https://github.com/xuperchain/xupercore) - A highly flexible blockchain architecture with great transaction performance.
* [m2](https://github.com/qichengzx/m2) - A simple http key/value store based on the raft protocol.
* [chaindb](https://github.com/ChainSafe/chaindb) - A blockchain storage layer used by [Gossamer](https://chainsafe.github.io/gossamer/), a Go client for the [Polkadot Network](https://polkadot.network/).
* [vxdb](https://github.com/vitalvas/vxdb) - Simple schema-less Key-Value NoSQL database with simplest API interface.
* [Opacity](https://github.com/opacity/storage-node) - Backend implementation for the Opacity storage project
* [Vephar](https://github.com/vaccovecrana/vephar) - A minimal key/value store using hashicorp-raft for cluster coordination and Badger for data storage.
* [gowarcserver](https://github.com/nlnwa/gowarcserver) - Open-source server for warc files. Can be used in conjunction with pywb
* [flow-go](https://github.com/onflow/flow-go) - A fast, secure, and developer-friendly blockchain built to support the next generation of games, apps and the digital assets that power them.
* [Wrgl](https://www.wrgl.co) - A data version control system that works like Git but specialized to store and diff CSV.
* [Loggie](https://github.com/loggie-io/loggie) - A lightweight, cloud-native data transfer agent and aggregator.
* [raft-badger](https://github.com/rfyiamcool/raft-badger) - raft-badger implements LogStore and StableStore Interface of hashcorp/raft. it is used to store raft log and metadata of hashcorp/raft.
* [DVID](https://github.com/janelia-flyem/dvid) - A dataservice for branched versioning of a variety of data types. Originally created for large-scale brain reconstructions in Connectomics.
* [KVS](https://github.com/tauraamui/kvs) - A library for making it easy to persist, load and query full structs into BadgerDB, using an ownership hierarchy model.
* [LLS](https://github.com/Boc-chi-no/LLS) - LLS is an efficient URL Shortener that can be used to shorten links and track link usage. Support for BadgerDB and MongoDB. Improved performance by more than 30% when using BadgerDB
* [ActionManager](https://mftlabs.io/actionmanager) - A dynamic entity manager based on rjsf schema and badger db
* [MightyMap](https://github.com/thisisdevelopment/mightymap) - Mightymap: Conveys both robustness and high capability, fitting for a powerful concurrent map.
- [Dgraph](https://github.com/dgraph-io/dgraph) - Distributed graph database.
- [Jaeger](https://github.com/jaegertracing/jaeger) - Distributed tracing platform.
- [go-ipfs](https://github.com/ipfs/go-ipfs) - Go client for the InterPlanetary File System (IPFS),
a new hypermedia distribution protocol.
- [Riot](https://github.com/go-ego/riot) - An open-source, distributed search engine.
- [emitter](https://github.com/emitter-io/emitter) - Scalable, low latency, distributed pub/sub
broker with message storage, uses MQTT, gossip and badger.
- [OctoSQL](https://github.com/cube2222/octosql) - Query tool that allows you to join, analyse and
transform data from multiple databases using SQL.
- [Dkron](https://dkron.io/) - Distributed, fault tolerant job scheduling system.
- [smallstep/certificates](https://github.com/smallstep/certificates) - Step-ca is an online
certificate authority for secure, automated certificate management.
- [Sandglass](https://github.com/celrenheit/sandglass) - distributed, horizontally scalable,
persistent, time sorted message queue.
- [TalariaDB](https://github.com/grab/talaria) - Grab's Distributed, low latency time-series
database.
- [Sloop](https://github.com/salesforce/sloop) - Salesforce's Kubernetes History Visualization
Project.
- [Usenet Express](https://usenetexpress.com/) - Serving over 300TB of data with Badger.
- [gorush](https://github.com/appleboy/gorush) - A push notification server written in Go.
- [0-stor](https://github.com/zero-os/0-stor) - Single device object store.
- [Dispatch Protocol](https://github.com/dispatchlabs/disgo) - Blockchain protocol for distributed
application data analytics.
- [GarageMQ](https://github.com/valinurovam/garagemq) - AMQP server written in Go.
- [RedixDB](https://alash3al.github.io/redix/) - A real-time persistent key-value store with the
same redis protocol.
- [BBVA](https://github.com/BBVA/raft-badger) - Raft backend implementation using BadgerDB for
Hashicorp raft.
- [Fantom](https://github.com/Fantom-foundation/go-lachesis) - aBFT Consensus platform for
distributed applications.
- [decred](https://github.com/decred/dcrdata) - An open, progressive, and self-funding
cryptocurrency with a system of community-based governance integrated into its blockchain.
- [OpenNetSys](https://github.com/opennetsys/c3-go) - Create useful dApps in any software language.
- [HoneyTrap](https://github.com/honeytrap/honeytrap) - An extensible and opensource system for
running, monitoring and managing honeypots.
- [Insolar](https://github.com/insolar/insolar) - Enterprise-ready blockchain platform.
- [IoTeX](https://github.com/iotexproject/iotex-core) - The next generation of the decentralized
network for IoT powered by scalability- and privacy-centric blockchains.
- [go-sessions](https://github.com/kataras/go-sessions) - The sessions manager for Go net/http and
fasthttp.
- [Babble](https://github.com/mosaicnetworks/babble) - BFT Consensus platform for distributed
applications.
- [Tormenta](https://github.com/jpincas/tormenta) - Embedded object-persistence layer / simple JSON
database for Go projects.
- [BadgerHold](https://github.com/timshannon/badgerhold) - An embeddable NoSQL store for querying Go
types built on Badger
- [Goblero](https://github.com/didil/goblero) - Pure Go embedded persistent job queue backed by
BadgerDB
- [Surfline](https://www.surfline.com) - Serving global wave and weather forecast data with Badger.
- [Cete](https://github.com/mosuka/cete) - Simple and highly available distributed key-value store
built on Badger. Makes it easy bringing up a cluster of Badger with Raft consensus algorithm by
hashicorp/raft.
- [Volument](https://volument.com/) - A new take on website analytics backed by Badger.
- [KVdb](https://kvdb.io/) - Hosted key-value store and serverless platform built on top of Badger.
- [Terminotes](https://gitlab.com/asad-awadia/terminotes) - Self hosted notes storage and search
server - storage powered by BadgerDB
- [Pyroscope](https://github.com/pyroscope-io/pyroscope) - Open source continuous profiling platform
built with BadgerDB
- [Veri](https://github.com/bgokden/veri) - A distributed feature store optimized for Search and
Recommendation tasks.
- [bIter](https://github.com/MikkelHJuul/bIter) - A library and Iterator interface for working with
the `badger.Iterator`, simplifying from-to, and prefix mechanics.
- [ld](https://github.com/MikkelHJuul/ld) - (Lean Database) A very simple gRPC-only key-value
database, exposing BadgerDB with key-range scanning semantics.
- [Souin](https://github.com/darkweak/Souin) - A RFC compliant HTTP cache with lot of other features
based on Badger for the storage. Compatible with all existing reverse-proxies.
- [Xuperchain](https://github.com/xuperchain/xupercore) - A highly flexible blockchain architecture
with great transaction performance.
- [m2](https://github.com/qichengzx/m2) - A simple http key/value store based on the raft protocol.
- [chaindb](https://github.com/ChainSafe/chaindb) - A blockchain storage layer used by
[Gossamer](https://chainsafe.github.io/gossamer/), a Go client for the
[Polkadot Network](https://polkadot.network/).
- [vxdb](https://github.com/vitalvas/vxdb) - Simple schema-less Key-Value NoSQL database with
simplest API interface.
- [Opacity](https://github.com/opacity/storage-node) - Backend implementation for the Opacity
storage project
- [Vephar](https://github.com/vaccovecrana/vephar) - A minimal key/value store using hashicorp-raft
for cluster coordination and Badger for data storage.
- [gowarcserver](https://github.com/nlnwa/gowarcserver) - Open-source server for warc files. Can be
used in conjunction with pywb
- [flow-go](https://github.com/onflow/flow-go) - A fast, secure, and developer-friendly blockchain
built to support the next generation of games, apps and the digital assets that power them.
- [Wrgl](https://www.wrgl.co) - A data version control system that works like Git but specialized to
store and diff CSV.
- [Loggie](https://github.com/loggie-io/loggie) - A lightweight, cloud-native data transfer agent
and aggregator.
- [raft-badger](https://github.com/rfyiamcool/raft-badger) - raft-badger implements LogStore and
StableStore Interface of hashcorp/raft. it is used to store raft log and metadata of
hashcorp/raft.
- [DVID](https://github.com/janelia-flyem/dvid) - A dataservice for branched versioning of a variety
of data types. Originally created for large-scale brain reconstructions in Connectomics.
- [KVS](https://github.com/tauraamui/kvs) - A library for making it easy to persist, load and query
full structs into BadgerDB, using an ownership hierarchy model.
- [LLS](https://github.com/Boc-chi-no/LLS) - LLS is an efficient URL Shortener that can be used to
shorten links and track link usage. Support for BadgerDB and MongoDB. Improved performance by more
than 30% when using BadgerDB
- [ActionManager](https://mftlabs.io/actionmanager) - A dynamic entity manager based on rjsf schema
and badger db
- [MightyMap](https://github.com/thisisdevelopment/mightymap) - Mightymap: Conveys both robustness
and high capability, fitting for a powerful concurrent map.
If you are using Badger in a project please send a pull request to add it to the list.
+7 -5
View File
@@ -3,18 +3,20 @@ title = "Resources"
aliases = ["/resouces"]
+++
## Blog Posts
1. [Introducing Badger: A fast key-value store written natively in
Go](https://open.dgraph.io/post/badger/)
1. [Introducing Badger: A fast key-value store written natively in Go](https://open.dgraph.io/post/badger/)
2. [Make Badger crash resilient with ALICE](https://blog.dgraph.io/post/alice/)
3. [Badger vs LMDB vs BoltDB: Benchmarking key-value databases in Go](https://blog.dgraph.io/post/badger-lmdb-boltdb/)
4. [Concurrent ACID Transactions in Badger](https://blog.dgraph.io/post/badger-txn/)
## Contact
- Please use [discuss.dgraph.io](https://discuss.dgraph.io) for questions, bugs, feature requests, and discussions.
- Please use [discuss.dgraph.io](https://discuss.dgraph.io) for questions, bugs, feature requests,
and discussions.
- Follow us on Twitter [@dgraphlabs](https://twitter.com/dgraphlabs).
## Contributing
If you're interested in contributing to Badger see [CONTRIBUTING.md](https://github.com/dgraph-io/badger/blob/main/CONTRIBUTING.md).
If you're interested in contributing to Badger see
[CONTRIBUTING.md](https://github.com/dgraph-io/badger/blob/main/CONTRIBUTING.md).
+35 -40
View File
@@ -38,7 +38,7 @@ joinVersions() {
function version { echo "$@" | gawk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'; }
rebuild() {
echo -e "$(date) $GREEN Updating docs for branch: $1.$RESET"
echo -e "$(date) ${GREEN} Updating docs for branch: $1.${RESET}"
# The latest documentation is generated in the root of /public dir
# Older documentations are generated in their respective `/public/vx.x.x` dirs
@@ -52,32 +52,30 @@ rebuild() {
export CURRENT_BRANCH=${1}
export CURRENT_VERSION=${2}
export VERSIONS=${VERSION_STRING}
HUGO_TITLE="Badger Doc ${2}"\
VERSIONS=${VERSION_STRING}\
CURRENT_BRANCH=${1}\
HUGO_TITLE="Badger Doc ${2}" \
VERSIONS=${VERSION_STRING} \
CURRENT_BRANCH=${1} \
CURRENT_VERSION=${2} ${HUGO} \
--destination="${PUBLIC}"/"$dir"\
--baseURL="$HOST"/"$dir" 1> /dev/null
--destination="${PUBLIC}"/"${dir}" \
--baseURL="${HOST}"/"${dir}" 1>/dev/null
}
branchUpdated()
{
branchUpdated() {
local branch="$1"
git checkout -q "$1"
UPSTREAM=$(git rev-parse "@{u}")
LOCAL=$(git rev-parse "@")
if [ "$LOCAL" != "$UPSTREAM" ] ; then
git merge -q origin/"$branch"
if [[ ${LOCAL} != "${UPSTREAM}" ]]; then
git merge -q origin/"${branch}"
return 0
else
return 1
fi
}
publicFolder()
{
publicFolder() {
dir=''
if [[ $1 == "${VERSIONS_ARRAY[0]}" ]]; then
echo "${PUBLIC}"
@@ -86,63 +84,60 @@ publicFolder()
fi
}
checkAndUpdate()
{
checkAndUpdate() {
local version="$1"
local branch=""
if [[ $version == "master" ]]; then
if [[ ${version} == "master" ]]; then
branch="master"
else
branch="release/$version"
branch="release/${version}"
fi
if branchUpdated "$branch" ; then
git merge -q origin/"$branch"
rebuild "$branch" "$version"
if branchUpdated "${branch}"; then
git merge -q origin/"${branch}"
rebuild "${branch}" "${version}"
fi
folder=$(publicFolder "$version")
if [ "$firstRun" = 1 ] || [ "$themeUpdated" = 0 ] || [ ! -d "$folder" ] ; then
rebuild "$branch" "$version"
folder=$(publicFolder "${version}")
if [[ ${firstRun} == 1 ]] || [[ ${themeUpdated} == 0 ]] || [[ ! -d ${folder} ]]; then
rebuild "${branch}" "${version}"
fi
}
firstRun=1
while true; do
# Lets move to the docs directory.
pushd "$(dirname "$0")/.." > /dev/null
pushd "$(dirname "$0")/.." >/dev/null
currentBranch=$(git rev-parse --abbrev-ref HEAD)
# Lets check if the theme was updated.
pushd themes/hugo-docs > /dev/null
git remote update > /dev/null
pushd themes/hugo-docs >/dev/null
git remote update >/dev/null
themeUpdated=1
if branchUpdated "master" ; then
echo -e "$(date) $GREEN Theme has been updated. Now will update the docs.$RESET"
if branchUpdated "master"; then
echo -e "$(date) ${GREEN} Theme has been updated. Now will update the docs.${RESET}"
themeUpdated=0
fi
popd > /dev/null
popd >/dev/null
# Now lets check the theme.
echo -e "$(date) Starting to check branches."
git remote update > /dev/null
git remote update >/dev/null
for version in "${VERSIONS_ARRAY[@]}"
do
checkAndUpdate "$version"
for version in "${VERSIONS_ARRAY[@]}"; do
checkAndUpdate "${version}"
done
echo -e "$(date) Done checking branches.\n"
git checkout -q "$currentBranch"
popd > /dev/null
git checkout -q "${currentBranch}"
popd >/dev/null
firstRun=0
if ! $LOOP; then
exit
fi
if ! ${LOOP}; then
exit
fi
sleep 60
done
done
+31 -32
View File
@@ -6,7 +6,7 @@ GREEN='\033[32;1m'
RESET='\033[0m'
VERSIONS_ARRAY=(
'preview'
'preview'
)
joinVersions() {
@@ -16,40 +16,39 @@ joinVersions() {
VERSION_STRING=$(joinVersions)
run() {
export CURRENT_BRANCH="master"
export CURRENT_VERSION=${VERSIONS_ARRAY[0]}
export VERSIONS=${VERSION_STRING}
export DGRAPH_ENDPOINT=${DGRAPH_ENDPOINT:-"https://play.dgraph.io/query?latency=true"}
run() {
export CURRENT_BRANCH="master"
export CURRENT_VERSION=${VERSIONS_ARRAY[0]}
export VERSIONS=${VERSION_STRING}
export DGRAPH_ENDPOINT=${DGRAPH_ENDPOINT:-"https://play.dgraph.io/query?latency=true"}
export HUGO_TITLE="Badger Doc - Preview" \
export VERSIONS=${VERSION_STRING} \
export CURRENT_BRANCH="master" \
export CURRENT_VERSION=${CURRENT_VERSION}
export HUGO_TITLE="Badger Doc - Preview" \
export VERSIONS=${VERSION_STRING} \
export CURRENT_BRANCH="master" \
export CURRENT_VERSION=${CURRENT_VERSION}
pushd "$(dirname "$0")/.." >/dev/null
pushd themes >/dev/null
pushd "$(dirname "$0")/.." > /dev/null
pushd themes > /dev/null
if [[ ! -d "hugo-docs" ]]; then
echo -e "$(date) ${GREEN} Hugo-docs repository not found. Cloning the repo. ${RESET}"
git clone https://github.com/dgraph-io/hugo-docs.git
else
echo -e "$(date) ${GREEN} Hugo-docs repository found. Pulling the latest version from master. ${RESET}"
pushd hugo-docs >/dev/null
git pull
popd >/dev/null
fi
popd >/dev/null
if [ ! -d "hugo-docs" ]; then
echo -e "$(date) $GREEN Hugo-docs repository not found. Cloning the repo. $RESET"
git clone https://github.com/dgraph-io/hugo-docs.git
else
echo -e "$(date) $GREEN Hugo-docs repository found. Pulling the latest version from master. $RESET"
pushd hugo-docs > /dev/null
git pull
popd > /dev/null
fi
popd > /dev/null
if [[ $1 == "-p" || $1 == "--preview" ]]; then
echo -e "$(date) $GREEN Generating documentation static pages in the public folder. $RESET"
hugo --destination=public --baseURL="$2" 1> /dev/null
echo -e "$(date) $GREEN Done building. $RESET"
else
hugo server -w --baseURL=http://localhost:1313
fi
popd > /dev/null
if [[ $1 == "-p" || $1 == "--preview" ]]; then
echo -e "$(date) ${GREEN} Generating documentation static pages in the public folder. ${RESET}"
hugo --destination=public --baseURL="$2" 1>/dev/null
echo -e "$(date) ${GREEN} Done building. ${RESET}"
else
hugo server -w --baseURL=http://localhost:1313
fi
popd >/dev/null
}
run "$1" "$2"
run "$1" "$2"
Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 24 KiB

+12 -15
View File
@@ -1,21 +1,18 @@
The MIT License (MIT)
Copyright (c) 2014 Grav
Copyright (c) 2016 MATHIEU CORNIC
Copyright (c) 2014 Grav Copyright (c) 2016 MATHIEU CORNIC
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 306 KiB

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 115 KiB

+4 -11
View File
@@ -191,19 +191,11 @@ pre.collapsed .showmore {
padding-bottom: 5px;
padding-top: 26px;
cursor: pointer;
background: linear-gradient(
180deg,
hsla(0, 0%, 100%, 0.1),
rgba(226, 226, 226, 0.72)
);
background: linear-gradient(180deg, hsla(0, 0%, 100%, 0.1), rgba(226, 226, 226, 0.72));
color: #5a5a5a;
}
pre.collapsed .showmore:hover {
background: linear-gradient(
180deg,
hsla(0, 0%, 100%, 0.1),
rgba(226, 226, 226, 0.91)
);
background: linear-gradient(180deg, hsla(0, 0%, 100%, 0.1), rgba(226, 226, 226, 0.91));
font-weight: 600;
}
pre.collapsed .showmore span {
@@ -695,7 +687,8 @@ section.toc .section-item {
font-size: 1rem;
font-weight: bold;
}
.landing .item h3:hover, .landing .item .cta:hover {
.landing .item h3:hover,
.landing .item .cta:hover {
text-decoration: underline;
}
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 49 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 101 KiB

After

Width:  |  Height:  |  Size: 91 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 84 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 46 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 46 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Some files were not shown because too many files have changed in this diff Show More