public static Connector initConnector() {
    Instance instance = new MockInstance();

    try {
      Connector connector = instance.getConnector("root", "password".getBytes());

      // set up table
      connector.tableOperations().create("partition");

      // set up root's auths
      connector
          .securityOperations()
          .changeUserAuthorizations("root", new Authorizations("ALPHA,BETA,GAMMA".split(",")));

      return connector;
    } catch (CBException e) {
      e.printStackTrace();
    } catch (CBSecurityException e) {
      e.printStackTrace();
    } catch (TableExistsException e) {
      e.printStackTrace();
    }

    return null;
  }
  public static void writeDenSerialized(Connector connector, Collection<Map<String, String>> data) {
    // write sample data
    MultiTableBatchWriter mtbw = connector.createMultiTableBatchWriter(200000, 10000, 1);
    try {
      BatchWriter writer;
      if (mtbw != null) {
        writer = mtbw.getBatchWriter("partition");
      } else {
        writer = connector.createBatchWriter("partition", 200000, 10000, 1);
      }
      int count = 0;
      Mutation m;
      for (Map<String, String> object : data) {
        count++;
        String id = (count < 10 ? "0" + count : "" + count);
        Text partition = new Text("" + (count % NUM_PARTITIONS));

        StringBuilder value = new StringBuilder();
        boolean first = true;
        for (Entry<String, String> entry : object.entrySet()) {
          if (!first) {
            value.append("\u0000");
          } else {
            first = false;
          }
          value.append(entry.getKey());
          value.append("\uFFFD");
          value.append(entry.getValue());

          // write the general index mutation
          m = new Mutation(partition);
          m.put("index", entry.getValue() + "\u0000" + id, "");
          writer.addMutation(m);

          // write the specific index mutation
          m = new Mutation(partition);
          m.put("index", entry.getKey() + "//" + entry.getValue() + "\u0000" + id, "");
          writer.addMutation(m);
        }

        // write the event mutation
        m = new Mutation(partition);
        m.put("event", id, value.toString());
        writer.addMutation(m);
      }
      writer.close();
    } catch (CBException e) {
      e.printStackTrace();
    } catch (CBSecurityException e) {
      e.printStackTrace();
    } catch (TableNotFoundException e) {
      e.printStackTrace();
    }
  }
  @Override
  public void runTest(
      Map<String, String> request, Connector connector, String table, String auths) {
    if (!request.containsKey("dates")) {
      logger.warn("No 'dates' parameter supplied. e.g. dates=20100720,20100721...");
      return;
    }

    if (request.containsKey("type")) {
      type = request.get("type");
    }

    String[] dates = request.get("dates").split(",");

    List<Long> comboTimes = new ArrayList<Long>();
    List<Long> partTimes = new ArrayList<Long>();
    List<Long> comboCounts = new ArrayList<Long>();
    List<Long> partCounts = new ArrayList<Long>();
    List<String> errors = new ArrayList<String>();
    try {
      for (String date : dates) {
        long rdate = 99999999 - Long.parseLong(date);
        for (int g = 0; g < 8; g++) {
          String begin = type + "//rdate:" + rdate + "//geokey:" + g;
          String end = type + "//rdate:" + rdate + "//geokey:" + (g + 1);
          long count = 0;
          Set<Range> ranges = new HashSet<Range>();

          logger.info("Running test for " + begin + " ...");
          // run combo index test
          BatchScanner reader =
              connector.createBatchScanner(table, new Authorizations(auths.split(",")), 30);
          ranges.add(new Range(new Key(new Text(begin)), true, new Key(new Text(end)), false));

          reader.setRanges(ranges);
          long start = System.currentTimeMillis();
          for (Entry<Key, Value> entry : reader) {
            count++;
          }
          comboTimes.add(System.currentTimeMillis() - start);
          comboCounts.add(count);

          logger.info(
              "\tC count=" + count + " time=" + comboTimes.get(comboTimes.size() - 1) + " ms");

          count = 0;

          // run partition index test
          //					reader = connector.createBatchScanner(table, new Authorizations(auths.split(",")),
          // 30);
          //
          //					reader.setScanIterators(3, SortedRangeIterator.class.getName(), "ri");
          //					reader.setScanIteratorOption("ri", SortedRangeIterator.OPTION_LOWER_BOUND,
          // begin.replace("geokey", "geoKey"));
          //					reader.setScanIteratorOption("ri", SortedRangeIterator.OPTION_UPPER_BOUND,
          // end.replace("geokey", "geoKey"));
          //
          //					ranges.clear();
          //					ranges.add(new Range(new Key(new Text("date:" + date)), true, new Key(new
          // Text("date:" + date + "z")), false));
          //					reader.setRanges(ranges);
          //
          //					start = System.currentTimeMillis();
          //					for (Entry<Key, Value> entry: reader) {
          //						count++;
          //					}
          //					partTimes.add(System.currentTimeMillis() - start);
          //					partCounts.add(count);
          //
          //					if (count != comboCounts.get(comboCounts.size() - 1)) {
          //						String msg = "Counts differed for " + begin + " C: " +
          // comboCounts.get(comboCounts.size() - 1) + " P: " + count;
          //						logger.warn(msg);
          //						errors.add(msg);
          //					}
          //					logger.info("\tP count=" + count + " time=" + partTimes.get(partTimes.size() - 1) +
          // " ms");
        }
      }

      logger.info("********************* RESULTS *********************");
      logger.info("Tested all 0 level tiles on " + type + " for " + request.get("dates"));
      // logger.info("This is a test of SortedRangeIterator performance");

      double comboSum = 0, partSum = 0;
      for (int i = 0; i < comboTimes.size(); i++) {
        comboSum += comboTimes.get(i);
        // partSum += partTimes.get(i);
      }

      logger.info("Average C Time: " + (comboSum / comboTimes.size()) + " ms");
      // logger.info("Average P Time: " + (partSum / partTimes.size()) + " ms");

      comboSum = 0;
      partSum = 0;

      for (int i = 0; i < comboCounts.size(); i++) {
        comboSum += comboCounts.get(i);
        // partSum += partCounts.get(i);
      }

      logger.info("Average C Count: " + (comboSum / comboCounts.size()));
      // logger.info("Average P Count: " + (partSum / partCounts.size()));

      if (errors.size() > 0) {
        logger.warn("ERRORS!!!:");
        for (String e : errors) {
          logger.warn(e);
        }
      }
    } catch (Exception e) {
      logger.error(e, e);
    }
  }