Documentation
¶
Index ¶
Constants ¶
View Source
const ( // Kb - Kilobyte Kb = 1024 // Mb - Megabyte Mb = 1024 * Kb // Gb - Gigabyte Gb = 1024 * Mb // StatusNotStarted - The Indexer has been created but not started StatusNotStarted = "Not Started" // StatusStarting - Indexer is starting StatusStarting = "Starting" // StatusSorting - Indexer is sorting tapes StatusSorting = "Sorting" // StatusMerging - Indexer is merging tapes StatusMerging = "Merging" )
Variables ¶
This section is empty.
Functions ¶
func EntryComparer ¶
func EntryComparer(a, b interface{}) int
EntryComparer - Compares entries in an index
Types ¶
type Sorter ¶
type Sorter struct {
IndexPath string
Index *os.File
OutputPath string
Output *os.File
Info os.FileInfo
MaxWorkers int
NumberOfEntires int // Number of entries
MaxMemory int // size of buffer in bytes
WorkerBufSize int
EntriesPerTape int
MaxPerTapeBufSize int
MergeBufLen int
Tapes []*Tape
TapeDir string
NoTapeCleanup bool
Heap *binaryheap.Heap
MergePercent float64
Workers []*Worker
NumberOfTapes int
Status string
}
Sorter - An index file
func GetSorter ¶
func GetSorter(index, output string, maxWorkers, maxMemory int, tempDir string, noTapeCleanup bool) (*Sorter, error)
GetSorter - Start the sorting process
func (*Sorter) CreateTape ¶
CreateTape - Creates a tape and loads the entire tap into memory
func (*Sorter) IsMergeCompleted ¶
IsMergeCompleted - Returns true if all tapes have ended and heap is size 0
func (*Sorter) PopulateHeap ¶
func (s *Sorter) PopulateHeap()
PopulateHeap - Populate the heap with lowest values from sorted tapes
func (*Sorter) TapesCompleted ¶
TapesCompleted - Number of tapes completed
type Tape ¶
type Tape struct {
ID int
Entries []*Entry
Dir string
FileName string
Len int // Number of entires in tape file
MergeSize int // Number of entires in merge buffer
Position int
}
Tape - A subsection of the index file that we can sort in-memory
func (*Tape) IsEndOfTape ¶
IsEndOfTape - Returns true if end of tape has been reached
The file is zero indexed but the Position will get incremented until EOF, so no Size-1.
Click to show internal directories.
Click to hide internal directories.