Beispiel #1
0
 // ALL OF THE VALIDATION SCHEMAS IN THIS TEST ARE BASED OFF OF
 // THE VOLTDB DOCS, RATHER THAN REUSING THE CODE THAT GENERATES THEM.
 // IN SOME MAGICAL FUTURE MAYBE THEY ALL CAN BE GENERATED FROM THE
 // SAME METADATA.
 protected static void validateSchema(VoltTable result, VoltTable expected) {
   assertEquals(expected.getColumnCount(), result.getColumnCount());
   for (int i = 0; i < result.getColumnCount(); i++) {
     assertEquals("Failed name column: " + i, expected.getColumnName(i), result.getColumnName(i));
     assertEquals("Failed type column: " + i, expected.getColumnType(i), result.getColumnType(i));
   }
 }
Beispiel #2
0
  protected void assertTablesAreEqual(String prefix, VoltTable expectedRows, VoltTable actualRows) {
    assertEquals(
        prefix
            + "column count mismatch.  Expected: "
            + expectedRows.getColumnCount()
            + " actual: "
            + actualRows.getColumnCount(),
        expectedRows.getColumnCount(),
        actualRows.getColumnCount());

    int i = 0;
    while (expectedRows.advanceRow()) {
      assertTrue(
          prefix + "too few actual rows; expected more than " + (i + 1), actualRows.advanceRow());

      for (int j = 0; j < actualRows.getColumnCount(); j++) {
        String columnName = actualRows.getColumnName(j);
        String colPrefix = prefix + "row " + i + ": column: " + columnName + ": ";
        VoltType actualTy = actualRows.getColumnType(j);
        VoltType expectedTy = expectedRows.getColumnType(j);
        assertEquals(colPrefix + "type mismatch", expectedTy, actualTy);

        Object expectedObj = expectedRows.get(j, expectedTy);
        Object actualObj = expectedRows.get(j, actualTy);
        assertEquals(
            colPrefix + "values not equal: expected: " + expectedObj + ", actual: " + actualObj,
            expectedObj,
            actualObj);
      }

      i++;
    }
    assertFalse(prefix + "too many actual rows; expected only " + i, actualRows.advanceRow());
  }
Beispiel #3
0
  /** Populate Subscriber table per benchmark spec. */
  void genSubscriber(Table catalog_tbl) {
    final VoltTable table = CatalogUtil.getVoltTable(catalog_tbl);
    Object row[] = new Object[table.getColumnCount()];
    long total = 0;
    for (long s_id = 0; s_id < this.subscriberSize; s_id++) {
      int col = 0;
      row[col++] = s_id;
      row[col++] = TM1Util.padWithZero(s_id);

      // BIT_##
      for (int j = 0; j < 10; j++) {
        row[col++] = TM1Util.number(0, 1);
      } // FOR
      // HEX_##
      for (int j = 0; j < 10; j++) {
        row[col++] = TM1Util.number(0, 15);
      }
      // BYTE2_##
      for (int j = 0; j < 10; j++) {
        row[col++] = TM1Util.number(0, 255);
      }
      // MSC_LOCATION + VLR_LOCATION
      for (int j = 0; j < 2; j++) {
        row[col++] = TM1Util.number(0, Integer.MAX_VALUE);
      }
      assert col == table.getColumnCount();
      table.addRow(row);
      total++;

      if (table.getRowCount() >= TM1Constants.BATCH_SIZE) {
        if (d)
          LOG.debug(
              String.format(
                  "%s: %6d / %d", TM1Constants.TABLENAME_SUBSCRIBER, total, this.subscriberSize));
        loadVoltTable(TM1Constants.TABLENAME_SUBSCRIBER, table);
        table.clearRowData();
        assert (table.getRowCount() == 0);
      }
    } // FOR
    if (table.getRowCount() > 0) {
      if (d)
        LOG.debug(
            String.format(
                "%s: %6d / %d", TM1Constants.TABLENAME_SUBSCRIBER, total, this.subscriberSize));
      loadVoltTable(TM1Constants.TABLENAME_SUBSCRIBER, table);
      table.clearRowData();
      assert (table.getRowCount() == 0);
    }
  }
  private VoltTable evictData(Table catalog_tbl) throws Exception {
    VoltTable results[] = this.ee.getStats(SysProcSelector.TABLE, this.locators, false, 0L);
    assertEquals(1, results.length);
    // System.err.println(VoltTableUtil.format(results));
    while (results[0].advanceRow()) {
      if (results[0].getString("TABLE_NAME").equalsIgnoreCase(catalog_tbl.getName()) == false)
        continue;
      for (String col : statsFields) {
        int idx = results[0].getColumnIndex(col);
        assertEquals(0, results[0].getLong(idx));
      } // FOR
    } // WHILE

    // Now force the EE to evict our boys out
    // We'll tell it to remove 1MB, which is guaranteed to include all of our tuples
    VoltTable evictResult = this.ee.antiCacheEvictBlock(catalog_tbl, 1024 * 1024, 1);

    //        System.err.println("-------------------------------");
    //        System.err.println(VoltTableUtil.format(evictResult));
    assertNotNull(evictResult);
    assertEquals(1, evictResult.getRowCount());
    assertNotSame(results[0].getColumnCount(), evictResult.getColumnCount());
    evictResult.resetRowPosition();
    boolean adv = evictResult.advanceRow();
    assertTrue(adv);
    return (evictResult);
  }
Beispiel #5
0
 /** Called from the ExecutionEngine to request serialized dependencies. */
 public byte[] nextDependencyAsBytes(final int dependencyId) {
   final VoltTable vt = m_dependencyTracker.nextDependency(dependencyId);
   if (vt != null) {
     ByteBuffer buffer = vt.getDirectDataReference();
     if (d)
       LOG.debug(
           String.format(
               "Passing Dependency %d to EE [rows=%d, cols=%d, bytes=%d/%d]\n%s",
               dependencyId,
               vt.getRowCount(),
               vt.getColumnCount(),
               vt.getUnderlyingBufferSize(),
               buffer.array().length,
               vt.toString()));
     assert (buffer.hasArray());
     return (buffer.array());
   }
   // Note that we will hit this after retrieving all the VoltTables for the given dependencyId
   // It does not mean that there were no VoltTables at all, it just means that
   // we have gotten all of them
   else if (d) {
     LOG.warn(
         String.format(
             "Failed to find Dependency %d for EE [dep=%s, count=%d, ids=%s]",
             dependencyId,
             m_dependencyTracker.m_depsById.get(dependencyId),
             m_dependencyTracker.m_depsById.size(),
             m_dependencyTracker.m_depsById.keySet()));
   }
   return null;
 }
 private void validateSubqueryWithWindowedAggregate(Client client, String sql)
     throws IOException, NoConnectionsException, ProcCallException {
   ClientResponse cr;
   VoltTable vt;
   cr = client.callProcedure("@AdHoc", sql);
   assertEquals(ClientResponse.SUCCESS, cr.getStatus());
   vt = cr.getResults()[0];
   int nc = vt.getColumnCount();
   while (vt.advanceRow()) {
     assertEquals(vt.getLong(nc - 2), vt.getLong(nc - 1));
   }
 }
 @Override
 public void printTable(PrintStream stream, VoltTable t, boolean includeColumnNames)
     throws IOException {
   final int columnCount = t.getColumnCount();
   List<VoltType> columnTypes = new ArrayList<VoltType>(columnCount);
   for (int i = 0; i < columnCount; i++) {
     columnTypes.add(t.getColumnType(i));
   }
   CSVWriter csvWriter = new CSVWriter(new OutputStreamWriter(stream));
   if (includeColumnNames) {
     String[] columnNames = new String[columnCount];
     for (int i = 0; i < columnCount; i++) {
       columnNames[i] = t.getColumnName(i);
     }
     csvWriter.writeNext(columnNames);
   }
   VoltTableUtil.toCSVWriter(csvWriter, t, columnTypes);
 }
Beispiel #8
0
  /** Populate Access_Info table per benchmark spec. */
  void genAccessInfo(Table catalog_tbl) {
    final VoltTable table = CatalogUtil.getVoltTable(catalog_tbl);
    int[] arr = {1, 2, 3, 4};

    int[] ai_types = TM1Util.subArr(arr, 1, 4);
    long total = 0;
    for (long s_id = 0; s_id < this.subscriberSize; s_id++) {
      for (int ai_type : ai_types) {
        Object row[] = new Object[table.getColumnCount()];
        row[0] = s_id;
        row[1] = ai_type;
        row[2] = TM1Util.number(0, 255);
        row[3] = TM1Util.number(0, 255);
        row[4] = TM1Util.astring(3, 3);
        row[5] = TM1Util.astring(5, 5);
        table.addRow(row);
        total++;
      } // FOR
      if (table.getRowCount() >= TM1Constants.BATCH_SIZE) {
        if (d)
          LOG.debug(
              String.format(
                  "%s: %6d / %d",
                  TM1Constants.TABLENAME_ACCESS_INFO, total, ai_types.length * subscriberSize));
        loadVoltTable(TM1Constants.TABLENAME_ACCESS_INFO, table);
        table.clearRowData();
      }
    } // WHILE
    if (table.getRowCount() > 0) {
      if (d)
        LOG.debug(
            String.format(
                "%s: %6d / %d",
                TM1Constants.TABLENAME_ACCESS_INFO, total, ai_types.length * subscriberSize));
      loadVoltTable(TM1Constants.TABLENAME_ACCESS_INFO, table);
      table.clearRowData();
    }
  }
Beispiel #9
0
  /** Populate Special_Facility table and CallForwarding table per benchmark spec. */
  void genSpeAndCal(Table catalog_spe, Table catalog_cal) {
    VoltTable speTbl = CatalogUtil.getVoltTable(catalog_spe);
    VoltTable calTbl = CatalogUtil.getVoltTable(catalog_cal);

    long speTotal = 0;
    long calTotal = 0;
    int[] arrSpe = {1, 2, 3, 4};
    int[] arrCal = {0, 8, 6};

    for (long s_id = 0; s_id < this.subscriberSize; s_id++) {
      int[] sf_types = TM1Util.subArr(arrSpe, 1, 4);
      for (int sf_type : sf_types) {
        Object row_spe[] = new Object[speTbl.getColumnCount()];
        row_spe[0] = s_id;
        row_spe[1] = sf_type;
        row_spe[2] = TM1Util.isActive();
        row_spe[3] = TM1Util.number(0, 255);
        row_spe[4] = TM1Util.number(0, 255);
        row_spe[5] = TM1Util.astring(5, 5);
        speTbl.addRow(row_spe);
        speTotal++;

        // now call_forwarding
        int[] start_times = TM1Util.subArr(arrCal, 0, 3);
        for (int start_time : start_times) {
          Object row_cal[] = new Object[calTbl.getColumnCount()];
          row_cal[0] = s_id;
          row_cal[1] = sf_type;
          row_cal[2] = start_time;
          row_cal[3] = start_time + TM1Util.number(1, 8);
          row_cal[4] = TM1Util.nstring(15, 15);
          calTbl.addRow(row_cal);
          calTotal++;
        } // FOR
      } // FOR

      if (calTbl.getRowCount() >= TM1Constants.BATCH_SIZE) {
        if (d) LOG.debug(String.format("%s: %d", TM1Constants.TABLENAME_CALL_FORWARDING, calTotal));
        loadVoltTable(TM1Constants.TABLENAME_CALL_FORWARDING, calTbl);
        calTbl.clearRowData();
        assert (calTbl.getRowCount() == 0);
      }
      if (speTbl.getRowCount() >= TM1Constants.BATCH_SIZE) {
        if (d)
          LOG.debug(String.format("%s: %d", TM1Constants.TABLENAME_SPECIAL_FACILITY, speTotal));
        loadVoltTable(TM1Constants.TABLENAME_SPECIAL_FACILITY, speTbl);
        speTbl.clearRowData();
        assert (speTbl.getRowCount() == 0);
      }
    } // WHILE
    if (calTbl.getRowCount() > 0) {
      if (d) LOG.debug(String.format("%s: %d", TM1Constants.TABLENAME_CALL_FORWARDING, calTotal));
      loadVoltTable(TM1Constants.TABLENAME_CALL_FORWARDING, calTbl);
      calTbl.clearRowData();
      assert (calTbl.getRowCount() == 0);
    }
    if (speTbl.getRowCount() > 0) {
      if (d) LOG.debug(String.format("%s: %d", TM1Constants.TABLENAME_SPECIAL_FACILITY, speTotal));
      loadVoltTable(TM1Constants.TABLENAME_SPECIAL_FACILITY, speTbl);
      speTbl.clearRowData();
      assert (speTbl.getRowCount() == 0);
    }
  }