use of org.h2.store.Data in project jackrabbit-oak by apache.
the class BlobCache method addGeneration.
@Override
public void addGeneration(int generation, boolean readOnly) {
CacheMap<Long, byte[]> d = cache.openMap(generation, "data", new MVMap.Builder<Long, byte[]>());
data.addReadMap(generation, d);
CacheMap<String, byte[]> m = cache.openMap(generation, "meta", new MVMap.Builder<String, byte[]>());
meta.addReadMap(generation, m);
if (!readOnly) {
// the order is important:
// if we switch the data first,
// we could end up with the data in store 1
// but the metadata in store 2 - which could
// result in a data block not found if store 1
// is removed later on
meta.setWriteMap(m);
data.setWriteMap(d);
}
if (streamStore == null) {
streamStore = new StreamStore(data);
}
}
use of org.h2.store.Data in project siena by mandubian.
the class FullText method indexExistingRows.
/**
* Add the existing data to the index.
*
* @param conn the database connection
* @param schema the schema name
* @param table the table name
*/
protected static void indexExistingRows(Connection conn, String schema, String table) throws SQLException {
FullText.FullTextTrigger existing = new FullText.FullTextTrigger();
existing.init(conn, schema, null, table, false, Trigger.INSERT);
String sql = "SELECT * FROM " + StringUtils.quoteIdentifier(schema) + "." + StringUtils.quoteIdentifier(table);
ResultSet rs = conn.createStatement().executeQuery(sql);
int columnCount = rs.getMetaData().getColumnCount();
while (rs.next()) {
Object[] row = new Object[columnCount];
for (int i = 0; i < columnCount; i++) {
row[i] = rs.getObject(i + 1);
}
existing.fire(conn, null, row);
}
}
use of org.h2.store.Data in project siena by mandubian.
the class FullText method addColumnData.
private static void addColumnData(ArrayList<String> columns, ArrayList<String> data, Expression expr) {
if (expr instanceof ConditionAndOr) {
ConditionAndOr and = (ConditionAndOr) expr;
Expression left = and.getExpression(true);
Expression right = and.getExpression(false);
addColumnData(columns, data, left);
addColumnData(columns, data, right);
} else {
Comparison comp = (Comparison) expr;
ExpressionColumn ec = (ExpressionColumn) comp.getExpression(true);
ValueExpression ev = (ValueExpression) comp.getExpression(false);
String columnName = ec.getColumnName();
columns.add(columnName);
if (ev == null) {
data.add(null);
} else {
data.add(ev.getValue(null).getString());
}
}
}
use of org.h2.store.Data in project ignite by apache.
the class DbH2ServerStartup method main.
/**
* Start H2 database TCP server.
*
* @param args Command line arguments, none required.
* @throws IgniteException If start H2 database TCP server failed.
*/
public static void main(String[] args) throws IgniteException {
try {
// Start H2 database TCP server in order to access sample in-memory database from other processes.
Server.createTcpServer("-tcpDaemon").start();
populateDatabase();
// Try to connect to database TCP server.
JdbcConnectionPool dataSrc = JdbcConnectionPool.create("jdbc:h2:tcp://localhost/mem:ExampleDb", "sa", "");
// Create Person table in database.
RunScript.execute(dataSrc.getConnection(), new StringReader(CREATE_PERSON_TABLE));
// Populates Person table with sample data in database.
RunScript.execute(dataSrc.getConnection(), new StringReader(POPULATE_PERSON_TABLE));
} catch (SQLException e) {
throw new IgniteException("Failed to start database TCP server", e);
}
try {
do {
System.out.println("Type 'q' and press 'Enter' to stop H2 TCP server...");
} while ('q' != System.in.read());
} catch (IOException ignored) {
// No-op.
}
}
use of org.h2.store.Data in project ignite by apache.
the class DbH2ServerStartup method populateDatabase.
/**
* Populate sample database.
*
* @throws SQLException if
*/
public static void populateDatabase() throws SQLException {
// Try to connect to database TCP server.
JdbcConnectionPool dataSrc = JdbcConnectionPool.create("jdbc:h2:tcp://localhost/mem:ExampleDb", "sa", "");
// Create Person table in database.
RunScript.execute(dataSrc.getConnection(), new StringReader(CREATE_PERSON_TABLE));
// Populates Person table with sample data in database.
RunScript.execute(dataSrc.getConnection(), new StringReader(POPULATE_PERSON_TABLE));
}
Aggregations