use of jnc.platform.win32.Handle in project airpal by airbnb.
the class JobHistoryStoreDAO method getJobs.
private List<Job> getJobs(long limit, int dayInterval, String outerWhereClauseArg, String innerWhereClauseArg) {
String outerWhereClause = Strings.isNullOrEmpty(outerWhereClauseArg) ? "true" : outerWhereClauseArg;
String innerWhereClause = Strings.isNullOrEmpty(innerWhereClauseArg) ? "true" : innerWhereClauseArg;
try (Handle handle = dbi.open()) {
Query<Map<String, Object>> query = handle.createQuery("SELECT " + "j.id AS id, " + "j.query AS query, " + "j.user AS user, " + "j.uuid AS uuid, " + "j.queryStats as queryStats, " + "j.state AS state, " + "j.columns AS columns, " + "j.query_finished AS queryFinished, " + "j.query_started AS queryStarted, " + "j.error AS error, " + "t.connector_id AS connectorId, " + "t.schema_ AS \"schema\", " + "t.table_ AS \"table\", " + "t.columns, " + "jo.type, " + "jo.description, " + "jo.location " + "FROM (SELECT * FROM jobs " + "WHERE " + Util.getQueryFinishedCondition(dbType) + " " + "AND " + innerWhereClause + " " + "ORDER BY query_finished DESC LIMIT :limit) j " + "LEFT OUTER JOIN job_tables jt ON j.id = jt.job_id " + "LEFT OUTER JOIN tables t ON jt.table_id = t.id " + "LEFT OUTER JOIN job_outputs jo ON j.id = jo.job_id " + "WHERE " + outerWhereClause + " " + "ORDER BY query_finished DESC").bind("limit", limit).bind("day_interval", dayInterval);
Map<Long, Job> idToJobMap = query.map(RosettaResultSetMapperFactory.mapperFor(JobTableOutputJoinRow.class)).fold(new HashMap<Long, Job>(), new JobTableOutputJoinRow.JobFolder());
return new ArrayList<>(idToJobMap.values());
}
}
use of jnc.platform.win32.Handle in project hive by apache.
the class TestDruidStorageHandler method testPreCreateTableWillCreateSegmentsTable.
@Test
public void testPreCreateTableWillCreateSegmentsTable() throws MetaException {
try (Handle handle = derbyConnectorRule.getConnector().getDBI().open()) {
Assert.assertFalse(derbyConnectorRule.getConnector().tableExists(handle, segmentsTable));
druidStorageHandler.preCreateTable(tableMock);
Assert.assertTrue(derbyConnectorRule.getConnector().tableExists(handle, segmentsTable));
}
}
use of jnc.platform.win32.Handle in project pac4j by pac4j.
the class DbProfileService method execute.
protected void execute(final String query, final Object... args) {
Handle h = null;
try {
h = dbi.open();
logger.debug("Execute query: {} and values: {}", query, args);
h.execute(query, args);
} finally {
if (h != null) {
h.close();
}
}
}
use of jnc.platform.win32.Handle in project pac4j by pac4j.
the class DbProfileServiceTests method getData.
private List<Map<String, Object>> getData(final int id) {
final var dbi = new DBI(ds);
Handle h = null;
try {
h = dbi.open();
return h.createQuery("select id,username,linkedid,password,serializedprofile from users where id = :id").bind("id", id).list(2);
} finally {
if (h != null) {
h.close();
}
}
}
use of jnc.platform.win32.Handle in project killbill by killbill.
the class BaseIdCacheLoader method load.
@Override
public Object load(final Object key, final Object argument) {
checkCacheLoaderStatus();
if (!(key instanceof String)) {
throw new IllegalArgumentException("Unexpected key type of " + key.getClass().getName());
}
if (!(argument instanceof CacheLoaderArgument)) {
throw new IllegalArgumentException("Unexpected key type of " + argument.getClass().getName());
}
final String rawKey;
if (getCacheType().isKeyPrefixedWithTableName()) {
final String[] parts = ((String) key).split(CacheControllerDispatcher.CACHE_KEY_SEPARATOR);
rawKey = parts[1];
} else {
rawKey = (String) key;
}
final ObjectType objectType = ((CacheLoaderArgument) argument).getObjectType();
final Handle handle = ((CacheLoaderArgument) argument).getHandle();
return doRetrieveOperation(rawKey, objectType, handle);
}
Aggregations