MCPcopy Create free account
hub / github.com/cruppstahl/upscaledb / testSelect

Method testSelect

java/unittests/EnvironmentTest.java:318–352  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

316 }
317
318 public void testSelect() {
319 byte[] k = new byte[5];
320 byte[] r = new byte[5];
321 Database db;
322 Environment env = new Environment();
323 try {
324 env.create("jtest.db");
325 db = env.createDatabase((short)1);
326 for (int i = 0; i < 100; i++) {
327 k[0] = (byte)i;
328 r[0] = (byte)i;
329 db.insert(k, r);
330 }
331
332 Result result = env.select("COUNT($key) FROM DATABASE 1");
333 assertEquals(result.getRowCount(), 1);
334 assertEquals(result.getKeyType(), Const.UPS_TYPE_BINARY);
335
336 byte[] r1 = result.getRecordData();
337 ByteBuffer b1 = ByteBuffer.wrap(r1);
338 b1.order(ByteOrder.LITTLE_ENDIAN);
339 assertEquals(b1.getInt(), 100);
340
341 byte[] r2 = result.getRecord(0);
342 ByteBuffer b2 = ByteBuffer.wrap(r2);
343 b2.order(ByteOrder.LITTLE_ENDIAN);
344 assertEquals(b2.getInt(), 100);
345
346 db.close();
347 }
348 catch (DatabaseException err) {
349 fail("Exception "+err);
350 }
351 env.close();
352 }
353
354 public void testSelectRange() {
355 byte[] k = new byte[5];

Callers

nothing calls this directly

Calls 10

createMethod · 0.95
createDatabaseMethod · 0.95
insertMethod · 0.95
selectMethod · 0.95
getRowCountMethod · 0.95
getKeyTypeMethod · 0.95
getRecordDataMethod · 0.95
getRecordMethod · 0.95
closeMethod · 0.95
closeMethod · 0.95

Tested by

no test coverage detected