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