matn

package
v0.0.0-...-4a740ba Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRecordNil = er.New().SetDetail(lang.LanguageEnglish, errorEnglishDomain, "Record Nil",
		"Given record can't be nil").Save()

	ErrRecordNotValid = er.New().SetDetail(lang.LanguageEnglish, errorEnglishDomain, "Record Not Valid",
		"Given recordID exist in storage devices but has diffrent StructureID").Save()

	ErrRecordNotExist = er.New().SetDetail(lang.LanguageEnglish, errorEnglishDomain, "Record Not Exist",
		"Given recordID not exist in any storage devices").Save()

	ErrRecordManipulated = er.New().SetDetail(lang.LanguageEnglish, errorEnglishDomain, "Record Manipulated",
		"Index record has problem when engine try to read it from storage devices").Save()
)

Errors

Functions

func PhraseTokenization

func PhraseTokenization(text string) (tokenized []string)

PhraseTokenization uses the delimiters categorized under [Dash, Hyphen, Pattern_Syntax, Quotation_Mark, Terminal_Punctuation, White_Space] drop language-specific stop words (e.g. in English, the, an, a, and, etc.)

func TextIndexSet

func TextIndexSet(req *TextIndexSetReq) (err *er.Error)

TextIndexSet index given text

func WordTokenization

func WordTokenization(req *TextIndexSetReq) (indexes map[string]*IndexWord)

WordTokenization uses the delimiters categorized under [Dash, Hyphen, Pattern_Syntax, Quotation_Mark, Terminal_Punctuation, White_Space] https://github.com/jdkato/prose

Types

type IndexPhrase

type IndexPhrase struct {
	/* Common header data */
	RecordID          [32]byte
	RecordStructureID uint64
	RecordSize        uint64
	WriteTime         etime.Time
	OwnerAppID        [32]byte

	/* Unique data */
	Terms      []string `index-hash:"RecordID[pair,PageNumber]"` // Array must be order to retrievable!
	PageNumber uint64
	Tokens     [10]PhraseToken // Order of PhraseTokens index changed by algorithm in exact period of time!
}

IndexPhrase is standard structure to store any hash byte index!! It is simple secondary index e.g. hash("user@email.com")

func (*IndexPhrase) FindRecordsIDByTermsPageNumber

func (ip *IndexPhrase) FindRecordsIDByTermsPageNumber(offset, limit uint64) (RecordsID [][32]byte, err *er.Error)

FindRecordsIDByTermsPageNumber find RecordsID by given Terms+PageNumber

func (*IndexPhrase) GetByRecordID

func (ip *IndexPhrase) GetByRecordID() (err *er.Error)

GetByRecordID method read all existing record data by given RecordID!

func (*IndexPhrase) IndexRecordIDForTermsPageNumber

func (ip *IndexPhrase) IndexRecordIDForTermsPageNumber()

IndexRecordIDForTermsPageNumber save RecordID chain for Terms+PageNumber Call in each update to the exiting record!

func (*IndexPhrase) SaveNew

func (ip *IndexPhrase) SaveNew() (err *er.Error)

SaveNew method set some data and write entire IndexPhrase record with all indexes!

func (*IndexPhrase) Set

func (ip *IndexPhrase) Set() (err *er.Error)

Set method set some data and write entire IndexPhrase record!

type IndexTextFindReq

type IndexTextFindReq struct {
	Term            string
	RecordStructure uint64
	PageNumber      uint64
}

IndexTextFindReq is request structure of IndexTextFind()

func (*IndexTextFindReq) JSONDecoder

func (req *IndexTextFindReq) JSONDecoder(buf []byte) (err *er.Error)

JSONDecoder decode json to given IndexTextFindReq

func (*IndexTextFindReq) JSONEncoder

func (req *IndexTextFindReq) JSONEncoder() (buf []byte)

JSONEncoder encode given IndexTextFindReq to json format.

func (*IndexTextFindReq) JSONLen

func (req *IndexTextFindReq) JSONLen() (ln int)

JSONLen return json needed len to encode!

func (*IndexTextFindReq) SyllabDecoder

func (req *IndexTextFindReq) SyllabDecoder(buf []byte) (err *er.Error)

SyllabDecoder decode syllab to given IndexTextFindReq

func (*IndexTextFindReq) SyllabEncoder

func (req *IndexTextFindReq) SyllabEncoder(buf []byte)

SyllabEncoder encode given IndexTextFindReq to syllab format

func (*IndexTextFindReq) SyllabHeapLen

func (req *IndexTextFindReq) SyllabHeapLen() (ln uint32)

SyllabHeapLen return heap length of IndexTextFindReq

func (*IndexTextFindReq) SyllabLen

func (req *IndexTextFindReq) SyllabLen() (ln uint64)

SyllabLen return whole length of IndexTextFindReq

func (*IndexTextFindReq) SyllabStackLen

func (req *IndexTextFindReq) SyllabStackLen() (ln uint32)

SyllabStackLen return stack length of IndexTextFindReq

type IndexTextFindRes

type IndexTextFindRes struct {
	Tokens [10]PhraseToken
}

IndexTextFindRes is response structure of IndexTextFind()

func IndexTextFind

func IndexTextFind(req *IndexTextFindReq) (res *IndexTextFindRes, err *er.Error)

IndexTextFind return index data of given terms if any exist

func (*IndexTextFindRes) JSONDecoder

func (res *IndexTextFindRes) JSONDecoder(buf []byte) (err *er.Error)

JSONDecoder decode json to given IndexTextFindRes

func (*IndexTextFindRes) JSONEncoder

func (res *IndexTextFindRes) JSONEncoder() (buf []byte)

JSONEncoder encode given IndexTextFindRes to json format.

func (*IndexTextFindRes) JSONLen

func (res *IndexTextFindRes) JSONLen() (ln int)

JSONLen return json needed len to encode!

func (*IndexTextFindRes) SyllabDecoder

func (res *IndexTextFindRes) SyllabDecoder(buf []byte) (err *er.Error)

SyllabDecoder decode syllab to given IndexTextFindRes

func (*IndexTextFindRes) SyllabEncoder

func (res *IndexTextFindRes) SyllabEncoder(buf []byte)

SyllabEncoder encode given IndexTextFindRes to syllab format

func (*IndexTextFindRes) SyllabHeapLen

func (res *IndexTextFindRes) SyllabHeapLen() (ln uint32)

SyllabHeapLen return heap length of IndexTextFindRes

func (*IndexTextFindRes) SyllabLen

func (res *IndexTextFindRes) SyllabLen() (ln uint64)

SyllabLen return whole length of IndexTextFindRes

func (*IndexTextFindRes) SyllabStackLen

func (res *IndexTextFindRes) SyllabStackLen() (ln uint32)

SyllabStackLen return stack length of IndexTextFindRes

type IndexTextGetReq

type IndexTextGetReq struct {
	Terms      []string
	PageNumber uint64
}

IndexTextGetReq is request structure of IndexTextGet()

type IndexTextGetRes

type IndexTextGetRes struct {
	Tokens [10]PhraseToken
}

IndexTextGetRes is response structure of IndexTextGet()

func IndexTextGet

func IndexTextGet(req *IndexTextGetReq) (res *IndexTextGetRes, err *er.Error)

IndexTextGet return index data of given terms if any exist

type IndexWord

type IndexWord struct {
	/* Common header data */
	RecordID          [32]byte
	RecordStructureID uint64
	RecordSize        uint64
	WriteTime         etime.Time
	OwnerAppID        [32]byte

	/* Unique data */
	Word               string `index-hash:"RecordID,RecordID[pair,RecordStructure],RecordID[pair,RecordSecondaryKey],RecordID[pair,RecordOwnerID]"` // Order of recordIDs index changed by algorithm in exact period of time!
	RecordStructure    uint64
	RecordPrimaryKey   [32]byte // Store any primary ID or any data up to 32 byte length e.g. ID
	RecordSecondaryKey [32]byte // Store any secondary ID or any data up to 32 byte length e.g. GroupID
	RecordOwnerID      [32]byte
	Tokens             []WordToken
}

IndexWord is standard structure to store the word index data!

func (*IndexWord) FindByWordRecordStructure

func (iw *IndexWord) FindByWordRecordStructure(offset, limit uint64) (phraseTokens []PhraseToken, err *er.Error)

FindByWordRecordStructure find by given Word+RecordStructure

func (*IndexWord) FindRecordsIDByWord

func (iw *IndexWord) FindRecordsIDByWord(offset, limit uint64) (RecordsID [][32]byte, err *er.Error)

FindRecordsIDByWord find RecordsID by given ID

func (*IndexWord) FindRecordsIDByWordRecordOwnerID

func (iw *IndexWord) FindRecordsIDByWordRecordOwnerID(offset, limit uint64) (RecordsID [][32]byte, err *er.Error)

FindRecordsIDByWordRecordOwnerID find RecordsID by given Word+RecordOwnerID

func (*IndexWord) FindRecordsIDByWordRecordStructure

func (iw *IndexWord) FindRecordsIDByWordRecordStructure(offset, limit uint64) (RecordsID [][32]byte, err *er.Error)

FindRecordsIDByWordRecordStructure find RecordsID by given Word+RecordStructure

func (*IndexWord) FindRecordsIDByWordSecondaryKey

func (iw *IndexWord) FindRecordsIDByWordSecondaryKey(offset, limit uint64) (RecordsID [][32]byte, err *er.Error)

FindRecordsIDByWordSecondaryKey find RecordsID by given Word+SecondaryKey

func (*IndexWord) GetByRecordID

func (iw *IndexWord) GetByRecordID() (err *er.Error)

GetByRecordID method read all existing record data by given RecordID!

func (*IndexWord) GetByWordRecordPrimaryKey

func (iw *IndexWord) GetByWordRecordPrimaryKey() (err *er.Error)

GetByWordRecordPrimaryKey find RecordsID by given Word+RecordPrimaryKey

func (*IndexWord) IndexRecordIDForWord

func (iw *IndexWord) IndexRecordIDForWord()

IndexRecordIDForWord save RecordID chain for ID+Language Call in each update to the exiting record!

func (*IndexWord) IndexRecordIDForWordRecordOwnerID

func (iw *IndexWord) IndexRecordIDForWordRecordOwnerID()

IndexRecordIDForWordRecordOwnerID save RecordID chain for Word+RecordOwnerID Don't call in update to an exiting record!

func (*IndexWord) IndexRecordIDForWordRecordSecondaryKey

func (iw *IndexWord) IndexRecordIDForWordRecordSecondaryKey()

IndexRecordIDForWordRecordSecondaryKey save RecordID chain for Word+RecordSecondaryKey Don't call in update to an exiting record!

func (*IndexWord) IndexRecordIDForWordRecordStructure

func (iw *IndexWord) IndexRecordIDForWordRecordStructure()

IndexRecordIDForWordRecordStructure save RecordID chain for Word+RecordStructure Don't call in update to an exiting record!

func (*IndexWord) SaveNew

func (iw *IndexWord) SaveNew() (err *er.Error)

SaveNew method set some data and write entire IndexWord record with all indexes!

func (*IndexWord) SaveOrUpdate

func (iw *IndexWord) SaveOrUpdate() (err *er.Error)

SaveOrUpdate method set some data and write entire IndexWord record with all indexes or update exiting one!

func (*IndexWord) Set

func (iw *IndexWord) Set() (err *er.Error)

Set method set some data and write entire IndexWord record!

type PhraseToken

type PhraseToken struct {
	RecordID          [32]byte `json:",string"`
	RecordStructureID uint64
	RecordFieldID     uint8
	RecordPrimaryKey  [32]byte `json:",string"` // Store any primary ID or any data up to 32 byte length

}

PhraseToken store detail about a word in the record to index

type TextIndexSetReq

type TextIndexSetReq struct {
	RecordID           [32]byte
	RecordStructure    uint64
	RecordPrimaryKey   [32]byte // Store any primary ID or any data up to 32 byte length e.g. ID
	RecordSecondaryKey [32]byte // Store any secondary ID or any data up to 32 byte length e.g. GroupID
	RecordOwnerID      [32]byte
	RecordFieldID      uint8
	Text               string
}

TextIndexSetReq is request structure of TextIndex()

type WordLabel

type WordLabel uint64

WordLabel indicate any word||phrase label

const (
	WordLabelUnset  WordLabel = iota
	WordLabelPERSON           // People
	WordLabelGPE              // geographical/political Entities (GPE
)

Word||phrases lables

type WordSuggestion

type WordSuggestion struct {
	/* Common header data */
	RecordID          [32]byte
	RecordStructureID uint64
	RecordSize        uint64
	WriteTime         etime.Time
	OwnerAppID        [32]byte
	// contains filtered or unexported fields
}

WordSuggestion is standard structure to store any hash byte index!! It is simple secondary index e.g. hash("user@email.com")

type WordToken

type WordToken struct {
	RecordID             [32]byte `json:",string"`
	RecordFieldID        uint8
	WordType             WordType
	WordOffsetInSentence uint64 //  Position of the word in the sentence
	WordOffsetInText     uint64 //  Position of the word in the text
	OffsetInSentence     uint64 //  First word charecter possition in the sentence
	OffsetInText         uint64 //  First word charecter possition in the text
}

WordToken store detail about a word in the record to index

type WordType

type WordType uint16

WordType indicate any word||phrase type

const (
	WordTypeUnset    WordType = iota
	WordTypeTag               // Mentions something e.g. tag a user > @omid
	WordTypeHashTag           // Mentions some topic e.g. #Victory
	WordTypeURI               // Email addresses > Jane.Doe@example.com || URLs > https://github.com/jdkato/prose
	WordTypeEmoticon          // :-), >:(, o_0, etc.

)

Word||phrases types

Jump to

Keyboard shortcuts

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