Exemple #1
0
    /** {@inheritDoc} */
    @Override
    public Tuple2<LongWritable, Mutation> map(PED persistentEdgeData) throws Exception {
      LongWritable key = new LongWritable(persistentEdgeData.getId());
      Put put = new Put(edgeDataHandler.getRowKey(persistentEdgeData.getId()));
      put = edgeDataHandler.writeEdgeData(put, persistentEdgeData);

      reuseTuple.f0 = key;
      reuseTuple.f1 = put;
      return reuseTuple;
    }
  /**
   * Creates the tables used by the graph store.
   *
   * @param config Hadoop configuration
   * @param vertexDataHandler vertex storage handler
   * @param edgeDataHandler edge storage handler
   * @param graphDataHandler graph storage handler
   * @param vertexDataTableName vertex data table name
   * @param edgeTableName edge data table name
   * @param graphDataTableName graph data table name
   * @throws IOException
   */
  private static void createTablesIfNotExists(
      final Configuration config,
      final VertexDataHandler vertexDataHandler,
      final EdgeDataHandler edgeDataHandler,
      final GraphDataHandler graphDataHandler,
      final String vertexDataTableName,
      final String edgeTableName,
      final String graphDataTableName)
      throws IOException {
    HTableDescriptor vertexDataTableDescriptor =
        new HTableDescriptor(TableName.valueOf(vertexDataTableName));
    HTableDescriptor edgeDataTableDescriptor =
        new HTableDescriptor(TableName.valueOf(edgeTableName));
    HTableDescriptor graphDataTableDescriptor =
        new HTableDescriptor(TableName.valueOf(graphDataTableName));

    HBaseAdmin admin = new HBaseAdmin(config);

    if (!admin.tableExists(vertexDataTableDescriptor.getName())) {
      vertexDataHandler.createTable(admin, vertexDataTableDescriptor);
    }
    if (!admin.tableExists(edgeDataTableDescriptor.getName())) {
      edgeDataHandler.createTable(admin, edgeDataTableDescriptor);
    }
    if (!admin.tableExists(graphDataTableDescriptor.getName())) {
      graphDataHandler.createTable(admin, graphDataTableDescriptor);
    }

    admin.close();
  }