예제 #1
0
  protected static void validateTableColumnOfScalarFloat(VoltTable vt, int col, double[] expected) {
    assertNotNull(expected);
    assertEquals(expected.length, vt.getRowCount());
    int len = expected.length;
    for (int i = 0; i < len; i++) {
      assertTrue(vt.advanceRow());
      double actual = vt.getDouble(col);

      if (expected[i] == Double.MIN_VALUE) {
        assertTrue(vt.wasNull());
        assertEquals(null, actual);
      } else {
        assertEquals(expected[i], actual, 0.00001);
      }
    }
  }
예제 #2
0
 private final void loadConfigProfile(VoltTable vt) {
   boolean adv = vt.advanceRow();
   assert (adv)
       : "No data in "
           + SEATSConstants.TABLENAME_CONFIG_PROFILE
           + ". "
           + "Did you forget to load the database first?";
   int col = 0;
   this.scale_factor = vt.getDouble(col++);
   JSONUtil.fromJSONString(this.airport_max_customer_id, vt.getString(col++));
   this.flight_start_date = vt.getTimestampAsTimestamp(col++);
   this.flight_upcoming_date = vt.getTimestampAsTimestamp(col++);
   this.flight_past_days = vt.getLong(col++);
   this.flight_future_days = vt.getLong(col++);
   this.num_flights = vt.getLong(col++);
   this.num_customers = vt.getLong(col++);
   this.num_reservations = vt.getLong(col++);
   if (debug.val)
     LOG.debug(String.format("Loaded %s data", SEATSConstants.TABLENAME_CONFIG_PROFILE));
 }
예제 #3
0
  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 + ", ";

      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);
      }
    }
  }