block

package
v1.1.47 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinPlainCoord = -34351347711
)

https://bitbucket.org/s_l_teichmann/mtsatellite/src/e1bf980a2b278c570b3f44f9452c9c087558acb3/common/coords.go?at=default&fileviewer=file-view-default

Variables

View Source
var IteratorBatchSize = 4096

IteratorBatchSize is a default value to be used while batching over Iterators.

Functions

func AsBlockPos added in v1.1.45

func AsBlockPos(x, y, z int) (int, int, int)

AsBlockPos converts the coordinates from the given Node into the equivalent Block position. Each block contains 16x16x16 nodes.

func CoordToPlain

func CoordToPlain(x, y, z int) int64

func MigrateBlockDB

func MigrateBlockDB(db *sql.DB, dbtype types.DatabaseType) error

func PlainToCoord

func PlainToCoord(i int64) (x, y, z int)

Types

type Block

type Block struct {
	PosX int    `json:"x"`
	PosY int    `json:"y"`
	PosZ int    `json:"z"`
	Data []byte `json:"data"`
}

func (*Block) String added in v1.1.45

func (b *Block) String() string

type BlockRepository

type BlockRepository interface {
	types.Backup

	// GetByPost returns the map block at positions X,Y,Z.
	GetByPos(x, y, z int) (*Block, error)

	// Iterator returns a channel to fetch all data from the starting position
	// X,Y,Z (exclusive), with the map blocks sorted by position ascending.
	// Sorting is done by Z, Y, X to keep consistency with Sqlite map format.
	Iterator(x, y, z int) (chan *Block, types.Closer, error)

	// Update upserts the provided map block in the database, using the position
	// as key.
	Update(block *Block) error

	// Delete removes the map block from the database denoted by the x,y,z
	// coordinates.
	Delete(x, y, z int) error

	// Vacuum executes the storage layer vacuum command. Useful to reclaim
	// storage space if not done automatically by the backend.
	Vacuum() error

	// Count returns the total number of stored blocks in the map database.
	Count() (int64, error)

	// Close gracefully finishes the connection with the database backend.
	Close() error
}

BlockRepository implementes data access layer for the Minetest map data. All positions are in mapblock coordinates, as described here: https://github.com/minetest/minetest/blob/master/doc/lua_api.md#mapblock-coordinates

func NewBlockRepository

func NewBlockRepository(db *sql.DB, dbtype types.DatabaseType) BlockRepository

NewBlockRepository initializes the connection with the appropriate database backend and returns the BlockRepository implementation suited for it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL