use of org.apache.hyracks.storage.am.common.CheckTuple in project asterixdb by apache.
the class OrderedIndexTestUtils method bulkLoadStringTuples.
@SuppressWarnings("unchecked")
public void bulkLoadStringTuples(IIndexTestContext ctx, int numTuples, boolean filtered, Random rnd) throws Exception {
int fieldCount = ctx.getFieldCount();
int numKeyFields = ctx.getKeyFieldCount();
String[] fieldValues = new String[fieldCount];
TreeSet<CheckTuple> tmpCheckTuples = new TreeSet<>();
for (int i = 0; i < numTuples; i++) {
// Set keys.
for (int j = 0; j < numKeyFields; j++) {
int length = (Math.abs(rnd.nextInt()) % 10) + 1;
fieldValues[j] = getRandomString(length, rnd);
}
// Set values.
for (int j = numKeyFields; j < fieldCount; j++) {
fieldValues[j] = getRandomString(5, rnd);
}
// Set expected values. We also use these as the pre-sorted stream
// for bulk loading.
ctx.insertCheckTuple(createStringCheckTuple(fieldValues, ctx.getKeyFieldCount()), tmpCheckTuples);
}
bulkLoadCheckTuples(ctx, tmpCheckTuples, filtered);
// Add tmpCheckTuples to ctx check tuples for comparing searches.
for (CheckTuple checkTuple : tmpCheckTuples) {
ctx.insertCheckTuple(checkTuple, ctx.getCheckTuples());
}
}
use of org.apache.hyracks.storage.am.common.CheckTuple in project asterixdb by apache.
the class OrderedIndexTestUtils method getPrefixExpectedSubset.
@SuppressWarnings("unchecked")
public static // work.
SortedSet<CheckTuple> getPrefixExpectedSubset(TreeSet<CheckTuple> checkTuples, CheckTuple lowKey, CheckTuple highKey) {
lowKey.setIsHighKey(false);
highKey.setIsHighKey(true);
CheckTuple low = checkTuples.ceiling(lowKey);
CheckTuple high = checkTuples.floor(highKey);
if (low == null || high == null) {
// Must be empty.
return new TreeSet<>();
}
if (high.compareTo(low) < 0) {
// Must be empty.
return new TreeSet<>();
}
return checkTuples.subSet(low, true, high, true);
}
use of org.apache.hyracks.storage.am.common.CheckTuple in project asterixdb by apache.
the class OrderedIndexTestUtils method insertSortedIntTuples.
@SuppressWarnings("unchecked")
public void insertSortedIntTuples(IIndexTestContext ctx, int numTuples, Random rnd) throws Exception {
int fieldCount = ctx.getFieldCount();
int numKeyFields = ctx.getKeyFieldCount();
int[] fieldValues = new int[ctx.getFieldCount()];
int maxValue = (int) Math.ceil(Math.pow(numTuples, 1.0 / numKeyFields));
Collection<CheckTuple> tmpCheckTuples = createCheckTuplesCollection();
for (int i = 0; i < numTuples; i++) {
// Set keys.
setIntKeyFields(fieldValues, numKeyFields, maxValue, rnd);
// Set values.
setIntPayloadFields(fieldValues, numKeyFields, fieldCount);
// Set expected values. (We also use these as the pre-sorted stream
// for ordered indexes bulk loading).
ctx.insertCheckTuple(createIntCheckTuple(fieldValues, ctx.getKeyFieldCount()), tmpCheckTuples);
}
insertCheckTuples(ctx, tmpCheckTuples);
// Add tmpCheckTuples to ctx check tuples for comparing searches.
for (CheckTuple checkTuple : tmpCheckTuples) {
ctx.insertCheckTuple(checkTuple, ctx.getCheckTuples());
}
}
use of org.apache.hyracks.storage.am.common.CheckTuple in project asterixdb by apache.
the class OrderedIndexTestUtils method checkExpectedResults.
@Override
public void checkExpectedResults(ITreeIndexCursor cursor, Collection checkTuples, ISerializerDeserializer[] fieldSerdes, int keyFieldCount, Iterator<CheckTuple> checkIter) throws Exception {
int actualCount = 0;
try {
while (cursor.hasNext()) {
if (!checkIter.hasNext()) {
fail("Ordered scan returned more answers than expected.\nExpected: " + checkTuples.size());
}
cursor.next();
CheckTuple expectedTuple = checkIter.next();
ITupleReference tuple = cursor.getTuple();
compareActualAndExpected(tuple, expectedTuple, fieldSerdes);
actualCount++;
}
if (actualCount < checkTuples.size()) {
fail("Ordered scan returned fewer answers than expected.\nExpected: " + checkTuples.size() + "\nActual : " + actualCount);
}
} finally {
cursor.close();
}
}
use of org.apache.hyracks.storage.am.common.CheckTuple in project asterixdb by apache.
the class OrderedIndexTestUtils method insertSortedStringTuples.
@SuppressWarnings("unchecked")
public void insertSortedStringTuples(IIndexTestContext ctx, int numTuples, Random rnd) throws Exception {
int fieldCount = ctx.getFieldCount();
int numKeyFields = ctx.getKeyFieldCount();
String[] fieldValues = new String[fieldCount];
TreeSet<CheckTuple> tmpCheckTuples = new TreeSet<>();
for (int i = 0; i < numTuples; i++) {
// Set keys.
for (int j = 0; j < numKeyFields; j++) {
int length = (Math.abs(rnd.nextInt()) % 10) + 1;
fieldValues[j] = getRandomString(length, rnd);
}
// Set values.
for (int j = numKeyFields; j < fieldCount; j++) {
fieldValues[j] = getRandomString(5, rnd);
}
// Set expected values. We also use these as the pre-sorted stream
// for bulk loading.
ctx.insertCheckTuple(createStringCheckTuple(fieldValues, ctx.getKeyFieldCount()), tmpCheckTuples);
}
insertCheckTuples(ctx, tmpCheckTuples);
// Add tmpCheckTuples to ctx check tuples for comparing searches.
for (CheckTuple checkTuple : tmpCheckTuples) {
ctx.insertCheckTuple(checkTuple, ctx.getCheckTuples());
}
}
Aggregations