@Override com.google.api.services.bigquery.model.JobStatistics toPb() { com.google.api.services.bigquery.model.JobStatistics statisticsPb = super.toPb(); return statisticsPb.setExtract( new JobStatistics4().setDestinationUriFileCounts(destinationUriFileCounts)); }
private Builder(com.google.api.services.bigquery.model.JobStatistics statisticsPb) { super(statisticsPb); if (statisticsPb.getExtract() != null) { this.destinationUriFileCounts = statisticsPb.getExtract().getDestinationUriFileCounts(); } }
@Override com.google.api.services.bigquery.model.JobStatistics toPb() { com.google.api.services.bigquery.model.JobStatistics statisticsPb = super.toPb(); return statisticsPb.setExtract( new JobStatistics4().setDestinationUriFileCounts(destinationUriFileCounts)); }
private Builder(com.google.api.services.bigquery.model.JobStatistics statisticsPb) { super(statisticsPb); this.destinationUriFileCounts = statisticsPb.getExtract().getDestinationUriFileCounts(); }
@Override com.google.api.services.bigquery.model.JobStatistics toPb() { com.google.api.services.bigquery.model.JobStatistics statisticsPb = super.toPb(); return statisticsPb.setExtract( new JobStatistics4().setDestinationUriFileCounts(destinationUriFileCounts)); }
private Builder(com.google.api.services.bigquery.model.JobStatistics statisticsPb) { super(statisticsPb); this.destinationUriFileCounts = statisticsPb.getExtract().getDestinationUriFileCounts(); }
@Override com.google.api.services.bigquery.model.JobStatistics toPb() { com.google.api.services.bigquery.model.JobStatistics statisticsPb = super.toPb(); return statisticsPb.setExtract( new JobStatistics4().setDestinationUriFileCounts(destinationUriFileCounts)); }
private Builder(com.google.api.services.bigquery.model.JobStatistics statisticsPb) { super(statisticsPb); if (statisticsPb.getExtract() != null) { this.destinationUriFileCounts = statisticsPb.getExtract().getDestinationUriFileCounts(); } }
private JobStatus runExtractJob(Job job, JobConfigurationExtract extract) throws InterruptedException, IOException { TableReference sourceTable = extract.getSourceTable(); List<TableRow> rows = datasetService.getAllRows( sourceTable.getProjectId(), sourceTable.getDatasetId(), sourceTable.getTableId()); TableSchema schema = datasetService.getTable(sourceTable).getSchema(); List<Long> destinationFileCounts = Lists.newArrayList(); for (String destination : extract.getDestinationUris()) { destinationFileCounts.add(writeRows(sourceTable.getTableId(), rows, schema, destination)); } job.setStatistics( new JobStatistics() .setExtract(new JobStatistics4().setDestinationUriFileCounts(destinationFileCounts))); return new JobStatus().setState("DONE"); }
static List<ResourceId> getExtractFilePaths(String extractDestinationDir, Job extractJob) throws IOException { JobStatistics jobStats = extractJob.getStatistics(); List<Long> counts = jobStats.getExtract().getDestinationUriFileCounts(); if (counts.size() != 1) { String errorMessage = (counts.isEmpty() ? "No destination uri file count received." : String.format( "More than one destination uri file count received. First two are %s, %s", counts.get(0), counts.get(1))); throw new RuntimeException(errorMessage); } long filesCount = counts.get(0); ImmutableList.Builder<ResourceId> paths = ImmutableList.builder(); ResourceId extractDestinationDirResourceId = FileSystems.matchNewResource(extractDestinationDir, true /* isDirectory */); for (long i = 0; i < filesCount; ++i) { ResourceId filePath = extractDestinationDirResourceId.resolve( String.format("%012d%s", i, ".avro"), ResolveOptions.StandardResolveOptions.RESOLVE_FILE); paths.add(filePath); } return paths.build(); }
JobStatistics4 extractStats = new JobStatistics4(); extractStats.setDestinationUriFileCounts(ImmutableList.of(1L)); extractJobStats.setExtract(extractStats); extractJob.setStatus(new JobStatus()).setStatistics(extractJobStats);
JobStatistics4 extractStats = new JobStatistics4(); extractStats.setDestinationUriFileCounts(ImmutableList.of(1L)); extractJobStats.setExtract(extractStats); extractJob.setStatus(new JobStatus()).setStatistics(extractJobStats);