Documentation ¶
Index ¶
- Variables
- func CreateFulltextIndexes(ctx *sql.Context, database Database, parent sql.Table, ...) error
- func CreateMultiTableEditor(ctx *sql.Context, primary sql.TableEditor, secondaries ...sql.TableEditor) (sql.TableEditor, error)
- func DropAllIndexes(ctx *sql.Context, tbl sql.IndexAddressableTable, db Database) error
- func DropColumnFromTables(ctx *sql.Context, tbl sql.IndexAddressableTable, db Database, colName string) error
- func GetCollationFromSchema(ctx *sql.Context, sch sql.Schema) sql.CollationID
- func GetParentColumnMap(parentSch sql.Schema) map[string]int
- func HashRow(row sql.Row) (string, error)
- func NewSchema(sch sql.Schema, insertCols []*sql.Column, source string, ...) (newSch sql.Schema, err error)
- func RebuildTables(ctx *sql.Context, tbl sql.IndexAddressableTable, db Database) error
- type Database
- type DefaultParser
- func (dp *DefaultParser) DocumentCount(ctx *sql.Context, word string) (count uint64, err error)
- func (dp *DefaultParser) Next(ctx *sql.Context) (word string, wordPosition uint64, reachedTheEnd bool, err error)
- func (dp *DefaultParser) NextUnique(ctx *sql.Context) (uniqueWord string, reachedTheEnd bool, err error)
- func (dp *DefaultParser) Reset()
- func (dp *DefaultParser) UniqueWordCount(ctx *sql.Context) (count uint64)
- type EditableTable
- type Index
- type IndexAlterableTable
- type IndexEditors
- type IndexSingleEditor
- type IndexTableNames
- type KeyColumns
- type KeyType
- type MultiTableEditor
- func (editor MultiTableEditor) Close(ctx *sql.Context) error
- func (editor MultiTableEditor) Delete(ctx *sql.Context, row sql.Row) error
- func (editor MultiTableEditor) DiscardChanges(ctx *sql.Context, errorEncountered error) error
- func (editor MultiTableEditor) GetIndexes(ctx *sql.Context) ([]sql.Index, error)
- func (editor MultiTableEditor) IndexedAccess(lookup sql.IndexLookup) sql.IndexedTable
- func (editor MultiTableEditor) Insert(ctx *sql.Context, row sql.Row) error
- func (editor MultiTableEditor) PrimaryEditor() sql.TableEditor
- func (editor MultiTableEditor) SecondaryEditors() []sql.TableEditor
- func (editor MultiTableEditor) SetAutoIncrementValue(ctx *sql.Context, u uint64) error
- func (editor MultiTableEditor) StatementBegin(ctx *sql.Context)
- func (editor MultiTableEditor) StatementComplete(ctx *sql.Context) error
- func (editor MultiTableEditor) Update(ctx *sql.Context, old sql.Row, new sql.Row) error
- type SearchModifier
- type TableEditor
- func (editor TableEditor) Close(ctx *sql.Context) error
- func (editor TableEditor) Delete(ctx *sql.Context, row sql.Row) error
- func (editor TableEditor) DiscardChanges(ctx *sql.Context, errorEncountered error) error
- func (editor TableEditor) Insert(ctx *sql.Context, row sql.Row) error
- func (editor TableEditor) StatementBegin(ctx *sql.Context)
- func (editor TableEditor) StatementComplete(ctx *sql.Context) error
- func (editor TableEditor) Update(ctx *sql.Context, old sql.Row, new sql.Row) error
- type TableSet
Constants ¶
This section is empty.
Variables ¶
var ( // SchemaConfig is the schema for the config table, which is a pseudo-index implementation of a Full-Text index. SchemaConfig = sql.Schema{ {Name: "id", Type: types.Int32, Nullable: false, PrimaryKey: true}, {Name: "stopword_table", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 2048), Nullable: false, PrimaryKey: false}, {Name: "use_stopword", Type: types.Boolean, Nullable: false, PrimaryKey: false}, } // SchemaPosition is the schema for the table that returns a word's position, which is a pseudo-index implementation of a Full-Text index. SchemaPosition = sql.Schema{ {Name: "word", Type: types.MustCreateString(sqltypes.VarChar, 84, sql.Collation_Default), Nullable: false, PrimaryKey: true}, {Name: "position", Type: types.Uint64, Nullable: false, PrimaryKey: true}, } // SchemaDocCount is the schema for the table that returns a word's document count, which is a pseudo-index implementation of a Full-Text index. SchemaDocCount = sql.Schema{ {Name: "word", Type: types.MustCreateString(sqltypes.VarChar, 84, sql.Collation_Default), Nullable: false, PrimaryKey: true}, {Name: "doc_count", Type: types.Uint64, Nullable: false, PrimaryKey: false}, } // SchemaGlobalCount is the schema for the table that returns a word's global document count, which is a pseudo-index implementation of a Full-Text index. SchemaGlobalCount = sql.Schema{ {Name: "word", Type: types.MustCreateString(sqltypes.VarChar, 84, sql.Collation_Default), Nullable: false, PrimaryKey: true}, {Name: "global_count", Type: types.Uint64, Nullable: false, PrimaryKey: false}, } // SchemaRowCount is the schema for the table that contains a count for each row's hash, which is a pseudo-index implementation of a Full-Text index. SchemaRowCount = sql.Schema{ {Name: "row_hash", Type: types.MustCreateString(sqltypes.VarChar, 84, sql.Collation_Default), Nullable: false, PrimaryKey: true}, {Name: "row_count", Type: types.Uint64, Nullable: false, PrimaryKey: false}, {Name: "unique_words", Type: types.Uint64, Nullable: false, PrimaryKey: false}, } )
Functions ¶
func CreateFulltextIndexes ¶
func CreateFulltextIndexes(ctx *sql.Context, database Database, parent sql.Table, predeterminedNames map[string]IndexTableNames, indexes ...sql.IndexDef) error
CreateFulltextIndexes creates and populates Full-Text indexes on the target table.
func CreateMultiTableEditor ¶
func CreateMultiTableEditor(ctx *sql.Context, primary sql.TableEditor, secondaries ...sql.TableEditor) (sql.TableEditor, error)
CreateMultiTableEditor creates a TableEditor that writes to both the primary and secondary editors. The primary editor must implement ForeignKeyEditor and AutoIncrementSetter in addition to TableEditor.
func DropAllIndexes ¶
DropAllIndexes drops all Full-Text pseudo-index tables and indexes that are declared on the given table.
func DropColumnFromTables ¶
func DropColumnFromTables(ctx *sql.Context, tbl sql.IndexAddressableTable, db Database, colName string) error
DropColumnFromTables removes the given column from all of the Full-Text indexes, which will trigger a rebuild if the index spans multiple columns, but will trigger a deletion if the index spans that single column. The column name is case-insensitive.
func GetCollationFromSchema ¶
GetCollationFromSchema returns the WORD's collation. This assumes that it is only used with schemas from the position, doc count, and global count tables.
func GetParentColumnMap ¶
GetParentColumnMap is used to map index expressions to their source columns. All strings have been lowercased.
func HashRow ¶
HashRow returns a 64 character lowercase hexadecimal hash of the given row. This is intended for use with keyless tables.
func NewSchema ¶
func NewSchema(sch sql.Schema, insertCols []*sql.Column, source string, collation sql.CollationID) (newSch sql.Schema, err error)
NewSchema returns a new schema based on the given schema with all collated fields replaced with the given collation, the given key columns inserted after the first column, and all columns set to the source given.
func RebuildTables ¶
RebuildTables rebuilds all Full-Text pseudo-index tables that are declared on the given table.
Types ¶
type Database ¶
type Database interface { sql.Database sql.TableCreator CreateFulltextTableNames(ctx *sql.Context, parentTable string, parentIndexName string) (IndexTableNames, error) }
Database allows a database to return a set of unique names that will be used for the pseudo-index tables with Full-Text indexes.
type DefaultParser ¶
type DefaultParser struct {
// contains filtered or unexported fields
}
DefaultParser is the default text parser that is used when parsing Full-Text documents. Its intention is the match the expected behavior of MySQL's default Full-Text parser. This provides normalization, as well as statistics regarding the input document, such as the occurrence of any given word. Such statistics may later be used when calculating the relevancy within a MatchAgainst expression.
func NewDefaultParser ¶
func NewDefaultParser(ctx *sql.Context, collation sql.CollationID, colVals ...interface{}) (DefaultParser, error)
NewDefaultParser creates a new DefaultParser.
func (*DefaultParser) DocumentCount ¶
DocumentCount returns the count of the given word within the document.
func (*DefaultParser) Next ¶
func (dp *DefaultParser) Next(ctx *sql.Context) (word string, wordPosition uint64, reachedTheEnd bool, err error)
Next returns the next word and its position. Once no more words can be returned, then we've reached the end. This iterates through its list separately from NextUnique.
func (*DefaultParser) NextUnique ¶
func (dp *DefaultParser) NextUnique(ctx *sql.Context) (uniqueWord string, reachedTheEnd bool, err error)
NextUnique returns the next unique word. Once no more words can be returned, then we've reached the end. This iterates through its list separately from Next.
func (*DefaultParser) Reset ¶
func (dp *DefaultParser) Reset()
Reset will set the progress on both Next and NextUnique to the beginning, allowing the parser to be reused.
func (*DefaultParser) UniqueWordCount ¶
func (dp *DefaultParser) UniqueWordCount(ctx *sql.Context) (count uint64)
UniqueWordCount returns the number of unique words within the document.
type EditableTable ¶
type EditableTable interface { sql.InsertableTable sql.UpdatableTable sql.DeletableTable sql.IndexAddressableTable }
EditableTable is a table that implements InsertableTable, UpdatableTable, and DeletableTable.
type Index ¶
type Index interface { sql.Index // FullTextTableNames returns the names of the tables that represent the FULLTEXT index. FullTextTableNames(ctx *sql.Context) (IndexTableNames, error) // FullTextKeyColumns returns the key columns of its parent table that are used with this Full-Text index. FullTextKeyColumns(ctx *sql.Context) (KeyColumns, error) }
Index contains additional information regarding the FULLTEXT index.
type IndexAlterableTable ¶
type IndexAlterableTable interface { sql.IndexAlterableTable // CreateFulltextIndex creates a FULLTEXT index for this table. The index should not create a backing store, as the // names of the tables given have already been created and will be managed by GMS as pseudo-indexes. CreateFulltextIndex(ctx *sql.Context, indexDef sql.IndexDef, keyCols KeyColumns, tableNames IndexTableNames) error }
IndexAlterableTable represents a table that supports the creation of FULLTEXT indexes. Renaming and deleting the FULLTEXT index are both handled by RenameIndex and DropIndex respectively.
type IndexEditors ¶
type IndexEditors struct { Position IndexSingleEditor DocCount IndexSingleEditor GlobalCount IndexSingleEditor RowCount IndexSingleEditor SourceCols []int KeyCols KeyColumns Collation sql.CollationID }
IndexEditors represents an individual index's editors, along with the columns (and order) to source the text from.
type IndexSingleEditor ¶
IndexSingleEditor is an editor for a single table, which represents a portion of a single index.
type IndexTableNames ¶
type IndexTableNames struct { Config string Position string DocCount string GlobalCount string RowCount string }
IndexTableNames holds all of the names for each pseudo-index table used by a Full-Text index.
type KeyColumns ¶
type KeyColumns struct { // Type refers to the type of key that the columns belong to. Type KeyType // Name is the name of the key. Only unique keys will have a name. Name string // Positions represents the schema index positions for primary keys and unique keys. Positions []int }
KeyColumns contains all of the information needed to create key columns for each Full-Text table.
func GetKeyColumns ¶
GetKeyColumns returns the key columns from the parent table that will be used to uniquely reference any given row on the parent table. For many tables, this will be the primary key. For tables that do not have a valid key, the columns will be much more important.
type MultiTableEditor ¶
type MultiTableEditor struct {
// contains filtered or unexported fields
}
MultiTableEditor wraps multiple table editors, allowing for a single function to handle writes across multiple tables.
func (MultiTableEditor) Close ¶
func (editor MultiTableEditor) Close(ctx *sql.Context) error
Close implements the interface sql.TableEditor.
func (MultiTableEditor) DiscardChanges ¶
func (editor MultiTableEditor) DiscardChanges(ctx *sql.Context, errorEncountered error) error
DiscardChanges implements the interface sql.TableEditor.
func (MultiTableEditor) GetIndexes ¶
GetIndexes implements the interface ForeignKeyEditor.
func (MultiTableEditor) IndexedAccess ¶
func (editor MultiTableEditor) IndexedAccess(lookup sql.IndexLookup) sql.IndexedTable
IndexedAccess implements the interface ForeignKeyEditor.
func (MultiTableEditor) PrimaryEditor ¶
func (editor MultiTableEditor) PrimaryEditor() sql.TableEditor
PrimaryEditor returns the primary editor.
func (MultiTableEditor) SecondaryEditors ¶
func (editor MultiTableEditor) SecondaryEditors() []sql.TableEditor
SecondaryEditors returns the secondary editors.
func (MultiTableEditor) SetAutoIncrementValue ¶
func (editor MultiTableEditor) SetAutoIncrementValue(ctx *sql.Context, u uint64) error
SetAutoIncrementValue implements the interface AutoIncrementSetter.
func (MultiTableEditor) StatementBegin ¶
func (editor MultiTableEditor) StatementBegin(ctx *sql.Context)
StatementBegin implements the interface sql.TableEditor.
func (MultiTableEditor) StatementComplete ¶
func (editor MultiTableEditor) StatementComplete(ctx *sql.Context) error
StatementComplete implements the interface sql.TableEditor.
type SearchModifier ¶
type SearchModifier byte
SearchModifier represents the search modifier when using MATCH ... AGAINST ...
const ( SearchModifier_NaturalLanguage SearchModifier = iota SearchModifier_NaturalLangaugeQueryExpansion SearchModifier_Boolean SearchModifier_QueryExpansion )
type TableEditor ¶
type TableEditor struct { Config IndexSingleEditor Indexes []IndexEditors }
TableEditor handles editors for FULLTEXT indexes. These indexes are implemented as standard tables, and therefore require the use of this editor to handle the transformation of rows.
func CreateEditor ¶
func CreateEditor(ctx *sql.Context, parent sql.Table, config EditableTable, indexes ...TableSet) (editor TableEditor, err error)
CreateEditor returns a TableEditor that will handle the transformation of rows destined for the parent table to the FULLTEXT tables.
func (TableEditor) Close ¶
func (editor TableEditor) Close(ctx *sql.Context) error
Close implements the interface sql.TableEditor.
func (TableEditor) DiscardChanges ¶
func (editor TableEditor) DiscardChanges(ctx *sql.Context, errorEncountered error) error
DiscardChanges implements the interface sql.TableEditor.
func (TableEditor) StatementBegin ¶
func (editor TableEditor) StatementBegin(ctx *sql.Context)
StatementBegin implements the interface sql.TableEditor.
func (TableEditor) StatementComplete ¶
func (editor TableEditor) StatementComplete(ctx *sql.Context) error
StatementComplete implements the interface sql.TableEditor.
type TableSet ¶
type TableSet struct { // Index contains information regarding the FULLTEXT index. Index Index // Position refers to the table that maps each word to an ID and position. Position EditableTable // DocCount refers to the table that contains the word count per document. DocCount EditableTable // GlobalCount refers to the table that contains the word count across all documents. GlobalCount EditableTable // RowCount refers to the table that contains the count of all row hashes for the index. RowCount EditableTable }
TableSet contains the multiple tables that comprise a single FULLTEXT index. The config table is supplied separately, as it is shared among all of the tables.