lexorank

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: MIT Imports: 4 Imported by: 0

README

Codecov GitHub Actions Workflow Status Codacy Badge GitHub language count GitHub top language GitHub License GoDoc


Logo

LexoRank
Report Bug | Request Feature | Documentation

Built With

Description

This is a simple implementation of the LexoRank algorithm in Go.

Installation

  1. go get github.com/BlindGarret/lexorank

Documentation

Index

Constants

View Source
const (
	BeginningToEnd = "beginingToEnd"
	EndToBegining  = "endToBegining"
)

Variables

View Source
var ErrGapSizeToLargeForObjectCount = fmt.Errorf("minGapSize is too large for objectCount")
View Source
var ErrRankFormatInvalid = fmt.Errorf("rank format is invalid")
View Source
var MaxBucketValue = 2

MaxBucketValue is the maximum value a bucket can be before it wraps around to 0, default is 2

Functions

func Between

func Between(first string, second string) (string, error)

Between returns the rank that is between the two provided ranks

func DissectRank

func DissectRank(rank string) (bucket int, id string, err error)

DissectRank is a helper function which takes a rank and returns the bucket and id of the rank

func Next

func Next(currentMaxRank string, longestRank string, stepSize uint64) (string, error)

Next returns the next rank in the lexorank space

currentMaxRank is the current maximum rank in the set

longestRank is the highest length in the set, (not highest rank, but highest len(rank)) this is required do to our usage of appending I's to the end of values to avoid collisions. It allows us to pad the max rank to the correct value before we start calculating the next rank

stepSize is the number of steps to take to get to the next rank (we have no way to evenly distribute the ranks so we have to use a step size)

Types

type Direction

type Direction string

Direction is the direction of movement for reindexing through the set. Whether it's going from begining to end or end to begining will matter based on which bucket we are moving to

type Indexer

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

Indexer is a lexorank index generator for reindexing objects to ensure they are spread throughout the lexorank space

func NewIndexer

func NewIndexer(minGapSize uint64, objectCount uint64, currentBucket int) (*Indexer, error)

NewIndexer creates a new indexer for reindexing objects in the lexorank space

func (*Indexer) Direction

func (i *Indexer) Direction() Direction

Direction returns the direction you should travel through your set during reindexing

func (*Indexer) Next

func (i *Indexer) Next() string

Next returns the next rank in the lexorank space

Jump to

Keyboard shortcuts

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