@Override
  public void setup(Context.OperatorContext context) {
    super.setup(context);

    LOG.info("Done setting up super");
    aggregatorRegistry.setup();

    // Create prepared statements
    schema = new DimensionalConfigurationSchema(eventSchema, aggregatorRegistry);

    List<FieldsDescriptor> keyFDs = schema.getDimensionsDescriptorIDToKeyDescriptor();

    for (int ddID = 0; ddID < keyFDs.size(); ddID++) {

      LOG.info("ddID {}", ddID);
      FieldsDescriptor keyFD = keyFDs.get(ddID);
      Int2ObjectMap<FieldsDescriptor> aggIDToAggFD =
          schema.getDimensionsDescriptorIDToAggregatorIDToOutputAggregatorDescriptor().get(ddID);

      Map<Integer, PreparedStatement> aggIDToStatement = ddIDToAggIDToStatement.get(ddID);

      if (aggIDToStatement == null) {
        aggIDToStatement = Maps.newHashMap();
        ddIDToAggIDToStatement.put(ddID, aggIDToStatement);
      }

      for (Map.Entry<String, String> aggTable : tableNames.get(ddID).entrySet()) {
        int aggID = aggregatorRegistry.getIncrementalAggregatorNameToID().get(aggTable.getKey());

        LOG.info("aggID {}", aggID);
        FieldsDescriptor aggFD = aggIDToAggFD.get(aggID);

        List<String> keyNames = keyFD.getFieldList();
        keyNames.remove(DimensionsDescriptor.DIMENSION_TIME_BUCKET);
        List<String> aggregateNames = aggFD.getFieldList();
        String tableName = aggTable.getValue();

        String statementString = buildStatement(tableName, keyNames, aggregateNames);

        try {
          aggIDToStatement.put(aggID, store.getConnection().prepareStatement(statementString));
        } catch (SQLException ex) {
          throw new RuntimeException(ex);
        }
      }
    }
  }
  @Override
  public GPOMutable convert(Map<String, Object> inputEvent) {
    FieldsDescriptor fd = schema.getValuesDescriptor();
    GPOMutable values = new GPOMutable(fd);

    List<String> fields = fd.getFieldList();

    for (int index = 0; index < fields.size(); index++) {
      String field = fields.get(index);
      values.setFieldGeneric(field, inputEvent.get(getMapField(field)));
    }

    return values;
  }
  /**
   * @param ps The {@link java.sql.PreparedStatement} which will do an insert into the Mysql
   *     database.
   * @param gpo The {@link GPOMutable} object whose values need to be set in the preparted
   *     statement.
   * @param qCounter The current index in the prepared statement
   * @param isKey TODO use this
   * @return The current index in the prepared statement.
   * @throws SQLException
   */
  private int setParams(PreparedStatement ps, GPOMutable gpo, int qCounter, boolean isKey)
      throws SQLException {
    FieldsDescriptor fd = gpo.getFieldDescriptor();

    Map<String, Type> fieldToType = fd.getFieldToType();
    List<String> fields = fd.getFieldList();

    for (int fieldCounter = 0; fieldCounter < fields.size(); fieldCounter++, qCounter++) {
      String fieldName = fields.get(fieldCounter);

      if (fieldName.equals(DimensionsDescriptor.DIMENSION_TIME_BUCKET)) {
        continue;
      }

      Type type = fieldToType.get(fieldName);

      switch (type) {
        case BOOLEAN:
          {
            ps.setByte(qCounter, (byte) (gpo.getFieldBool(fieldName) ? 1 : 0));
            break;
          }
        case BYTE:
          {
            ps.setByte(qCounter, gpo.getFieldByte(fieldName));
            break;
          }
        case CHAR:
          {
            ps.setString(qCounter, Character.toString(gpo.getFieldChar(fieldName)));
            break;
          }
        case STRING:
          {
            ps.setString(qCounter, gpo.getFieldString(fieldName));
            break;
          }
        case SHORT:
          {
            ps.setInt(qCounter, gpo.getFieldShort(fieldName));
            break;
          }
        case INTEGER:
          {
            ps.setInt(qCounter, gpo.getFieldInt(fieldName));
            break;
          }
        case LONG:
          {
            ps.setLong(qCounter, gpo.getFieldLong(fieldName));
            break;
          }
        case FLOAT:
          {
            ps.setFloat(qCounter, gpo.getFieldFloat(fieldName));
            break;
          }
        case DOUBLE:
          {
            ps.setDouble(qCounter, gpo.getFieldDouble(fieldName));
            break;
          }
        default:
          {
            throw new UnsupportedOperationException("The type: " + type + " is not supported.");
          }
      }
    }

    return qCounter;
  }