@SuppressWarnings("unchecked") public void insertDoubleTuples(IIndexTestContext ctx, int numTuples, Random rnd) throws Exception { int fieldCount = ctx.getFieldCount(); int numKeyFields = ctx.getKeyFieldCount(); double[] fieldValues = new double[ctx.getFieldCount()]; // Scale range of values according to number of keys. // For example, for 2 keys we want the square root of numTuples, for 3 // keys the cube root of numTuples, etc. double maxValue = Math.ceil(Math.pow(numTuples, 1.0 / (double) numKeyFields)); for (int i = 0; i < numTuples; i++) { // Set keys. setDoubleKeyFields(fieldValues, numKeyFields, maxValue, rnd); // Set values. setDoublePayloadFields(fieldValues, numKeyFields, fieldCount); TupleUtils.createDoubleTuple(ctx.getTupleBuilder(), ctx.getTuple(), fieldValues); if (LOGGER.isLoggable(Level.INFO)) { if ((i + 1) % (numTuples / Math.min(10, numTuples)) == 0) { LOGGER.info("Inserting Tuple " + (i + 1) + "/" + numTuples); } } try { ctx.getIndexAccessor().insert(ctx.getTuple()); ctx.insertCheckTuple( createDoubleCheckTuple(fieldValues, ctx.getKeyFieldCount()), ctx.getCheckTuples()); } catch (TreeIndexException e) { // We set expected values only after insertion succeeds because // we // ignore duplicate keys. } } }
@SuppressWarnings("unchecked") public void bulkLoadDoubleTuples(IIndexTestContext ctx, int numTuples, Random rnd) throws Exception { int fieldCount = ctx.getFieldCount(); int numKeyFields = ctx.getKeyFieldCount(); double[] fieldValues = new double[ctx.getFieldCount()]; double maxValue = Math.ceil(Math.pow(numTuples, 1.0 / (double) numKeyFields)); Collection<CheckTuple> tmpCheckTuples = createCheckTuplesCollection(); for (int i = 0; i < numTuples; i++) { // Set keys. setDoubleKeyFields(fieldValues, numKeyFields, maxValue, rnd); // Set values. setDoublePayloadFields(fieldValues, numKeyFields, fieldCount); // Set expected values. ctx.insertCheckTuple( createDoubleCheckTuple(fieldValues, ctx.getKeyFieldCount()), tmpCheckTuples); } bulkLoadCheckTuples(ctx, tmpCheckTuples); // Add tmpCheckTuples to ctx check tuples for comparing searches. for (CheckTuple checkTuple : tmpCheckTuples) { ctx.insertCheckTuple(checkTuple, ctx.getCheckTuples()); } }
@Override protected boolean checkDiskOrderScanResult( ITupleReference tuple, CheckTuple checkTuple, IIndexTestContext ctx) throws HyracksDataException { return ctx.getCheckTuples().contains(checkTuple); }