Categorygithub.com/mcuadros/go-rat
repositorypackage
1.1.0
Repository: https://github.com/mcuadros/go-rat.git
Documentation: pkg.go.dev

# README

rat - random access tar

Build Status Coverage Status GoDoc GitHub release

rat is an extension to the classical tar archive, focused on allowing constant-time random file access with linear memory consumption increase. tape archive, was originally developed to write and read streamed sources, making random access to the content very inefficient.

Based on the benchmarks, we found that rat is 4x to 60x times faster over SSD and HDD than the classic tar file, when reading a single file from a tar archive.

Any tar file produced by rat is compatible with standard tar implementation.

Installation

The recommended way to install rat

go get -u github.com/mcuadros/go-rat/...

Example

Import the package:

import "github.com/mcuadros/go-rat"

Converting a standard tar file to a rat file:

src, _ := os.Open("standard.file.tar")
dst, _ := os.Create("extended.rat.file.tar")
defer src.Close()
defer dst.Close()

if err = AddIndexToTar(src, dst); err != nil {
    panic(err)
}

Searching a specific file in a rat file:

archive, _ := os.Open("extended.rat.file.tar")

content, _ := archive.ReadFile("foo.txt")
fmt.Println(string(content))
//Prints: foo

Benchmarks Results

These are some of the benchmarking results over differrent storage systems.

Fixture name explanation: 5_1.0KB_102KB means a tar containing 5 files with a size between 1kb and 102kb.

SSDTAR (ns)RAT (ns)times
5_1.0KB_102KB367838772364.76
100_1.0KB_102KB592503635011616.92
1000_1.0KB_102KB58735369350331716.77
6000_1.0KB_102KB3494846652006407217.42
60_1.0MB_21MB146302392340265143.00
HDDTAR (ns)RAT (ns)times
5_1.0KB_102KB253406544724.65
100_1.0KB_102KB368279628208513.06
1000_1.0KB_102KB37834628239623915.79
6000_1.0KB_102KB2108413821391315815.15
60_1.0MB_21MB166405959278365959.78
GlusterFSTAR (ns)RAT (ns)times
5_1.0KB_102KB2932521306522.24
100_1.0KB_102KB429272336239911.85
1000_1.0KB_102KB3963258144689768.87
6000_1.0KB_102KB241305750416586371145.48
60_1.0MB_21MB6234613201125297045.54

License

MIT, see LICENSE