Package com.semedy.reasoner.symboltable
Class SymbolTableBplus
java.lang.Object
com.semedy.reasoner.symboltable.AbstractSymbolTable
com.semedy.reasoner.symboltable.SymbolTableBplus
- All Implemented Interfaces:
SymbolTable,ReasoningSymbolTable,Closeable,AutoCloseable,Iterable<Object>
Implements a persistent symbol table based on b+ trees
- Author:
- angele
-
Constructor Summary
ConstructorsConstructorDescriptionSymbolTableBplus(int index, ExternalDataTypeProvider dataTypes, boolean directencoding, String edbDir, String logDir, int termlength, boolean transactionLog, boolean compress) SymbolTableBplus(ExternalDataTypeProvider dataTypes, boolean directencoding, String edbDir, String logDir, int termlength, boolean transactionLog, boolean compress) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an index to the symbol table.booleancheckSanity(boolean shadow) check sanityvoidclear()remove all symbolsvoidclose()Close symbol table.voidcommit()commit transactionfinal longcreateFunctionCode(long[] buffer, Function f) create function codefinal longcreateFunctionCodeNotInternalize(long[] buffer, Function f) create function code not internalizedvoiddelete()delete all / release fileslongReturns a code for an object but does not internalize the object.longInternalize a value.voidflush()flushes symbol table.get the provider for external data typeslonggetFunctionCode(long[] t) get function codelong[]getFunctionEncoding(long code) get the encoding of a function code, if it is theregetValue(long code) Produce a value from the code of an internal constant.getValueFunction(long code) get function for symbol codegetValueSymbol(long code) get object for symbol codebooleanare there indices like text index, geo indexbooleanis symbol table within a transactionbooleanis symbol table in bulk modebooleanisCreatedDuringReasoning(long code) indicated for a code, that the corresponding symbol has been created during reasoningbooleanisEmpty()is symbol table empty (now symbols stored)iterator()get an iterator for all symbolslongreturns the last time a modification took placevoidremoves all symbol table indexes.voidremoveNotInternalized(long code) remove a non internalized termvoidremoves the given symbol table index.voidreset transactionvoidrestore(String edbdir, String workdir, ExternalDataTypeProvider datatypes, boolean compress, int maxTermLength) voidrollback()rollback transactionvoidsetBulkMode(boolean bulk) for loading into an empty symbol table bulk mode should be usedlongsize()returns the number of symbols in the symbol tabletoString()voidbegin a transaction.voidcommit last changesvoidabort last changesMethods inherited from class com.semedy.reasoner.symboltable.AbstractSymbolTable
createNonGroundFunction, decodeNonGroundFunction, encode, getCode, getGeoIndex, getTextIndex, match, matchArguments, matchArguments, notifySymbolAdded, recreateSymbolTableIndexes, refreshSearchIndexes, semiSubstitute, substitute, substitute, substitute, substituteArguments, substituteArguments, substituteFunction, unifiable, unify, unifyMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface com.semedy.reasoner.api.symboltable.SymbolTable
decodeNonGroundFunction, encode, getCode, getGeoIndex, getTextIndex, matchArguments, notifySymbolAdded, recreateSymbolTableIndexes, refreshSearchIndexes, substitute, substitute, substituteArguments, unify, unify
-
Constructor Details
-
SymbolTableBplus
public SymbolTableBplus(ExternalDataTypeProvider dataTypes, boolean directencoding, String edbDir, String logDir, int termlength, boolean transactionLog, boolean compress) throws IOException, EDBException - Throws:
IOExceptionEDBException
-
SymbolTableBplus
public SymbolTableBplus(int index, ExternalDataTypeProvider dataTypes, boolean directencoding, String edbDir, String logDir, int termlength, boolean transactionLog, boolean compress) throws IOException, EDBException - Throws:
IOExceptionEDBException
-
-
Method Details
-
lastModificationTime
public long lastModificationTime()Description copied from interface:SymbolTablereturns the last time a modification took place- Specified by:
lastModificationTimein interfaceSymbolTable- Returns:
-
isBulkMode
public boolean isBulkMode()Description copied from interface:SymbolTableis symbol table in bulk mode- Specified by:
isBulkModein interfaceSymbolTable- Returns:
-
resetTransaction
public void resetTransaction()Description copied from interface:SymbolTablereset transaction- Specified by:
resetTransactionin interfaceSymbolTable
-
inTransaction
public boolean inTransaction()Description copied from interface:SymbolTableis symbol table within a transaction- Specified by:
inTransactionin interfaceSymbolTable- Returns:
-
checkSanity
Description copied from interface:SymbolTablecheck sanity- Specified by:
checkSanityin interfaceSymbolTable- Returns:
- Throws:
IOException
-
getSymbolsCache
-
getFunctionsCache
-
getExternalDataTypes
Description copied from interface:SymbolTableget the provider for external data types- Specified by:
getExternalDataTypesin interfaceSymbolTable- Returns:
-
encodeWOEncoding
Description copied from interface:SymbolTableInternalize a value. All values are internalized,
i.e. for every different value there exists exactly one instance and thus
also exactly one code
Encoding is done without encoding characters in strings- Specified by:
encodeWOEncodingin interfaceSymbolTable- Parameters:
t- , the user term to be internalized- Returns:
- code, the code of the term
- Throws:
EDBExceptionIOExceptionSemReasonerException
-
encodeNotInternalize
Description copied from interface:SymbolTableReturns a code for an object but does not internalize the object.
This means that there might be different codes
for the same object.- Specified by:
encodeNotInternalizein interfaceSymbolTable- Specified by:
encodeNotInternalizein classAbstractSymbolTable- Returns:
- Throws:
IOExceptionSemReasonerException
-
createFunctionCode
public final long createFunctionCode(long[] buffer, Function f) throws SymboltableException, IOException, EDBException Description copied from class:AbstractSymbolTablecreate function code- Specified by:
createFunctionCodein interfaceSymbolTable- Specified by:
createFunctionCodein classAbstractSymbolTable- Parameters:
buffer- , t[0] code of function symbol, t[1]..t[n] codes for n arguments- Returns:
- code for whole function
- Throws:
IOExceptionEDBExceptionSymboltableException
-
createFunctionCodeNotInternalize
public final long createFunctionCodeNotInternalize(long[] buffer, Function f) throws SymboltableException, IOException create function code not internalized- Parameters:
buffer-f-- Returns:
- Throws:
SymboltableExceptionIOException
-
getFunctionCode
Description copied from class:AbstractSymbolTableget function code- Specified by:
getFunctionCodein interfaceSymbolTable- Specified by:
getFunctionCodein classAbstractSymbolTable- Parameters:
t- , t[0] code of function symbol, t[1]..t[n] codes for n arguments- Returns:
- code for whole function
- Throws:
IOExceptionSymboltableException
-
getFunctionEncoding
Description copied from class:AbstractSymbolTableget the encoding of a function code, if it is there- Specified by:
getFunctionEncodingin interfaceSymbolTable- Specified by:
getFunctionEncodingin classAbstractSymbolTable- Parameters:
code- , the code of the function- Returns:
- t[0] code of function symbol, t[1]..t[n] codes for n arguments
- Throws:
IOExceptionSymboltableException
-
setBulkMode
Description copied from interface:SymbolTablefor loading into an empty symbol table bulk mode should be used- Specified by:
setBulkModein interfaceSymbolTable- Throws:
IOExceptionEDBException
-
clear
Description copied from interface:SymbolTableremove all symbols- Specified by:
clearin interfaceSymbolTable- Throws:
IOExceptionEDBExceptionSymboltableException
-
delete
Description copied from interface:SymbolTabledelete all / release files- Specified by:
deletein interfaceSymbolTable- Throws:
IOExceptionSymboltableException
-
close
Description copied from interface:SymbolTableClose symbol table. Must be called to correctly finalize symbol table- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceSymbolTable- Throws:
IOException
-
flush
Description copied from interface:SymbolTableflushes symbol table.- Specified by:
flushin interfaceSymbolTable- Throws:
IOException
-
transactionBegin
Description copied from interface:SymbolTablebegin a transaction.- Specified by:
transactionBeginin interfaceSymbolTable- Throws:
IOExceptionSymboltableException
-
transactionRollback
Description copied from interface:SymbolTableabort last changes- Specified by:
transactionRollbackin interfaceSymbolTable- Throws:
IOExceptionSymboltableException
-
transactionCommit
Description copied from interface:SymbolTablecommit last changes- Specified by:
transactionCommitin interfaceSymbolTable- Throws:
SemReasonerException- if an error occursIOException
-
restore
public void restore(String edbdir, String workdir, ExternalDataTypeProvider datatypes, boolean compress, int maxTermLength) throws SemReasonerException, InterruptedException -
isCreatedDuringReasoning
public boolean isCreatedDuringReasoning(long code) Description copied from interface:ReasoningSymbolTableindicated for a code, that the corresponding symbol has been created during reasoning- Specified by:
isCreatedDuringReasoningin interfaceReasoningSymbolTable- Returns:
-
size
public long size()Description copied from interface:SymbolTablereturns the number of symbols in the symbol table- Specified by:
sizein interfaceSymbolTable- Returns:
-
iterator
Description copied from interface:SymbolTableget an iterator for all symbols- Specified by:
iteratorin interfaceIterable<Object>- Specified by:
iteratorin interfaceSymbolTable- Returns:
- an iterator over all symbols in this symbol table
-
addSymbolTableIndex
Description copied from interface:SymbolTableAdds an index to the symbol table.
Examples are the text index and the geo index.- Specified by:
addSymbolTableIndexin interfaceSymbolTable- Specified by:
addSymbolTableIndexin classAbstractSymbolTable- Parameters:
index- the index
-
removeSymbolTableIndex
Description copied from interface:SymbolTableremoves the given symbol table index.- Specified by:
removeSymbolTableIndexin interfaceSymbolTable- Specified by:
removeSymbolTableIndexin classAbstractSymbolTable- Parameters:
index- the index
-
removeAllSymbolTableIndexes
public void removeAllSymbolTableIndexes()Description copied from interface:SymbolTableremoves all symbol table indexes.- Specified by:
removeAllSymbolTableIndexesin interfaceSymbolTable- Overrides:
removeAllSymbolTableIndexesin classAbstractSymbolTable
-
toString
-
hasIndices
public boolean hasIndices()are there indices like text index, geo index- Specified by:
hasIndicesin interfaceSymbolTable- Returns:
-
removeNotInternalized
remove a non internalized term- Specified by:
removeNotInternalizedin interfaceSymbolTable- Throws:
IOException
-
commit
Description copied from interface:SymbolTablecommit transaction- Specified by:
commitin interfaceSymbolTable- Throws:
EDBExceptionIOException
-
rollback
public void rollback()Description copied from interface:SymbolTablerollback transaction- Specified by:
rollbackin interfaceSymbolTable
-
isEmpty
public boolean isEmpty()Description copied from interface:SymbolTableis symbol table empty (now symbols stored)- Specified by:
isEmptyin interfaceSymbolTable- Returns:
-
getValueSymbol
Description copied from class:AbstractSymbolTableget object for symbol code- Specified by:
getValueSymbolin interfaceSymbolTable- Specified by:
getValueSymbolin classAbstractSymbolTable- Parameters:
code- , symbol code- Returns:
- code for whole function
- Throws:
IOExceptionSemReasonerException
-
getValueFunction
Description copied from class:AbstractSymbolTableget function for symbol code- Specified by:
getValueFunctionin interfaceSymbolTable- Specified by:
getValueFunctionin classAbstractSymbolTable- Parameters:
code- , symbol code- Returns:
- code for whole function
- Throws:
IOExceptionSemReasonerException
-
getValue
Produce a value from the code of an internal constant.
Should be used only for the call of builtins and for the final answer- Specified by:
getValuein interfaceSymbolTable- Overrides:
getValuein classAbstractSymbolTable- Parameters:
code- , the code of the internal term- Returns:
- Throws:
SymboltableExceptionIOException
-