Class OStatementCache
java.lang.Object
com.orientechnologies.orient.core.sql.parser.OStatementCache
This class is an LRU cache for already parsed SQL statement executors. It stores itself in the
storage as a resource. It also acts an an entry point for the SQL parser.
- Author:
- Luigi Dell'Aquila (l.dellaquila-(at)-orientdb.com)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleanstatic OStatementget(String statement, ODatabaseDocumentInternal db) returns an already parsed SQL executor, taking it from the cache if it exists or creating a new one (parsing and then putting it into the cache) if it doesn'tstatic OServerStatementgetServerStatement(String statement, OrientDBInternal db) returns an already parsed server-level SQL executor, taking it from the cache if it exists or creating a new one (parsing and then putting it into the cache) if it doesn'tgetStatement(String statement, ODatabaseDocumentInternal db) protected static OStatementparse(String statement, ODatabaseDocumentInternal db) parses an SQL statement and returns the corresponding executorprotected static OServerStatementparseServerStatement(String statement) parses an SQL statement and returns the corresponding executorprotected static voidthrowParsingException(ParseException e, String statement) protected static voidthrowParsingException(TokenMgrError e, String statement)
-
Constructor Details
-
OStatementCache
public OStatementCache(int size) - Parameters:
size- the size of the cache
-
-
Method Details
-
contains
- Parameters:
statement- an SQL statement- Returns:
- true if the corresponding executor is present in the cache
-
get
returns an already parsed SQL executor, taking it from the cache if it exists or creating a new one (parsing and then putting it into the cache) if it doesn't- Parameters:
statement- the SQL statementdb- the current DB instance. If null, cache is ignored and a new executor is created through statement parsing- Returns:
- a statement executor from the cache
-
getServerStatement
returns an already parsed server-level SQL executor, taking it from the cache if it exists or creating a new one (parsing and then putting it into the cache) if it doesn't- Parameters:
statement- the SQL statementdb- the current OrientDB instance. If null, cache is ignored and a new executor is created through statement parsing- Returns:
- a statement executor from the cache
-
getStatement
- Parameters:
statement- an SQL statement- Returns:
- the corresponding executor, taking it from the internal cache, if it exists
-
parse
protected static OStatement parse(String statement, ODatabaseDocumentInternal db) throws OCommandSQLParsingException parses an SQL statement and returns the corresponding executor- Parameters:
statement- the SQL statementdb- TODO- Returns:
- the corresponding executor
- Throws:
OCommandSQLParsingException- if the input parameter is not a valid SQL statement
-
parseServerStatement
protected static OServerStatement parseServerStatement(String statement) throws OCommandSQLParsingException parses an SQL statement and returns the corresponding executor- Parameters:
statement- the SQL statement- Returns:
- the corresponding executor
- Throws:
OCommandSQLParsingException- if the input parameter is not a valid SQL statement
-
throwParsingException
-
throwParsingException
-
clear
public void clear()
-