use of org.voltdb.VoltType in project voltdb by VoltDB.
the class RegressionSuite method assertTablesAreEqual.
protected void assertTablesAreEqual(String prefix, VoltTable expectedRows, VoltTable actualRows, Double epsilon) {
assertEquals(prefix + "column count mismatch. Expected: " + expectedRows.getColumnCount() + " actual: " + actualRows.getColumnCount(), expectedRows.getColumnCount(), actualRows.getColumnCount());
if (expectedRows.getRowCount() != actualRows.getRowCount()) {
long expRowCount = expectedRows.getRowCount();
long actRowCount = actualRows.getRowCount();
if (expRowCount + actRowCount < TOO_MUCH_INFO) {
System.out.println("Expected: " + expectedRows);
System.out.println("Actual: " + actualRows);
} else {
System.out.println("Expected: " + expRowCount + " rows");
System.out.println("Actual: " + actRowCount + " rows");
}
fail(prefix + "row count mismatch. Expected: " + expectedRows.getRowCount() + " actual: " + actualRows.getRowCount());
}
int rowNum = 1;
while (expectedRows.advanceRow()) {
if (!actualRows.advanceRow()) {
fail(prefix + "too few actual rows; expected more than " + rowNum);
}
for (int j = 0; j < actualRows.getColumnCount(); j++) {
String columnName = actualRows.getColumnName(j);
String colPrefix = prefix + "row " + rowNum + ": column: " + columnName + ": ";
VoltType actualType = actualRows.getColumnType(j);
VoltType expectedType = expectedRows.getColumnType(j);
assertEquals(colPrefix + "type mismatch", expectedType, actualType);
Object expectedObj = expectedRows.get(j, expectedType);
Object actualObj = actualRows.get(j, actualType);
if (expectedRows.wasNull()) {
if (actualRows.wasNull()) {
continue;
}
fail(colPrefix + "expected null, got non null value: " + actualObj);
} else {
assertFalse(colPrefix + "expected the value " + expectedObj + ", got a null value.", actualRows.wasNull());
String message = colPrefix + "values not equal: ";
if (expectedType == VoltType.FLOAT) {
if (epsilon != null) {
assertEquals(message, (Double) expectedObj, (Double) actualObj, epsilon);
continue;
}
// With no epsilon provided, fall through to take
// a chance on an exact value match, but helpfully
// annotate any false positive that results.
message += ". NOTE: You may want to pass a" + " non-null epsilon value >= " + Math.abs((Double) expectedObj - (Double) actualObj) + " to the table comparison test " + " if nearly equal FLOAT values are " + " causing a false mismatch.";
}
assertEquals(message, expectedObj, actualObj);
}
}
rowNum++;
}
}
use of org.voltdb.VoltType in project voltdb by VoltDB.
the class RegressionSuite method validateRowOfLongs.
protected static void validateRowOfLongs(String messagePrefix, VoltTable vt, long[] expected) {
int len = expected.length;
assertTrue(vt.advanceRow());
for (int i = 0; i < len; i++) {
String message = messagePrefix + "at column " + (i + 1) + ", ";
long actual = -10000000;
// ENG-4295: hsql bug: HSQLBackend sometimes returns wrong column type.
try {
actual = vt.getLong(i);
} catch (IllegalArgumentException ex) {
try {
actual = (long) vt.getDouble(i);
} catch (IllegalArgumentException newEx) {
try {
actual = vt.getTimestampAsLong(i);
} catch (IllegalArgumentException exTm) {
try {
actual = vt.getDecimalAsBigDecimal(i).longValueExact();
} catch (IllegalArgumentException newerEx) {
newerEx.printStackTrace();
fail(message);
}
} catch (ArithmeticException newestEx) {
newestEx.printStackTrace();
fail(message);
}
}
}
// Long.MIN_VALUE is like a NULL
if (expected[i] != Long.MIN_VALUE) {
assertEquals(message, expected[i], actual);
} else {
VoltType type = vt.getColumnType(i);
assertEquals(message + "expected null: ", Long.parseLong(type.getNullValue().toString()), actual);
}
}
}
use of org.voltdb.VoltType in project voltdb by VoltDB.
the class CatalogSizing method getColumnsSize.
private static CatalogItemSizeBase getColumnsSize(List<Column> columns, boolean forIndex, boolean bAdjustForDrAA) {
// See http://voltdb.com/docs/PlanningGuide/ChapMemoryRecs.php
CatalogItemSizeBase csize = new CatalogItemSizeBase();
for (Column column : columns) {
VoltType ctype = VoltType.get((byte) column.getType());
boolean isNullable = column.getNullable();
if (ctype.isVariableLength()) {
int capacity = column.getSize();
if (ctype == VoltType.STRING && !column.getInbytes()) {
capacity *= MAX_BYTES_PER_UTF8_CHARACTER;
}
csize.widthMin += getVariableColumnSize(ctype, capacity, 0, forIndex, isNullable);
csize.widthMax += getVariableColumnSize(ctype, capacity, capacity, forIndex, false);
} else {
// Fixed type - use the fixed size.
csize.widthMin += ctype.getLengthInBytesForFixedTypes();
csize.widthMax += ctype.getLengthInBytesForFixedTypes();
}
}
//For DR active active enabled account for additional timestamp column for conflict detection.
if (bAdjustForDrAA) {
csize.widthMin += 8;
csize.widthMax += 8;
}
return csize;
}
use of org.voltdb.VoltType in project voltdb by VoltDB.
the class TestPlansSubQueries method testGeneratedNamesDontConflict.
/*
* ENG-10497 wants to make generated column names not conflict with
* user column names.
*/
public void testGeneratedNamesDontConflict() {
String sql = "select C1 from ( select cast(a as varchar), c as c1 from r5 ) as SQ where SQ.C1 < 0;";
AbstractPlanNode pn = compile(sql);
assertNotNull(pn);
VoltType vt = pn.getOutputSchema().getColumns().get(0).getType();
assert (VoltType.INTEGER.equals(vt));
}
use of org.voltdb.VoltType in project voltdb by VoltDB.
the class AbstractExpression method hasInlineVarType.
public static boolean hasInlineVarType(AbstractExpression expr) {
VoltType type = expr.getValueType();
int size = expr.getValueSize();
boolean inBytes = expr.getInBytes();
switch(type) {
case STRING:
if (inBytes && size < 64) {
return true;
}
if (!inBytes && size < 16) {
return true;
}
break;
case VARBINARY:
if (size < 64) {
return true;
}
break;
default:
break;
}
return false;
}
Aggregations