VariantDataset extends ParentDataset<VariantDataset> implements Serializable { public VariantDataset studyFilter(String key, String value) { query.put("studies." + key, value); return this; } VariantDataset(SparkSession sparkSession); void reset(); Dataset executeSql(String sql); @Override String getSql(); VariantDataset idFilter(String value); VariantDataset idFilter(List<String> values); VariantDataset idFilter(List<String> values, boolean and); VariantDataset typeFilter(String value); VariantDataset typeFilter(List<String> values); VariantDataset studyFilter(String key, String value); VariantDataset studyFilter(String key, List<String> values); VariantDataset studyFilter(String key, List<String> values, boolean and); VariantDataset sampleFilter(String key, String value); VariantDataset sampleFilter(String key, List<String> values); VariantDataset annotationFilter(String key, String value); VariantDataset annotationFilter(String key, List<String> values); VariantDataset annotationFilter(String key, List<String> values, boolean and); Iterator<Variant> iterator();  }
@Test public void outputFormats() { long count = 0; try { initDataset(); System.out.println("--------------------------------------"); vd.studyFilter("stats.refAlleleCount", "hgva@hsapiens_grch37:1000GENOMES_phase_3::ASW==121"); vd.update(); String format = "json"; String filename = "/tmp/query.out." + format; String tmpDir = filename + ".tmp"; if ("json".equals(format)) { vd.coalesce(1).write().format("json").save(tmpDir); } else if ("parquet".equals(format)) { vd.coalesce(1).write().format("parquet").save(tmpDir); } else { vd.coalesce(1).write().format("com.databricks.spark.avro").save(tmpDir); format = "avro"; } File dir = new File(tmpDir); if (!dir.isDirectory()) { System.err.println("Error: a directory was expected but " + tmpDir); return; } Boolean found = false; String[] list = dir.list(); for (String name: list) { if (name.startsWith("part-r-") && name.endsWith(format)) { new File(tmpDir + "/" + name).renameTo(new File(filename)); found = true; break; } } if (!found) { System.out.println("Error: pattern 'part-r-*" + format + "' was not found"); } FileUtils.deleteDirectory(dir); } catch (Exception e) { e.printStackTrace(); } vd.sparkSession.sparkContext().stop(); }