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
ConstructorDescriptionSymbolTableBplus
(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 TypeMethodDescriptionvoid
Adds an index to the symbol table.boolean
checkSanity
(boolean shadow) check sanityvoid
clear()
remove all symbolsvoid
close()
Close symbol table.void
commit()
commit transactionfinal long
createFunctionCode
(long[] buffer, Function f) create function codefinal long
createFunctionCodeNotInternalize
(long[] buffer, Function f) create function code not internalizedvoid
delete()
delete all / release fileslong
Returns a code for an object but does not internalize the object.long
Internalize a value.void
flush()
flushes symbol table.get the provider for external data typeslong
getFunctionCode
(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 codeboolean
are there indices like text index, geo indexboolean
is symbol table within a transactionboolean
is symbol table in bulk modeboolean
isCreatedDuringReasoning
(long code) indicated for a code, that the corresponding symbol has been created during reasoningboolean
isEmpty()
is symbol table empty (now symbols stored)iterator()
get an iterator for all symbolslong
returns the last time a modification took placevoid
removes all symbol table indexes.void
removeNotInternalized
(long code) remove a non internalized termvoid
removes the given symbol table index.void
reset transactionvoid
restore
(String edbdir, String workdir, ExternalDataTypeProvider datatypes, boolean compress, int maxTermLength) void
rollback()
rollback transactionvoid
setBulkMode
(boolean bulk) for loading into an empty symbol table bulk mode should be usedlong
size()
returns the number of symbols in the symbol tabletoString()
void
begin a transaction.void
commit last changesvoid
abort 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, unify
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods 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:
IOException
EDBException
-
SymbolTableBplus
public SymbolTableBplus(int index, ExternalDataTypeProvider dataTypes, boolean directencoding, String edbDir, String logDir, int termlength, boolean transactionLog, boolean compress) throws IOException, EDBException - Throws:
IOException
EDBException
-
-
Method Details
-
lastModificationTime
public long lastModificationTime()Description copied from interface:SymbolTable
returns the last time a modification took place- Specified by:
lastModificationTime
in interfaceSymbolTable
- Returns:
-
isBulkMode
public boolean isBulkMode()Description copied from interface:SymbolTable
is symbol table in bulk mode- Specified by:
isBulkMode
in interfaceSymbolTable
- Returns:
-
resetTransaction
public void resetTransaction()Description copied from interface:SymbolTable
reset transaction- Specified by:
resetTransaction
in interfaceSymbolTable
-
inTransaction
public boolean inTransaction()Description copied from interface:SymbolTable
is symbol table within a transaction- Specified by:
inTransaction
in interfaceSymbolTable
- Returns:
-
checkSanity
Description copied from interface:SymbolTable
check sanity- Specified by:
checkSanity
in interfaceSymbolTable
- Returns:
- Throws:
IOException
-
getSymbolsCache
-
getFunctionsCache
-
getExternalDataTypes
Description copied from interface:SymbolTable
get the provider for external data types- Specified by:
getExternalDataTypes
in interfaceSymbolTable
- Returns:
-
encodeWOEncoding
Description copied from interface:SymbolTable
Internalize 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:
encodeWOEncoding
in interfaceSymbolTable
- Parameters:
t
- , the user term to be internalized- Returns:
- code, the code of the term
- Throws:
EDBException
IOException
SemReasonerException
-
encodeNotInternalize
Description copied from interface:SymbolTable
Returns 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:
encodeNotInternalize
in interfaceSymbolTable
- Specified by:
encodeNotInternalize
in classAbstractSymbolTable
- Returns:
- Throws:
IOException
SemReasonerException
-
createFunctionCode
public final long createFunctionCode(long[] buffer, Function f) throws SymboltableException, IOException, EDBException Description copied from class:AbstractSymbolTable
create function code- Specified by:
createFunctionCode
in interfaceSymbolTable
- Specified by:
createFunctionCode
in classAbstractSymbolTable
- Parameters:
buffer
- , t[0] code of function symbol, t[1]..t[n] codes for n arguments- Returns:
- code for whole function
- Throws:
IOException
EDBException
SymboltableException
-
createFunctionCodeNotInternalize
public final long createFunctionCodeNotInternalize(long[] buffer, Function f) throws SymboltableException, IOException create function code not internalized- Parameters:
buffer
-f
-- Returns:
- Throws:
SymboltableException
IOException
-
getFunctionCode
Description copied from class:AbstractSymbolTable
get function code- Specified by:
getFunctionCode
in interfaceSymbolTable
- Specified by:
getFunctionCode
in classAbstractSymbolTable
- Parameters:
t
- , t[0] code of function symbol, t[1]..t[n] codes for n arguments- Returns:
- code for whole function
- Throws:
IOException
SymboltableException
-
getFunctionEncoding
Description copied from class:AbstractSymbolTable
get the encoding of a function code, if it is there- Specified by:
getFunctionEncoding
in interfaceSymbolTable
- Specified by:
getFunctionEncoding
in classAbstractSymbolTable
- Parameters:
code
- , the code of the function- Returns:
- t[0] code of function symbol, t[1]..t[n] codes for n arguments
- Throws:
IOException
SymboltableException
-
setBulkMode
Description copied from interface:SymbolTable
for loading into an empty symbol table bulk mode should be used- Specified by:
setBulkMode
in interfaceSymbolTable
- Throws:
IOException
EDBException
-
clear
Description copied from interface:SymbolTable
remove all symbols- Specified by:
clear
in interfaceSymbolTable
- Throws:
IOException
EDBException
SymboltableException
-
delete
Description copied from interface:SymbolTable
delete all / release files- Specified by:
delete
in interfaceSymbolTable
- Throws:
IOException
SymboltableException
-
close
Description copied from interface:SymbolTable
Close symbol table. Must be called to correctly finalize symbol table- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceSymbolTable
- Throws:
IOException
-
flush
Description copied from interface:SymbolTable
flushes symbol table.- Specified by:
flush
in interfaceSymbolTable
- Throws:
IOException
-
transactionBegin
Description copied from interface:SymbolTable
begin a transaction.- Specified by:
transactionBegin
in interfaceSymbolTable
- Throws:
IOException
SymboltableException
-
transactionRollback
Description copied from interface:SymbolTable
abort last changes- Specified by:
transactionRollback
in interfaceSymbolTable
- Throws:
IOException
SymboltableException
-
transactionCommit
Description copied from interface:SymbolTable
commit last changes- Specified by:
transactionCommit
in 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:ReasoningSymbolTable
indicated for a code, that the corresponding symbol has been created during reasoning- Specified by:
isCreatedDuringReasoning
in interfaceReasoningSymbolTable
- Returns:
-
size
public long size()Description copied from interface:SymbolTable
returns the number of symbols in the symbol table- Specified by:
size
in interfaceSymbolTable
- Returns:
-
iterator
Description copied from interface:SymbolTable
get an iterator for all symbols- Specified by:
iterator
in interfaceIterable<Object>
- Specified by:
iterator
in interfaceSymbolTable
- Returns:
- an iterator over all symbols in this symbol table
-
addSymbolTableIndex
Description copied from interface:SymbolTable
Adds an index to the symbol table.
Examples are the text index and the geo index.- Specified by:
addSymbolTableIndex
in interfaceSymbolTable
- Specified by:
addSymbolTableIndex
in classAbstractSymbolTable
- Parameters:
index
- the index
-
removeSymbolTableIndex
Description copied from interface:SymbolTable
removes the given symbol table index.- Specified by:
removeSymbolTableIndex
in interfaceSymbolTable
- Specified by:
removeSymbolTableIndex
in classAbstractSymbolTable
- Parameters:
index
- the index
-
removeAllSymbolTableIndexes
public void removeAllSymbolTableIndexes()Description copied from interface:SymbolTable
removes all symbol table indexes.- Specified by:
removeAllSymbolTableIndexes
in interfaceSymbolTable
- Overrides:
removeAllSymbolTableIndexes
in classAbstractSymbolTable
-
toString
-
hasIndices
public boolean hasIndices()are there indices like text index, geo index- Specified by:
hasIndices
in interfaceSymbolTable
- Returns:
-
removeNotInternalized
remove a non internalized term- Specified by:
removeNotInternalized
in interfaceSymbolTable
- Throws:
IOException
-
commit
Description copied from interface:SymbolTable
commit transaction- Specified by:
commit
in interfaceSymbolTable
- Throws:
EDBException
IOException
-
rollback
public void rollback()Description copied from interface:SymbolTable
rollback transaction- Specified by:
rollback
in interfaceSymbolTable
-
isEmpty
public boolean isEmpty()Description copied from interface:SymbolTable
is symbol table empty (now symbols stored)- Specified by:
isEmpty
in interfaceSymbolTable
- Returns:
-
getValueSymbol
Description copied from class:AbstractSymbolTable
get object for symbol code- Specified by:
getValueSymbol
in interfaceSymbolTable
- Specified by:
getValueSymbol
in classAbstractSymbolTable
- Parameters:
code
- , symbol code- Returns:
- code for whole function
- Throws:
IOException
SemReasonerException
-
getValueFunction
Description copied from class:AbstractSymbolTable
get function for symbol code- Specified by:
getValueFunction
in interfaceSymbolTable
- Specified by:
getValueFunction
in classAbstractSymbolTable
- Parameters:
code
- , symbol code- Returns:
- code for whole function
- Throws:
IOException
SemReasonerException
-
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:
getValue
in interfaceSymbolTable
- Overrides:
getValue
in classAbstractSymbolTable
- Parameters:
code
- , the code of the internal term- Returns:
- Throws:
SymboltableException
IOException
-