Documentation ¶
Index ¶
- Constants
- type BufferStream
- type DlSymbol
- type Extractor
- func (ego *Extractor) AddMinerSo(sodir string, symbol string, params []byte) error
- func (ego *Extractor) Destroy() error
- func (ego *Extractor) Eof() bool
- func (ego *Extractor) GetLastError() error
- func (ego *Extractor) Meta() []DlSymbol
- func (ego *Extractor) Next() (Occurrencer, error)
- func (ego *Extractor) SetFlags(flags uint32) error
- func (ego *Extractor) SetStream(stream Streamer) error
- func (ego *Extractor) UnsetFlags(flags uint32) error
- func (ego *Extractor) UnsetStream()
- type FileStream
- type Occurrence
- func (ego *Occurrence) Eof() bool
- func (ego *Occurrence) Label() string
- func (ego *Occurrence) Len() uint32
- func (ego *Occurrence) Next()
- func (ego *Occurrence) Pos() uint64
- func (ego *Occurrence) Prob() float64
- func (ego *Occurrence) Str() string
- func (ego *Occurrence) Ulen() uint32
- func (ego *Occurrence) Upos() uint64
- type Occurrencer
- type Streamer
Constants ¶
const ( // Disables enclosed occurrence feature. E_NO_ENCLOSED_OCCURRENCES = 1 << 0 // Enables results ascending sorting of occurrence records. E_SORT_RESULTS = 1 << 1 )
Constants for valid NativeExtractor flags.
const DEFAULT_MINERS_PATH = "/usr/lib/nativeextractor_miners"
Default path to .so libs representing miners.
const POINTER_SIZE = bits.UintSize / 8
Size of pointer in bytes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferStream ¶
type BufferStream struct { Buffer []byte Ptr *C.struct_stream_buffer_c }
Structure representing buffer over heap memory.
func NewBufferStream ¶
func NewBufferStream(buffer []byte) (*BufferStream, error)
Creates a new BufferStream.
Parameters:
- buffer - byte array for stream initialization (has to be terminated with \x00).
Returns:
- pointer to a new instance of BufferStream.
- error if any occurred, nil otherwise.
func (*BufferStream) Check ¶
func (ego *BufferStream) Check() bool
Checks if an error occurred in a BufferStream.
Returns:
- true if an error occurred, false otherwise.
func (*BufferStream) Close ¶
func (ego *BufferStream) Close() error
Closes a BufferStream.
Returns:
- error if the stream has been already closed, nil otherwise.
func (*BufferStream) GetStream ¶
func (ego *BufferStream) GetStream() *C.struct_stream_c
Gets the inner stream structure.
Returns:
- pointer to the C struct stream_c.
type DlSymbol ¶
type DlSymbol struct { // Path to the .so library Ldpath string // Miner function name Ldsymb string // Meta info about miner functions and labels Meta []string // Miner params Params string // Pointer to the loaded .so library Ldptr unsafe.Pointer }
Structure with information about a miner.
type Extractor ¶
type Extractor struct {
// contains filtered or unexported fields
}
Analyzes next batch with miners.
func NewExtractor ¶
Creates a new Extractor. Has to be deallocated with 'Destroy' method after use.
Parameters:
- batch - number of logical symbols to be analyzed in the stream (if negative, defaults to 2^16),
- threads - number of threads for miners to run on (if negative, defaults to maximum threads available),
- flags - initial flags.
Returns:
- pointer to a new instance of Extractor.
func (*Extractor) AddMinerSo ¶
Loads a Miner from a Shared Object (.so library).
Parameters:
- sodir - a path to the shared object,
- symbol - shared object symbol,
- params - optional (may be empty array or nil, but if present, has to be terminated with \x00).
Returns:
- error if any occurred, nil otherwise.
func (*Extractor) Destroy ¶
Destroys the Extractor.
Returns:
- error if the extractor has been already closed, nil otherwise.
func (*Extractor) Eof ¶
Checks if the stream attached to the Extractor ended.
Returns:
- true if there is nothing to read (stream ended or no stream set), false otherwise.
func (*Extractor) GetLastError ¶
Gives the last error which occurred in Extractor.
Returns:
- error, nil if no error occurred.
func (*Extractor) Meta ¶
Gives the meta information about Extractor.
Returns:
- slice of structures with information about miners.
func (*Extractor) Next ¶
func (ego *Extractor) Next() (Occurrencer, error)
Gives the next batch of found entities.
Returns:
- the first found occurrence,
- error, if any occurred.
func (*Extractor) SetFlags ¶
Sets NativeExtractor flags.
Parameters:
- flags - use constants defined above.
Returns:
- error if any occurred, nil otherwise.
func (*Extractor) SetStream ¶
Sets a stream to the Extractor.
Parameters:
- stream - an instance of Streamer interface.
Returns:
- error if any occurred, nil otherwise.
func (*Extractor) UnsetFlags ¶
Unsets NativeExtractor flags.
Parameters:
- flags - use constants defined above.
Returns:
- error if any occurred, nil otherwise.
func (*Extractor) UnsetStream ¶
func (ego *Extractor) UnsetStream()
Dettaches the stream from the Extractor.
type FileStream ¶
type FileStream struct { Ptr *C.struct_stream_file_c Path string }
Structure representing stream from file.
func NewFileStream ¶
func NewFileStream(path string) (*FileStream, error)
Creates a new FileStream.
Parameters:
- path - path to a file.
Returns:
- pointer to a new instance of FileStream.
- error if any occurred, nil otherwise.
func (*FileStream) Check ¶
func (ego *FileStream) Check() bool
Checks if an error occurred in a FileStream.
Returns:
- true if an error occurred, false otherwise.
func (*FileStream) Close ¶
func (ego *FileStream) Close() error
Closes a FileStream.
Returns:
- error if the stream has been already closed, nil otherwise.
func (*FileStream) GetStream ¶
func (ego *FileStream) GetStream() *C.struct_stream_c
Gets the inner stream structure.
Returns:
- pointer to the C struct stream_c.
type Occurrence ¶
type Occurrence struct {
// contains filtered or unexported fields
}
Struct implementing Occurrencer, contains a pointer to the current occurrence (C struct).
func (*Occurrence) Eof ¶
func (ego *Occurrence) Eof() bool
Checks if all occurrences have been read.
Returns:
- true if there is nothing to read (current pointer is nil), false otherwise.
func (*Occurrence) Label ¶
func (ego *Occurrence) Label() string
Casts label of the found occurrence to Go string.
Returns:
- label of the found entity.
func (*Occurrence) Len ¶
func (ego *Occurrence) Len() uint32
Casts length of the found occurrence to Go integer type.
Returns:
- length of the found occurrence (in bytes).
func (*Occurrence) Next ¶
func (ego *Occurrence) Next()
Moves the pointer to the next occurrence. If EOF, does nothing.
func (*Occurrence) Pos ¶
func (ego *Occurrence) Pos() uint64
Casts position of the found occurrence to Go integer type.
Returns:
- position of the found occurrence (in bytes).
func (*Occurrence) Prob ¶
func (ego *Occurrence) Prob() float64
Casts probability of the found occurrence to Go float type.
Returns:
- probability of the occurrence.
func (*Occurrence) Str ¶
func (ego *Occurrence) Str() string
Creates a string containing found occurrence.
Returns:
- found occurrence.
func (*Occurrence) Ulen ¶
func (ego *Occurrence) Ulen() uint32
Casts UTF length of the found occurrence to Go integer type.
Returns:
- length of the found occurrence (in unicode characters).
func (*Occurrence) Upos ¶
func (ego *Occurrence) Upos() uint64
Casts UTF position of the found occurrence to Go integer type.
Returns:
- position of the found occurrence (in unicode characters).