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

Method testSelectRange

java/unittests/EnvironmentTest.java:354–405  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

352 }
353
354 public void testSelectRange() {
355 byte[] k = new byte[5];
356 byte[] r = new byte[5];
357 Environment env = new Environment();
358 Database db = null;
359 Cursor c = null;
360 try {
361 env.create("jtest.db");
362 db = env.createDatabase((short)1);
363 for (int i = 0; i < 100; i++) {
364 k[0] = (byte)i;
365 r[0] = (byte)i;
366 db.insert(k, r);
367 }
368
369 k[0] = 50;
370 c = new Cursor(db);
371 c.find(k);
372 assertByteArrayEquals(c.getRecord(), k);
373
374 Result result1 = env.selectRange("COUNT($key) FROM DATABASE 1", null, c);
375 assertEquals(result1.getRowCount(), 1);
376 assertEquals(result1.getKeyType(), Const.UPS_TYPE_BINARY);
377
378 byte[] r1 = result1.getRecordData();
379 ByteBuffer b1 = ByteBuffer.wrap(r1);
380 b1.order(ByteOrder.LITTLE_ENDIAN);
381 assertEquals(b1.getInt(), 50);
382 Result result2 = env.selectRange("COUNT($key) FROM DATABASE 1", c, null);
383 assertEquals(result2.getRowCount(), 1);
384
385 byte[] r2 = result2.getRecordData();
386 ByteBuffer b2 = ByteBuffer.wrap(r2);
387 b2.order(ByteOrder.LITTLE_ENDIAN);
388 assertEquals(b2.getInt(), 50);
389 }
390 catch (DatabaseException err) {
391 fail("Exception "+err);
392 }
393
394 boolean failed = false;
395 try {
396 c.move(Const.UPS_CURSOR_NEXT); // must fail
397 }
398 catch (DatabaseException err) {
399 failed = true;
400 }
401 assertEquals(failed, true);
402
403 db.close();
404 env.close();
405 }
406
407}

Callers

nothing calls this directly

Calls 13

createMethod · 0.95
createDatabaseMethod · 0.95
insertMethod · 0.95
findMethod · 0.95
assertByteArrayEqualsMethod · 0.95
getRecordMethod · 0.95
selectRangeMethod · 0.95
getRowCountMethod · 0.95
getKeyTypeMethod · 0.95
getRecordDataMethod · 0.95
moveMethod · 0.95
closeMethod · 0.95

Tested by

no test coverage detected