xdelta

package module
v0.0.0-...-c291ec5 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: LGPL-2.1 Imports: 8 Imported by: 0

README

xdelta

—— 用于提取文件间差异数据,并且用于在两个端点之间进行差异化的文件同步。核心采用 rsync 算法,并且支持多轮同步以及就地构造文件。 ——

  • In-Place Rsync: File Synchronization for Mobile and Wireless Devices, David Rasch and Randal Burns Department of Computer Science Johns Hopkins University {frasch,randalg}@cs.jhu.edu。

Documentation

Index

Constants

View Source
const (
	DIGEST_BYTES           = 16
	XDELTA_BUFFER_LEN      = (1 << 22)
	ROLLSUM_CHAR_OFFSET    = 31
	XDELTA_BLOCK_SIZE      = 16   // Define your XDELTA_BLOCK_SIZE here
	MAX_XDELTA_BLOCK_BYTES = 4096 // Define your MAX_XDELTA_BLOCK_BYTES here
)

/ 在一些内存受限系统中,如果下面的参数定义得很多,有可能导致内存耗用过多,使系统 / 运行受到影响,甚至是宕机,所以,当你需要你的目标系统的内存特性后,请你自己定义相应的 / 的大小。不过建议 MULTIROUND_MAX_BLOCK_SIZE 不要小于 512 KB,XDELTA_BUFFER_LEN 必须大于 / MULTIROUND_MAX_BLOCK_SIZE,最好为 2 的 N 次方倍,如 8 倍 等。 / 当你的系统中存在大量内存时,较大的内存可以优化实现。使用库同步数据时,软件系统最多占用内存 / 的大概为: / 在数据源端(客户端): / 线程数 * XDELTA_BUFFER_LEN * 3,如果系统内存受限,你可以采用少线程的方式进行处理方式, / 但是你无法使用多线程的优势。 / 在数据目标端(服务端): / 线程数 * XDELTA_BUFFER_LEN * 2,但是线程数量受到并发的客户端的数目以及每客户端在同步数据时 / 采用的线程数。 / 由于在同步时,如果文件大小或者块大小,没有达到 XDELTA_BUFFER_LEN 长度,则未被使用的地址系统不会分配 / 物理内存,因此有时只会占用进程的地址空间,但却不会占用系统的物理内存。 Constants

View Source
const (
	DT_DIFF  uint16 = 0x0
	DT_IDENT uint16 = 0xffff
)

Variables

This section is empty.

Functions

func MultipleRound

func MultipleRound(srcfile, tgtfile string) error

func RollsumHash

func RollsumHash(buf []byte, len int) uint32

func SingleRound

func SingleRound(srcfile, tgtfile string) error

func SingleRoundInplace

func SingleRoundInplace(srcfile, tgtfile string) error

Types

type HasherRet

type HasherRet struct {
	// contains filtered or unexported fields
}

type Hole

type Hole struct {
	Offset uint64 // 文件偏移量
	Length uint64 // 文件长度
}

type Rollsum

type Rollsum struct {
	// contains filtered or unexported fields
}

func (*Rollsum) Digest

func (rs *Rollsum) Digest() uint32

func (*Rollsum) EatHash

func (rs *Rollsum) EatHash(buf []byte, len int)

func (*Rollsum) Hash

func (rs *Rollsum) Hash(buf []byte, len int)

func (*Rollsum) Rollin

func (rs *Rollsum) Rollin(c byte)

func (*Rollsum) Rollout

func (rs *Rollsum) Rollout(c byte)

func (*Rollsum) Rotate

func (rs *Rollsum) Rotate(out, in byte)

func (*Rollsum) Update

func (rs *Rollsum) Update(out, in byte) uint32

type SlowHash

type SlowHash struct {
	Hash [DIGEST_BYTES]uint8
	TPos TargetPos
}

type TargetPos

type TargetPos struct {
	Index   uint32
	TOffset uint64
}

TargetPos represents the target_pos struct in C.

type XdeltaRet

type XdeltaRet struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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