Class OStatementCache

java.lang.Object
com.orientechnologies.orient.core.sql.parser.OStatementCache

public class OStatementCache extends Object
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 Details

    • OStatementCache

      public OStatementCache(int size)
      Parameters:
      size - the size of the cache
  • Method Details

    • contains

      public boolean contains(String statement)
      Parameters:
      statement - an SQL statement
      Returns:
      true if the corresponding executor is present in the cache
    • get

      public static OStatement get(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't
      Parameters:
      statement - the SQL statement
      db - 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

      public static OServerStatement getServerStatement(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't
      Parameters:
      statement - the SQL statement
      db - 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

      public OStatement getStatement(String statement, ODatabaseDocumentInternal db)
      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 statement
      db - 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

      protected static void throwParsingException(ParseException e, String statement)
    • throwParsingException

      protected static void throwParsingException(TokenMgrError e, String statement)
    • clear

      public void clear()