package org.kitesdk.examples.data;

import org.kitesdk.data.DatasetDescriptor;
import org.kitesdk.data.DatasetRepositories;
import org.kitesdk.data.DatasetRepository;
import org.kitesdk.data.Datasets;
import org.kitesdk.data.Formats;
import org.apache.avro.Schema;
import org.apache.avro.SchemaBuilder;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.util.Tool;
import org.apache.hadoop.util.ToolRunner;

public class DescribeDatasets extends Configured implements Tool {

  @Override
  public int run(String[] args) throws Exception {
    Schema ratingSchema = SchemaBuilder.record("Rating")
        .fields()
        .name("userId").type().intType().noDefault()
        .name("movieId").type().intType().noDefault()
        .name("rating").type().intType().noDefault()
        .name("timeInSeconds").type().intType().noDefault()
        .endRecord();

    Datasets.create("dataset:hdfs:/tmp/data/ratings",
        new DatasetDescriptor.Builder()
            .location("hdfs:ratings.tsv") // originally u.data
            .format(Formats.CSV)
            .property("kite.csv.delimiter", "\t")
            .schema(ratingSchema)
            .build(), Object.class);

//    movie id | movie title | release date | video release date |
//    IMDb URL | unknown | Action | Adventure | Animation |
//        Children's | Comedy | Crime | Documentary | Drama | Fantasy |
//    Film-Noir | Horror | Musical | Mystery | Romance | Sci-Fi |
//        Thriller | War | Western |
    Schema movieSchema = SchemaBuilder.record("Movie")
        .fields()
        .name("movieId").type().intType().noDefault()
        .name("title").type().stringType().noDefault()
        .name("releaseDate").type().stringType().noDefault()
        .name("videoReleaseDate").type().stringType().noDefault()
        .name("imdbURL").type().stringType().noDefault()
        // ignore genre fields for now
        .endRecord();

    Datasets.create("dataset:hdfs:/tmp/data/movies",
        new DatasetDescriptor.Builder()
            .location("hdfs:movies.psv") // originally u.item
            .format(Formats.CSV)
            .property("kite.csv.delimiter", "|")
            .schema(movieSchema)
            .build(), Object.class);

    return 0;
  }

  public static void main(String... args) throws Exception {
    int rc = ToolRunner.run(new DescribeDatasets(), args);
    System.exit(rc);
  }
}

@@ -33,206 +33,8 @@
 a;%0A%0A
-import org.kitesdk.data.DatasetDescriptor;%0Aimport org.kitesdk.data.DatasetRepositories;%0Aimport org.kitesdk.data.DatasetRepository;%0Aimport org.kitesdk.data.Datasets;%0Aimport org.kitesdk.data.Formats;%0A
 impo
@@ -60,16 +60,16 @@
 Schema;%0A
+
 import o
@@ -217,16 +217,126 @@
 lRunner;
+%0Aimport org.kitesdk.data.DatasetDescriptor;%0Aimport org.kitesdk.data.Datasets;%0Aimport org.kitesdk.data.Formats;
 %0A%0Apublic
@@ -456,24 +456,92 @@
 Exception %7B%0A
+    String home = %22hdfs:/user/%22 + System.getProperty(%22user.name%22);%0A%0A
     Schema r
@@ -962,22 +962,25 @@
 ocation(
-%22hdfs:
+home + %22/
 ratings.
@@ -2006,22 +2006,25 @@
 ocation(
-%22hdfs:
+home + %22/
 movies.p

Use full path for dataset-compatibility locations.