org.aksw.commons.sparql.api.cache.extra
Class CacheCoreH2

java.lang.Object
  extended by org.aksw.commons.sparql.api.cache.extra.SqlDaoBase
      extended by org.aksw.commons.sparql.api.cache.extra.CacheCoreH2
All Implemented Interfaces:
CacheCore, CacheCoreEx, SqlDao

public class CacheCoreH2
extends SqlDaoBase
implements CacheCore, CacheCoreEx

The class is used to cache information about resources to a database. Provides the connection to an H2 database in a light weight, configuration free manner. Important: This implementation of the CacheCoreEx interface uses combined hashes of services and queries.

Author:
Jens Lehmann, Claus Stadler

Field Summary
 
Fields inherited from class org.aksw.commons.sparql.api.cache.extra.SqlDaoBase
idToQuery, queryToStmt
 
Constructor Summary
CacheCoreH2(Connection conn, long lifespan)
           
 
Method Summary
 CacheEntry _lookup(String service, String queryString)
           
static CacheCoreH2 create(boolean autoServerMode, String dbDir, String dbName, long lifespan)
          Loads the driver
static CacheCoreEx create(boolean autoServerMode, String dbDir, String dbName, long lifespan, boolean useCompression)
           
static CacheCoreH2 create(String dbName)
           
static CacheCoreH2 create(String dbName, long lifespan)
           
static CacheCoreEx create(String dbName, long lifespan, boolean useCompression)
           
 String createHashRoot(String service, String queryString)
           
 Iterator<CacheEntryH2> iterator()
          Note: Do not close the InputStream provider on the cache entries as this closes the underlying result set.
 CacheEntry lookup(String queryString)
           
 CacheEntry lookup(String service, String queryString)
           
 void write(String queryString, InputStream in)
           
 void write(String service, String queryString, InputStream in)
           
 
Methods inherited from class org.aksw.commons.sparql.api.cache.extra.SqlDaoBase
execute, executeList, executeQuery, getConnection, setConnection, setPreparedStatement
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheCoreH2

public CacheCoreH2(Connection conn,
                   long lifespan)
            throws SQLException
Throws:
SQLException
Method Detail

lookup

public CacheEntry lookup(String queryString)
Specified by:
lookup in interface CacheCore

write

public void write(String queryString,
                  InputStream in)
Specified by:
write in interface CacheCore

create

public static CacheCoreH2 create(String dbName)
                          throws ClassNotFoundException,
                                 SQLException
Throws:
ClassNotFoundException
SQLException

create

public static CacheCoreH2 create(String dbName,
                                 long lifespan)
                          throws ClassNotFoundException,
                                 SQLException
Throws:
ClassNotFoundException
SQLException

create

public static CacheCoreH2 create(boolean autoServerMode,
                                 String dbDir,
                                 String dbName,
                                 long lifespan)
                          throws ClassNotFoundException,
                                 SQLException
Loads the driver

Throws:
ClassNotFoundException
SQLException

create

public static CacheCoreEx create(boolean autoServerMode,
                                 String dbDir,
                                 String dbName,
                                 long lifespan,
                                 boolean useCompression)
                          throws ClassNotFoundException,
                                 SQLException
Throws:
ClassNotFoundException
SQLException

create

public static CacheCoreEx create(String dbName,
                                 long lifespan,
                                 boolean useCompression)
                          throws ClassNotFoundException,
                                 SQLException
Throws:
ClassNotFoundException
SQLException

iterator

public Iterator<CacheEntryH2> iterator()
                                throws SQLException
Note: Do not close the InputStream provider on the cache entries as this closes the underlying result set.

Returns:
Throws:
SQLException

lookup

public CacheEntry lookup(String service,
                         String queryString)
Specified by:
lookup in interface CacheCoreEx

_lookup

public CacheEntry _lookup(String service,
                          String queryString)
                   throws SQLException
Throws:
SQLException

write

public void write(String service,
                  String queryString,
                  InputStream in)
Specified by:
write in interface CacheCoreEx

createHashRoot

public String createHashRoot(String service,
                             String queryString)


Copyright © 2012. All Rights Reserved.