Package org.kitesdk.data.spi

Examples of org.kitesdk.data.spi.DatasetRepository


    } else {
      LOG.warn(
          "kite.datasetName is deprecated, instead use kite.uri=<dataset-uri>");
      Preconditions.checkArgument(datasetName != null,
          "kite.datasetName is required if kite.uri is not used");
      DatasetRepository repo = getDatasetRepository();
      descriptor = repo.load(datasetNamespace, datasetName).getDescriptor();
    }

    DatasetDescriptor.Builder descriptorBuilder = new DatasetDescriptor.Builder(
        descriptor);
    configureSchema(descriptorBuilder, avroSchemaFile, avroSchemaReflectClass);

    if (columnDescriptorFile != null) {
      File columnDescriptor = new File(columnDescriptorFile);
      try {
        if (columnDescriptor.exists()) {
          descriptorBuilder.columnMapping(columnDescriptor);
        } else {
          descriptorBuilder.columnMapping(Resources.getResource(
              columnDescriptorFile).openStream());
        }
      } catch (IOException e) {
        throw new MojoExecutionException("Problem while reading file "
            + columnDescriptorFile, e);
      }
    }

    if (uri != null) {
      Datasets.update(uri, descriptorBuilder.build());
    } else {
      // datasetName is checked above
      DatasetRepository repo = getDatasetRepository();
      repo.update(datasetNamespace, datasetName, descriptorBuilder.build());
    }
  }
View Full Code Here


    } else {
      LOG.warn(
          "kite.datasetName is deprecated, instead use kite.uri=<dataset-uri>");
      Preconditions.checkArgument(datasetName != null,
          "kite.datasetName is required if kite.uri is not used");
      DatasetRepository repo = getDatasetRepository();
      repo.create(datasetNamespace, datasetName, descriptorBuilder.build());
    }
  }
View Full Code Here

  @Test
  public void testExternalURI() {
    URI hdfsUri = getDFS().getUri();
    URI repoUri = URI.create("repo:hive:/tmp/hive-repo?hdfs:host=" +
        hdfsUri.getHost() + "&hdfs:port=" + hdfsUri.getPort());
    DatasetRepository repo = DatasetRepositories.repositoryFor(repoUri);

    Assert.assertNotNull("Received a repository", repo);
    org.junit.Assert.assertTrue("Repo should be a HCatalogExternalDatasetRepository",
        repo instanceof HiveExternalDatasetRepository);
    Assert.assertEquals("Repository URI", repoUri, repo.getUri());

    // verify location
    DatasetDescriptor created = repo.create("tmp", "test",
        new DatasetDescriptor.Builder()
        .schemaLiteral("\"string\"")
        .build()).getDescriptor();
    Assert.assertEquals("Location should be in HDFS",
        "hdfs", created.getLocation().getScheme());
View Full Code Here

  @Test
  public void testExternalURIWithHostAndPort() {
    URI hdfsUri = getDFS().getUri();
    URI repoUri = URI.create("repo:hive://meta-host:1234/tmp/data?hdfs:host=" +
        hdfsUri.getHost() + "&hdfs:port=" + hdfsUri.getPort());
    DatasetRepository repo = DatasetRepositories.repositoryFor(repoUri);

    Assert.assertNotNull("Received a repository", repo);
    org.junit.Assert.assertTrue("Repo should be a HCatalogExternalDatasetRepository",
        repo instanceof HiveExternalDatasetRepository);
    Assert.assertEquals("Repository URI", repoUri, repo.getUri());
  }
View Full Code Here

  @Test
  public void testExternalURIWithRootPath() {
    URI hdfsUri = getDFS().getUri();
    URI repoUri = URI.create("repo:hive:/?hdfs:host=" + hdfsUri.getHost() +
        "&hdfs:port=" + hdfsUri.getPort());
    DatasetRepository repo = DatasetRepositories.repositoryFor(repoUri);
    Assert.assertNotNull("Received a repository", repo);
    Assert.assertTrue("Repo should be a HCatalogExternalDatasetRepository",
        repo instanceof HiveExternalDatasetRepository);
    MetadataProvider provider = ((HiveExternalDatasetRepository) repo)
        .getMetadataProvider();
    Assert.assertTrue("Repo should be using a HCatalogExternalMetadataProvider",
        provider instanceof HiveExternalMetadataProvider);
    Assert.assertEquals("Repository URI", repoUri, repo.getUri());
  }
View Full Code Here

  @Test
  public void testExternalURIWithHostAndPortAndRootPath() {
    URI hdfsUri = getDFS().getUri();
    URI repoUri = URI.create("repo:hive://meta-host:1234/?hdfs:host=" +
        hdfsUri.getHost() + "&hdfs:port=" + hdfsUri.getPort());
    DatasetRepository repo = DatasetRepositories.repositoryFor(repoUri);
    Assert.assertNotNull("Received a repository", repo);
    Assert.assertTrue("Repo should be a HCatalogExternalDatasetRepository",
        repo instanceof HiveExternalDatasetRepository);
    MetadataProvider provider = ((HiveExternalDatasetRepository) repo)
        .getMetadataProvider();
    Assert.assertTrue("Repo should be using a HCatalogManagedMetadataProvider",
        provider instanceof HiveExternalMetadataProvider);
    Assert.assertEquals("Repository URI", repoUri, repo.getUri());
  }
View Full Code Here

    test.hcatalog = false;
    test.rootDirectory = "/tmp/datasets";
    test.hadoopConfiguration = new Properties();
    test.hadoopConfiguration.setProperty("fs.default.name", fsUri.toString());

    DatasetRepository repo = test.getDatasetRepository();
    Assert.assertNotNull("Should create repo successfully", repo);
    Assert.assertEquals("Should be a HDFS repo",
        "repo:hdfs://" + fsUri.getAuthority() + "/tmp/datasets",
        repo.getUri().toString());
  }
View Full Code Here

    test.hcatalog = false;
    test.rootDirectory = "/tmp/datasets";
    test.hadoopConfiguration = new Properties();
    test.hadoopConfiguration.setProperty("fs.defaultFS", fsUri.toString());

    DatasetRepository repo = test.getDatasetRepository();
    Assert.assertNotNull("Should create repo successfully", repo);
    Assert.assertEquals("Should be a HDFS repo",
        "repo:hdfs://" + fsUri.getAuthority() + "/tmp/datasets",
        repo.getUri().toString());
  }
View Full Code Here

    command.datasets = Lists.newArrayList(source, dest);

    int rc = command.run();
    Assert.assertEquals("Should return success", 0, rc);

    DatasetRepository repo = DatasetRepositories.repositoryFor("repo:file:target/data");
    int size = DatasetTestUtilities.datasetSize(repo.load("default", source));
    Assert.assertEquals("Should contain copied records", 2, size);
  }
View Full Code Here

    }
  }

  @Test
  public void testExternal() {
    DatasetRepository repo = DatasetRepositories
        .repositoryFor("repo:hive:/tmp/data?" + hdfsQueryArgs);
    repo.delete("ns", "test");
    repo.create("ns", "test", descriptor);

    Dataset<Object> ds = Datasets
        .<Object, Dataset<Object>>load("dataset:hive:/tmp/data/ns/test?" + hdfsQueryArgs, Object.class);

    Assert.assertNotNull("Should load dataset", ds);
    Assert.assertTrue(ds instanceof FileSystemDataset);
    Assert.assertEquals("Locations should match",
        URI.create("hdfs://" + hdfsAuth + "/tmp/data/ns/test"),
        ds.getDescriptor().getLocation());
    Assert.assertEquals("Descriptors should match",
        repo.load("ns", "test").getDescriptor(), ds.getDescriptor());
    Assert.assertEquals("Should report correct namespace",
        "ns", ds.getNamespace());
    Assert.assertEquals("Should report correct name",
        "test", ds.getName());

    repo.delete("ns", "test");
  }
View Full Code Here

TOP

Related Classes of org.kitesdk.data.spi.DatasetRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.