Documentation ¶
Index ¶
- Constants
- Variables
- func CountBits(arc *Arc, in BytesReader) (int, error)
- func CountBitsUpTo(bitIndex int, arc *Arc, in BytesReader) (int, error)
- func IsBitSet(ctx context.Context, bitIndex int, arc *Arc, in BytesReader) (bool, error)
- func NextBitSet(ctx context.Context, bitIndex int, arc *Arc, in BytesReader) (int, error)
- func PreviousBitSet(bitIndex int, arc *Arc, in BytesReader) (int, error)
- func TargetHasArcs(arc *Arc) bool
- type AbsEnum
- type Arc
- func (r *Arc) ArcIdx() int
- func (r *Arc) BytesPerArc() int
- func (r *Arc) FirstLabel() int
- func (r *Arc) Flags() byte
- func (r *Arc) IsFinal() bool
- func (r *Arc) IsLast() bool
- func (r *Arc) Label() int
- func (r *Arc) NextArc() int64
- func (r *Arc) NextFinalOutput() Output
- func (r *Arc) NodeFlags() byte
- func (r *Arc) NumArcs() int
- func (r *Arc) Output() Output
- func (r *Arc) PosArcsStart() int64
- func (r *Arc) Target() int64
- type BoxManager
- func (b *BoxManager[T]) EmptyOutput() Output
- func (b *BoxManager[T]) New() Output
- func (b *BoxManager[T]) Read(ctx context.Context, in store.DataInput, v any) error
- func (b *BoxManager[T]) ReadFinalOutput(ctx context.Context, in store.DataInput, v any) error
- func (b *BoxManager[T]) SkipFinalOutput(ctx context.Context, in store.DataInput) error
- func (b *BoxManager[T]) SkipOutput(ctx context.Context, in store.DataInput) error
- func (b *BoxManager[T]) Write(ctx context.Context, out store.DataOutput, v any) error
- func (b *BoxManager[T]) WriteFinalOutput(ctx context.Context, out store.DataOutput, v any) error
- type Buffer
- type Builder
- func (b *Builder) Add(ctx context.Context, input []rune, output Output) error
- func (b *Builder) AddInts(ctx context.Context, input []int, output Output) error
- func (b *Builder) AddStr(ctx context.Context, input string, output Output) error
- func (b *Builder) Finish(ctx context.Context) (*FST, error)
- func (b *Builder) GetArcCount() int
- func (b *Builder) GetDirectAddressingMaxOversizingFactor() float64
- func (b *Builder) GetNodeCount() int
- func (b *Builder) GetTermCount() int
- func (b *Builder) SetDirectAddressingMaxOversizingFactor(factor float64) *Builder
- type BuilderOption
- func WithAllowFixedLengthArcs(allowFixedLengthArcs bool) BuilderOption
- func WithBytesPageBits(bytesPageBits int) BuilderOption
- func WithDoShareNonSingletonNodes(doShareNonSingletonNodes bool) BuilderOption
- func WithDoShareSuffix(doShareSuffix bool) BuilderOption
- func WithMinSuffixCount1(minSuffixCount1 int) BuilderOption
- func WithMinSuffixCount2(minSuffixCount2 int) BuilderOption
- func WithShareMaxTailLength(shareMaxTailLength int) BuilderOption
- type ByteStore
- func (r *ByteStore) CopyTo(ctx context.Context, src int64, size int64, w io.Writer) error
- func (r *ByteStore) Finish() error
- func (r *ByteStore) GetBlockBits() int64
- func (r *ByteStore) GetPosition() int64
- func (r *ByteStore) GetReverseReader() (BytesReader, error)
- func (r *ByteStore) MoveBytes(ctx context.Context, src, dest, size int64) error
- func (r *ByteStore) Reverse(srcPos, destPos int64) error
- func (r *ByteStore) SkipBytes(size int64) error
- func (r *ByteStore) Truncate(newLen int64) error
- func (r *ByteStore) Write(bs []byte) (int, error)
- func (r *ByteStore) WriteByte(b byte) error
- func (r *ByteStore) WriteByteAt(dest int64, b byte) error
- func (r *ByteStore) WriteBytesAt(ctx context.Context, dest int64, bs []byte) error
- func (r *ByteStore) WriteInt32(pos int64, value int32) error
- func (r *ByteStore) WriteToDataOutput(out store.DataOutput) error
- type BytesReader
- type CompiledNode
- type Enum
- func (b *Enum[T]) Current() *KV[T]
- func (b *Enum[T]) GetCurrentLabel(upto int) int
- func (b *Enum[T]) GetTargetLabel(upto int) int
- func (b *Enum[T]) Grow()
- func (b *Enum[T]) Next(ctx context.Context) (*KV[T], error)
- func (b *Enum[T]) SeekCeil(ctx context.Context, target []T) (*KV[T], bool, error)
- func (b *Enum[T]) SeekExact(ctx context.Context, target []T) (*KV[T], bool, error)
- func (b *Enum[T]) SeekFloor(ctx context.Context, target []T) (*KV[T], bool, error)
- func (b *Enum[T]) SetCurrentLabel(label int) error
- type FST
- func NewFST(inputType InputType, outputM OutputManager, bytesPageBits int) *FST
- func NewFSTFromFile(ctx context.Context, path string, outputs OutputManager) (*FST, error)
- func NewFstV1(ctx context.Context, manager OutputManager, metaIn, in store.DataInput) (*FST, error)
- func NewFstV2(ctx context.Context, manager OutputManager, fstStore Store, ...) (*FST, error)
- func (f *FST) AddNode(ctx context.Context, builder *Builder, nodeIn *UnCompiledNode) (int64, error)
- func (f *FST) FindTarget(ctx context.Context, labelToMatch int, current *Arc, in BytesReader) (*Arc, bool, error)
- func (f *FST) FindTargetArc(ctx context.Context, labelToMatch int, in BytesReader, follow, arc *Arc) (*Arc, bool, error)
- func (f *FST) Finish(newStartNode int64) error
- func (f *FST) GetBytesReader() (BytesReader, error)
- func (f *FST) GetFirstArc(arc *Arc) (*Arc, error)
- func (f *FST) ReadArcByDirectAddressing(ctx context.Context, in BytesReader, rangeIndex int, arc *Arc) (*Arc, error)
- func (f *FST) ReadArcByIndex(ctx context.Context, in BytesReader, idx int, arc *Arc) (*Arc, error)
- func (f *FST) ReadFirstRealTargetArc(ctx context.Context, nodeAddress int64, in BytesReader, arc *Arc) (*Arc, error)
- func (f *FST) ReadFirstTargetArc(ctx context.Context, in BytesReader, follow *Arc, arc *Arc) (*Arc, error)
- func (f *FST) ReadLabel(ctx context.Context, in store.DataInput) (int, error)
- func (f *FST) ReadLastArcByDirectAddressing(ctx context.Context, arc *Arc, in BytesReader) (*Arc, error)
- func (f *FST) ReadNextArc(ctx context.Context, arc *Arc, in BytesReader) (*Arc, error)
- func (f *FST) ReadNextRealArc(ctx context.Context, in BytesReader, arc *Arc) (*Arc, error)
- func (f *FST) Save(ctx context.Context, metaOut store.DataOutput, out store.DataOutput) error
- func (f *FST) SaveToFile(ctx context.Context, path string) error
- func (f *FST) SetEmptyOutput(output Output) error
- type InputType
- type Int
- type IntBox
- func (b *IntBox[T]) Add(v Output) (Output, error)
- func (b *IntBox[T]) Common(v Output) (Output, error)
- func (b *IntBox[T]) Equal(v Output) bool
- func (b *IntBox[T]) Hash() int64
- func (b *IntBox[T]) IsNoOutput() bool
- func (b *IntBox[T]) Merge(v Output) (Output, error)
- func (b *IntBox[T]) Sub(v Output) (Output, error)
- func (b *IntBox[T]) Value() T
- type Ints
- type IntsManager
- func (r *IntsManager[T]) EmptyOutput() Output
- func (r *IntsManager[T]) New() Output
- func (r *IntsManager[T]) Read(ctx context.Context, in store.DataInput, v any) error
- func (r *IntsManager[T]) ReadFinalOutput(ctx context.Context, in store.DataInput, v any) error
- func (r *IntsManager[T]) SkipFinalOutput(ctx context.Context, in store.DataInput) error
- func (r *IntsManager[T]) SkipOutput(ctx context.Context, in store.DataInput) error
- func (r *IntsManager[T]) Write(ctx context.Context, out store.DataOutput, v any) error
- func (r *IntsManager[T]) WriteFinalOutput(ctx context.Context, out store.DataOutput, v any) error
- type KV
- type LabelManager
- type Node
- type NodeHash
- type OffHeapStore
- type OnHeapStore
- type Output
- type OutputBuilder
- type OutputManager
- type OutputReader
- type OutputWriter
- type Outputs
- type PendingArc
- type PostingOutput
- func (r *PostingOutput) Add(v Output) (Output, error)
- func (r *PostingOutput) Common(v Output) (Output, error)
- func (r *PostingOutput) Equal(v Output) bool
- func (r *PostingOutput) Hash() int64
- func (r *PostingOutput) IsNoOutput() bool
- func (r *PostingOutput) Merge(v Output) (Output, error)
- func (r *PostingOutput) Sub(v Output) (Output, error)
- type PostingOutputManager
- func (p *PostingOutputManager) EmptyOutput() Output
- func (p *PostingOutputManager) New() Output
- func (p *PostingOutputManager) Read(ctx context.Context, in store.DataInput, v any) error
- func (p *PostingOutputManager) ReadFinalOutput(ctx context.Context, in store.DataInput, v any) error
- func (p *PostingOutputManager) SkipFinalOutput(ctx context.Context, in store.DataInput) error
- func (p *PostingOutputManager) SkipOutput(ctx context.Context, in store.DataInput) error
- func (p *PostingOutputManager) Write(ctx context.Context, out store.DataOutput, v any) error
- func (p *PostingOutputManager) WriteFinalOutput(ctx context.Context, out store.DataOutput, v any) error
- type ReverseBytesReader
- func (r *ReverseBytesReader) Clone() store.CloneReader
- func (r *ReverseBytesReader) GetPosition() int64
- func (r *ReverseBytesReader) Read(b []byte) (int, error)
- func (r *ReverseBytesReader) ReadByte() (byte, error)
- func (r *ReverseBytesReader) Reversed() bool
- func (r *ReverseBytesReader) SetPosition(pos int64) error
- func (r *ReverseBytesReader) SkipBytes(ctx context.Context, numBytes int) error
- type ReverseRandomAccessReader
- func (r *ReverseRandomAccessReader) Clone() store.CloneReader
- func (r *ReverseRandomAccessReader) GetPosition() int64
- func (r *ReverseRandomAccessReader) Read(b []byte) (int, error)
- func (r *ReverseRandomAccessReader) ReadByte() (byte, error)
- func (r *ReverseRandomAccessReader) Reversed() bool
- func (r *ReverseRandomAccessReader) SetPosition(pos int64) error
- func (r *ReverseRandomAccessReader) SkipBytes(ctx context.Context, numBytes int) error
- type Store
- type UnCompiledNode
- func (u *UnCompiledNode) AddArc(label int, target Node)
- func (u *UnCompiledNode) Clear()
- func (u *UnCompiledNode) Code() int64
- func (u *UnCompiledNode) DeleteLast(ctx context.Context, label int, target Node) error
- func (u *UnCompiledNode) GetLastOutput() Output
- func (u *UnCompiledNode) IsCompiled() bool
- func (u *UnCompiledNode) NumArcs() int
- func (u *UnCompiledNode) PrependOutput(outputPrefix Output) error
- func (u *UnCompiledNode) ReplaceLast(labelToMatch int, target Node, nextFinalOutput Output, isFinal bool) error
- func (u *UnCompiledNode) SetLastOutput(ctx context.Context, label int, newOutput Output) error
Constants ¶
const ( BYTE_SIZE = 8 INTEGER_SIZE = 32 LONG_SIZE = 64 LONG_BYTES = 8 )
const ( BitFinalArc = 1 << 0 BitLastArc = 1 << 1 BitTargetNext = 1 << 2 BitStopNode = 1 << 3 BitArcHasOutput = 1 << 4 // This flag is set if the arc has an output. BitArcHasFinalOutput = 1 << 5 // ArcsForBinarySearch // value of the arc flags to declare a node with fixed length arcs designed for binary search. // We use this as a marker because this one flag is illegal by itself. ArcsForBinarySearch = BitArcHasFinalOutput // ArcsForDirectAddressing // value of the arc flags to declare a node with fixed length arcs and bit table designed for direct addressing. ArcsForDirectAddressing = 1 << 6 )
const ( DEFAULT_MAX_BLOCK_BITS = 30 INTEGER_BYTES = 4 BYTE1 = InputType(iota) BYTE2 BYTE4 // FIXED_LENGTH_ARC_SHALLOW_DEPTH // See Also: shouldExpandNodeWithFixedLengthArcs // 0 => only root node. FIXED_LENGTH_ARC_SHALLOW_DEPTH = 3 // FIXED_LENGTH_ARC_SHALLOW_NUM_ARCS // See Also: shouldExpandNodeWithFixedLengthArcs FIXED_LENGTH_ARC_SHALLOW_NUM_ARCS = 5 // FIXED_LENGTH_ARC_DEEP_NUM_ARCS // See Also: shouldExpandNodeWithFixedLengthArcs FIXED_LENGTH_ARC_DEEP_NUM_ARCS = 10 // DIRECT_ADDRESSING_MAX_OVERSIZE_WITH_CREDIT_FACTOR // Maximum oversizing factor allowed for direct addressing compared to binary search // when expansion credits allow the oversizing. This factor prevents expansions // that are obviously too costly even if there are sufficient credits. // See Also: shouldExpandNodeWithDirectAddressing DIRECT_ADDRESSING_MAX_OVERSIZE_WITH_CREDIT_FACTOR = 1.66 FILE_FORMAT_NAME = "FST" VERSION_START = 6 VERSION_CURRENT = 7 // FINAL_END_NODE // Never serialized; just used to represent the virtual // final node w/ no arcs: FINAL_END_NODE = -1 // NON_FINAL_END_NODE // Never serialized; just used to represent the virtual // non-final node w/ no arcs: NON_FINAL_END_NODE = 0 // END_LABEL // If arc has this label then that arc is final/accepted END_LABEL = -1 )
const DIRECT_ADDRESSING_MAX_OVERSIZING_FACTOR = 1.0
DIRECT_ADDRESSING_MAX_OVERSIZING_FACTOR Default oversizing factor used to decide whether to encode a node with direct addressing or binary search. Default is 1: ensure no oversizing on average. This factor does not determine whether to encode a node with a list of variable length arcs or with fixed length arcs. It only determines the effective encoding of a node that is already known to be encoded with fixed length arcs. See Fst.shouldExpandNodeWithFixedLengthArcs() and Fst.shouldExpandNodeWithDirectAddressing(). For English words we measured 217K nodes, only 3.27% nodes are encoded with fixed length arcs, and 99.99% of them with direct addressing. Overall FST memory reduced by 1.67%. For worst case we measured 168K nodes, 50% of them are encoded with fixed length arcs, and 14% of them with direct encoding. Overall FST memory reduced by 0.8%. Use TestFstDirectAddressing.main() and TestFstDirectAddressing.testWorstCaseForDirectAddressing() to evaluate a change. see: setDirectAddressingMaxOversizingFactor
const (
PRIME = int64(32)
)
Variables ¶
var ( ErrByteStoreBasic = errors.New("bytestore basic error") ErrItemNotFound = errors.Wrap(ErrByteStoreBasic, "item not found") )
Functions ¶
func CountBits ¶
func CountBits(arc *Arc, in BytesReader) (int, error)
CountBits See BitTableUtil.countBits(int, Fst.BytesReader). The count of bit set is the number of arcs of a direct addressing node.
func CountBitsUpTo ¶
func CountBitsUpTo(bitIndex int, arc *Arc, in BytesReader) (int, error)
CountBitsUpTo See BitTableUtil.countBitsUpTo(int, Fst.BytesReader).
func NextBitSet ¶
NextBitSet See BitTableUtil.NextBitSet(int, int, Fst.BytesReader).
func PreviousBitSet ¶
func PreviousBitSet(bitIndex int, arc *Arc, in BytesReader) (int, error)
PreviousBitSet See BitTableUtil.previousBitSet(int, Fst.BytesReader).
func TargetHasArcs ¶
TargetHasArcs returns true if the node at this address has any outgoing arcs
Types ¶
type AbsEnum ¶
type AbsEnum interface { GetUpTo() int GetOutput(idx int) Output SetTargetLength(size int) DoNext(ctx context.Context, lm LabelManager) error DoSeekCeil(ctx context.Context, lm LabelManager) error DoSeekFloor(ctx context.Context, lm LabelManager) error DoSeekExact(ctx context.Context, lm LabelManager) (bool, error) }
type Arc ¶
type Arc struct {
// contains filtered or unexported fields
}
Arc Represents a single arc.
func (*Arc) BytesPerArc ¶
BytesPerArc Non-zero if this arc is part of a node with fixed length arcs, which means all arcs for the node are encoded with a fixed number of bytes so that we binary search or direct address. We do when there are enough arcs leaving one node. It wastes some bytes but gives faster lookups.
func (*Arc) FirstLabel ¶
FirstLabel First label of a direct addressing node. Only valid if nodeFlags == ArcsForDirectAddressing.
func (*Arc) NextArc ¶
NextArc Address (into the byte[]) of the next arc - only for list of variable length arc. Or ord/address to the next node if label == END_LABEL.
func (*Arc) NextFinalOutput ¶
func (*Arc) NodeFlags ¶
NodeFlags Node header flags. Only meaningful to check if the value is either ArcsForBinarySearch or ArcsForDirectAddressing (other value when bytesPerArc == 0).
func (*Arc) NumArcs ¶
NumArcs How many arcs; only valid if bytesPerArc != 0 (fixed length arcs). For a node designed for binary search this is the array size. For a node designed for direct addressing, this is the label range.
func (*Arc) PosArcsStart ¶
PosArcsStart Where the first arc in the array starts; only valid if bytesPerArc != 0
type BoxManager ¶
type BoxManager[T Int] struct { // contains filtered or unexported fields }
func NewBoxManager ¶
func NewBoxManager[T Int]() *BoxManager[T]
func (*BoxManager[T]) EmptyOutput ¶
func (b *BoxManager[T]) EmptyOutput() Output
func (*BoxManager[T]) New ¶
func (b *BoxManager[T]) New() Output
func (*BoxManager[T]) ReadFinalOutput ¶
func (*BoxManager[T]) SkipFinalOutput ¶
func (*BoxManager[T]) SkipOutput ¶
func (*BoxManager[T]) Write ¶
func (b *BoxManager[T]) Write(ctx context.Context, out store.DataOutput, v any) error
func (*BoxManager[T]) WriteFinalOutput ¶
func (b *BoxManager[T]) WriteFinalOutput(ctx context.Context, out store.DataOutput, v any) error
type Buffer ¶
func (*Buffer) WriteUvarint ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder Builds a minimal FST (maps a term([]int) to an arbitrary output) from pre-sorted terms with output. The FST becomes an FSA if you use NoOutputs. The FST is written on-the-fly into a compact serialized format byte array, which can be saved to / loaded from a Directory or used directly for traversal. The FST is always finite (no cycles).
NOTE: The algorithm is described at http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.24.3698
The parameterized type T is the output type. See the subclasses of Output.
FSTs larger than 2.1GB are now possible (as of Lucene 4.2). FSTs containing more than 2.1B nodes are also now possible, however they cannot be packed.
lucene.experimental
func NewBuilder ¶
func NewBuilder(inputType InputType, manager OutputManager, options ...BuilderOption) (*Builder, error)
NewBuilder Instantiates an FST/FSA builder without any pruning. A shortcut to Builder(Fst.INPUT_TYPE, int, int, boolean, boolean, int, Output, boolean, int) with pruning options turned off.
func (*Builder) Finish ¶
Finish Returns final FST. NOTE: this will return null if nothing is accepted by the FST.
func (*Builder) GetArcCount ¶
func (*Builder) GetDirectAddressingMaxOversizingFactor ¶
func (*Builder) GetNodeCount ¶
func (*Builder) GetTermCount ¶
func (*Builder) SetDirectAddressingMaxOversizingFactor ¶
SetDirectAddressingMaxOversizingFactor Overrides the default the maximum oversizing of fixed array allowed to enable direct addressing of arcs instead of binary search. Setting this factor to a negative value (e.g. -1) effectively disables direct addressing, only binary search nodes will be created. DIRECT_ADDRESSING_MAX_OVERSIZING_FACTOR
type BuilderOption ¶
type BuilderOption func(option *builderOption)
func WithAllowFixedLengthArcs ¶
func WithAllowFixedLengthArcs(allowFixedLengthArcs bool) BuilderOption
func WithBytesPageBits ¶
func WithBytesPageBits(bytesPageBits int) BuilderOption
func WithDoShareNonSingletonNodes ¶
func WithDoShareNonSingletonNodes(doShareNonSingletonNodes bool) BuilderOption
func WithDoShareSuffix ¶
func WithDoShareSuffix(doShareSuffix bool) BuilderOption
func WithMinSuffixCount1 ¶
func WithMinSuffixCount1(minSuffixCount1 int) BuilderOption
func WithMinSuffixCount2 ¶
func WithMinSuffixCount2(minSuffixCount2 int) BuilderOption
func WithShareMaxTailLength ¶
func WithShareMaxTailLength(shareMaxTailLength int) BuilderOption
type ByteStore ¶
type ByteStore struct { *store.BaseDataOutput // contains filtered or unexported fields }
func NewByteStore ¶
func (*ByteStore) GetBlockBits ¶
func (*ByteStore) GetPosition ¶
func (*ByteStore) GetReverseReader ¶
func (r *ByteStore) GetReverseReader() (BytesReader, error)
func (*ByteStore) MoveBytes ¶
MoveBytes Absolute copy bytes self to self, without changing the position. Note: this cannot "grow" the bytes, so must only call it on already written parts.
func (*ByteStore) Truncate ¶
Truncate Pos must be less than the max position written so far! Ie, you cannot "grow" the file with this!
func (*ByteStore) WriteByteAt ¶
WriteByteAt Absolute write byte; you must ensure dest is < max position written so far.
func (*ByteStore) WriteBytesAt ¶
WriteBytesAt Absolute writeBytes without changing the current position. Note: this cannot "grow" the bytes, so you must only call it on already written parts.
func (*ByteStore) WriteInt32 ¶
WriteInt32 Writes an int at the absolute position without changing the current pointer.
func (*ByteStore) WriteToDataOutput ¶
func (r *ByteStore) WriteToDataOutput(out store.DataOutput) error
WriteToDataOutput Writes all of our bytes to the target DataOutput.
type BytesReader ¶
type BytesReader interface { store.DataInput // GetPosition Get current read position. GetPosition() int64 // SetPosition Set current read position. SetPosition(pos int64) error // Reversed Returns true if this reader uses reversed bytes under-the-hood. Reversed() bool }
BytesReader Reads bytes stored in an FST.
type CompiledNode ¶
type CompiledNode struct {
// contains filtered or unexported fields
}
func NewCompiledNode ¶
func NewCompiledNode() *CompiledNode
func (*CompiledNode) Code ¶
func (r *CompiledNode) Code() int64
func (*CompiledNode) IsCompiled ¶
func (*CompiledNode) IsCompiled() bool
type Enum ¶
Enum Enumerates all input (BytesRef) + output pairs in an FST. lucene.experimental
func (*Enum[T]) GetCurrentLabel ¶
func (*Enum[T]) GetTargetLabel ¶
func (*Enum[T]) SeekExact ¶
SeekExact Seeks to exactly this term, returning null if the term doesn't exist. This is faster than using seekFloor or seekCeil because it short-circuits as soon the match is not found.
func (*Enum[T]) SetCurrentLabel ¶
type FST ¶
type FST struct {
// contains filtered or unexported fields
}
func NewFSTFromFile ¶
NewFSTFromFile Reads an automaton from a file.
func NewFstV2 ¶
func NewFstV2(ctx context.Context, manager OutputManager, fstStore Store, metaIn, in store.DataInput) (*FST, error)
NewFstV2 Load a previously saved FST; maxBlockBits allows you to control the size of the byte[] pages used to hold the FST bytes.
func (*FST) AddNode ¶
AddNode serializes new node by appending its bytes to the end of the current byte[]
func (*FST) FindTarget ¶
func (*FST) FindTargetArc ¶
func (f *FST) FindTargetArc(ctx context.Context, labelToMatch int, in BytesReader, follow, arc *Arc) (*Arc, bool, error)
FindTargetArc Finds an arc leaving the incoming arc, replacing the arc in place. This returns null if the arc was not found, else the incoming arc. 查找follow后满足label=${labelToMatch}的Arc
func (*FST) GetBytesReader ¶
func (f *FST) GetBytesReader() (BytesReader, error)
GetBytesReader Returns a Fst.BytesReader for this FST, positioned at position 0.
func (*FST) GetFirstArc ¶
GetFirstArc Fills virtual 'start' arc, ie, an empty incoming arc to the FST's start node
func (*FST) ReadArcByDirectAddressing ¶
func (f *FST) ReadArcByDirectAddressing(ctx context.Context, in BytesReader, rangeIndex int, arc *Arc) (*Arc, error)
ReadArcByDirectAddressing Reads a present direct addressing node arc, with the provided index in the label range. rangeIndex: The index of the arc in the label range. It must be present. The real arc offset is computed based on the presence bits of the direct addressing node.
func (*FST) ReadArcByIndex ¶
func (*FST) ReadFirstRealTargetArc ¶
func (*FST) ReadFirstTargetArc ¶
func (f *FST) ReadFirstTargetArc(ctx context.Context, in BytesReader, follow *Arc, arc *Arc) (*Arc, error)
ReadFirstTargetArc Follow the follow arc and read the first arc of its target; this changes the provided arc (3rd arg) in-place and returns it. Returns: Returns the second argument (arc).
func (*FST) ReadLastArcByDirectAddressing ¶
func (f *FST) ReadLastArcByDirectAddressing(ctx context.Context, arc *Arc, in BytesReader) (*Arc, error)
ReadLastArcByDirectAddressing Reads the last arc of a direct addressing node. This method is equivalent to call readArcByDirectAddressing(Fst.Arc, Fst.BytesReader, int) with rangeIndex equal to arc.numArcs() - 1, but it is faster.
func (*FST) ReadNextArc ¶
ReadNextArc In-place read; returns the arc.
func (*FST) ReadNextRealArc ¶
ReadNextRealArc Never returns null, but you should never call this if arc.isLast() is true.
func (*FST) Save ¶
func (f *FST) Save(ctx context.Context, metaOut store.DataOutput, out store.DataOutput) error
func (*FST) SetEmptyOutput ¶
type IntBox ¶
type IntBox[T Int] struct { // contains filtered or unexported fields }
func (*IntBox[T]) IsNoOutput ¶
type IntsManager ¶
type IntsManager[T Int] struct { // contains filtered or unexported fields }
func NewIntsManager ¶
func NewIntsManager[T Int](size int) *IntsManager[T]
func (*IntsManager[T]) EmptyOutput ¶
func (r *IntsManager[T]) EmptyOutput() Output
func (*IntsManager[T]) New ¶
func (r *IntsManager[T]) New() Output
func (*IntsManager[T]) ReadFinalOutput ¶
func (*IntsManager[T]) SkipFinalOutput ¶
func (*IntsManager[T]) SkipOutput ¶
func (*IntsManager[T]) Write ¶
func (r *IntsManager[T]) Write(ctx context.Context, out store.DataOutput, v any) error
func (*IntsManager[T]) WriteFinalOutput ¶
func (r *IntsManager[T]) WriteFinalOutput(ctx context.Context, out store.DataOutput, v any) error
type LabelManager ¶
type NodeHash ¶
type NodeHash struct {
// contains filtered or unexported fields
}
NodeHash Used to dedup states (lookup already-frozen states)
func NewNodeHash ¶
func NewNodeHash(fst *FST, in BytesReader) *NodeHash
type OffHeapStore ¶
type OffHeapStore struct {
// contains filtered or unexported fields
}
OffHeapStore Provides off heap storage of finite state machine (FST), using underlying index input instead of byte store on heap
func (*OffHeapStore) GetReverseBytesReader ¶
func (o *OffHeapStore) GetReverseBytesReader() (BytesReader, error)
func (*OffHeapStore) Size ¶
func (o *OffHeapStore) Size() int64
func (*OffHeapStore) WriteTo ¶
func (o *OffHeapStore) WriteTo(ctx context.Context, out store.DataOutput) error
type OnHeapStore ¶
type OnHeapStore struct {
// contains filtered or unexported fields
}
OnHeapStore Provides storage of finite state machine (FST), using byte array or byte store allocated on heap.
func NewOnHeapStore ¶
func NewOnHeapStore(maxBlockBits int) (*OnHeapStore, error)
func (*OnHeapStore) GetReverseBytesReader ¶
func (o *OnHeapStore) GetReverseBytesReader() (BytesReader, error)
func (*OnHeapStore) Size ¶
func (o *OnHeapStore) Size() int64
func (*OnHeapStore) WriteTo ¶
func (o *OnHeapStore) WriteTo(ctx context.Context, out store.DataOutput) error
type OutputBuilder ¶
type OutputManager ¶
type OutputManager interface { OutputBuilder OutputReader OutputWriter }
type OutputReader ¶
type OutputReader interface { // Read Decode an output value previously written with write(Object, DataOutput). Read(ctx context.Context, in store.DataInput, v any) error // SkipOutput Skip the output; defaults to just calling read and discarding the result. SkipOutput(ctx context.Context, in store.DataInput) error // ReadFinalOutput Decode an output value previously written with writeFinalOutput(Object, DataOutput). // By default this just calls read(DataInput). ReadFinalOutput(ctx context.Context, in store.DataInput, v any) error // SkipFinalOutput Skip the output previously written with writeFinalOutput; // defaults to just calling readFinalOutput and discarding the result. SkipFinalOutput(ctx context.Context, in store.DataInput) error }
type OutputWriter ¶
type OutputWriter interface { // Write Encode an output value into a DataOutput. Write(ctx context.Context, out store.DataOutput, v any) error // WriteFinalOutput Encode an final node output value into a DataOutput. // By default this just calls write(Object, DataOutput). WriteFinalOutput(ctx context.Context, out store.DataOutput, v any) error }
type Outputs ¶
type Outputs[T any] interface { // Common Eg common("foobar", "food") -> "foo" Common(output1, output2 T) (T, error) // Subtract Eg sub("foobar", "foo") -> "bar" Subtract(output1, inc T) (T, error) // Add Eg add("foo", "bar") -> "foobar" Add(prefix, output T) (T, error) // Write Encode an output value into a DataOutput. Write(output T, out store.DataOutput) error // WriteFinalOutput Encode an final node output value into a DataOutput. // By default this just calls write(Object, DataOutput). WriteFinalOutput(output T, out store.DataOutput) error // Read Decode an output value previously written with write(Object, DataOutput). Read(in store.DataInput) (T, error) // SkipOutput Skip the output; defaults to just calling read and discarding the result. SkipOutput(in store.DataInput) error // ReadFinalOutput Decode an output value previously written with writeFinalOutput(Object, DataOutput). // By default this just calls read(DataInput). ReadFinalOutput(in store.DataInput) (T, error) // SkipFinalOutput Skip the output previously written with writeFinalOutput; // defaults to just calling readFinalOutput and discarding the result. SkipFinalOutput(in store.DataInput) error IsNoOutput(v T) bool GetNoOutput() T Merge(first, second T) (T, error) }
Outputs Represents the output for an FST, providing the basic algebra required for building and traversing the FST. Note that any operation that returns noOutput must return the same singleton object from getNoOutput. lucene.experimental
type PendingArc ¶
PendingArc Expert: holds a pending (seen but not yet serialized) arc.
type PostingOutput ¶
type PostingOutput struct { LastDocsStart int64 SkipPointer int64 DocFreq int64 TotalTermFreq int64 }
func NewPostingOutput ¶
func NewPostingOutput(lastDocsStart, skipPointer, docFreq, totalTermFreq int64) *PostingOutput
func (*PostingOutput) Equal ¶
func (r *PostingOutput) Equal(v Output) bool
func (*PostingOutput) Hash ¶
func (r *PostingOutput) Hash() int64
func (*PostingOutput) IsNoOutput ¶
func (r *PostingOutput) IsNoOutput() bool
type PostingOutputManager ¶
type PostingOutputManager struct {
// contains filtered or unexported fields
}
func NewPostingOutputManager ¶
func NewPostingOutputManager() *PostingOutputManager
func (*PostingOutputManager) EmptyOutput ¶
func (p *PostingOutputManager) EmptyOutput() Output
func (*PostingOutputManager) New ¶
func (p *PostingOutputManager) New() Output
func (*PostingOutputManager) ReadFinalOutput ¶
func (*PostingOutputManager) SkipFinalOutput ¶
func (*PostingOutputManager) SkipOutput ¶
func (*PostingOutputManager) Write ¶
func (p *PostingOutputManager) Write(ctx context.Context, out store.DataOutput, v any) error
func (*PostingOutputManager) WriteFinalOutput ¶
func (p *PostingOutputManager) WriteFinalOutput(ctx context.Context, out store.DataOutput, v any) error
type ReverseBytesReader ¶
type ReverseBytesReader struct { *store.BaseDataInput // contains filtered or unexported fields }
func (*ReverseBytesReader) Clone ¶
func (r *ReverseBytesReader) Clone() store.CloneReader
func (*ReverseBytesReader) GetPosition ¶
func (r *ReverseBytesReader) GetPosition() int64
func (*ReverseBytesReader) ReadByte ¶
func (r *ReverseBytesReader) ReadByte() (byte, error)
func (*ReverseBytesReader) Reversed ¶
func (r *ReverseBytesReader) Reversed() bool
func (*ReverseBytesReader) SetPosition ¶
func (r *ReverseBytesReader) SetPosition(pos int64) error
type ReverseRandomAccessReader ¶
type ReverseRandomAccessReader struct { *store.BaseDataInput // contains filtered or unexported fields }
func (*ReverseRandomAccessReader) Clone ¶
func (r *ReverseRandomAccessReader) Clone() store.CloneReader
func (*ReverseRandomAccessReader) GetPosition ¶
func (r *ReverseRandomAccessReader) GetPosition() int64
func (*ReverseRandomAccessReader) Read ¶
func (r *ReverseRandomAccessReader) Read(b []byte) (int, error)
func (*ReverseRandomAccessReader) ReadByte ¶
func (r *ReverseRandomAccessReader) ReadByte() (byte, error)
func (*ReverseRandomAccessReader) Reversed ¶
func (r *ReverseRandomAccessReader) Reversed() bool
func (*ReverseRandomAccessReader) SetPosition ¶
func (r *ReverseRandomAccessReader) SetPosition(pos int64) error
type Store ¶
type Store interface { Init(in io.Reader, numBytes int64) error Size() int64 GetReverseBytesReader() (BytesReader, error) WriteTo(ctx context.Context, out store.DataOutput) error }
Store Abstraction for reading/writing bytes necessary for FST.
type UnCompiledNode ¶
type UnCompiledNode struct { Arcs []*PendingArc Output Output IsFinal bool InputCount int Depth int // This node's depth, starting from the automaton root. // contains filtered or unexported fields }
UnCompiledNode TODO: instead of recording isFinal/output on the node, maybe we should use -1 arc to mean "end" (like we do when reading the FST). Would simplify much code here...
func NewUnCompiledNode ¶
func NewUnCompiledNode(builder *Builder, depth int) *UnCompiledNode
func (*UnCompiledNode) AddArc ¶
func (u *UnCompiledNode) AddArc(label int, target Node)
func (*UnCompiledNode) Clear ¶
func (u *UnCompiledNode) Clear()
func (*UnCompiledNode) Code ¶
func (u *UnCompiledNode) Code() int64
func (*UnCompiledNode) DeleteLast ¶
DeleteLast 移除目标arc
func (*UnCompiledNode) GetLastOutput ¶
func (u *UnCompiledNode) GetLastOutput() Output
func (*UnCompiledNode) IsCompiled ¶
func (u *UnCompiledNode) IsCompiled() bool
func (*UnCompiledNode) NumArcs ¶
func (u *UnCompiledNode) NumArcs() int
func (*UnCompiledNode) PrependOutput ¶
func (u *UnCompiledNode) PrependOutput(outputPrefix Output) error
PrependOutput pushes an output prefix forward onto all arcs 所有的边都增加一个output前缀
func (*UnCompiledNode) ReplaceLast ¶
func (u *UnCompiledNode) ReplaceLast(labelToMatch int, target Node, nextFinalOutput Output, isFinal bool) error
ReplaceLast 替换最后的arc的内部数据
func (*UnCompiledNode) SetLastOutput ¶
SetLastOutput 设置最后arc的output对象