当前位置: 首页>>代码示例>>Java>>正文


Java Dataset.setDatasetReference方法代码示例

本文整理汇总了Java中com.google.api.services.bigquery.model.Dataset.setDatasetReference方法的典型用法代码示例。如果您正苦于以下问题:Java Dataset.setDatasetReference方法的具体用法?Java Dataset.setDatasetReference怎么用?Java Dataset.setDatasetReference使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.api.services.bigquery.model.Dataset的用法示例。


在下文中一共展示了Dataset.setDatasetReference方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setupJob

import com.google.api.services.bigquery.model.Dataset; //导入方法依赖的package包/类
/**
 * Creates the temporary dataset that will contain all of the task work tables.
 *
 * @param context the job's context.
 * @throws IOException on IO Error.
 */
@Override
public void setupJob(JobContext context) throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug("setupJob({})", HadoopToStringUtil.toString(context));
  }
  // Create dataset.
  DatasetReference datasetReference = new DatasetReference();
  datasetReference.setProjectId(tempTableRef.getProjectId());
  datasetReference.setDatasetId(tempTableRef.getDatasetId());

  Configuration config = context.getConfiguration();
  Dataset tempDataset = new Dataset();
  tempDataset.setDatasetReference(datasetReference);
  tempDataset.setLocation(config.get(BigQueryConfiguration.DATA_LOCATION_KEY,
                                     BigQueryConfiguration.DATA_LOCATION_DEFAULT));

  // Insert dataset into Bigquery.
  Bigquery.Datasets datasets = bigQueryHelper.getRawBigquery().datasets();

  // TODO(user): Maybe allow the dataset to exist already instead of throwing 409 here.
  LOG.debug("Creating temporary dataset '{}' for project '{}'",
      tempTableRef.getDatasetId(), tempTableRef.getProjectId());

  // NB: Even though this "insert" makes it look like we can specify a different projectId than
  // the one which owns the dataset, it actually has to match.
  datasets.insert(tempTableRef.getProjectId(), tempDataset).execute();
}
 
开发者ID:GoogleCloudPlatform,项目名称:bigdata-interop,代码行数:34,代码来源:BigQueryOutputCommitter.java

示例2: createDataset

import com.google.api.services.bigquery.model.Dataset; //导入方法依赖的package包/类
public void createDataset(String datasetName) throws GeneralSecurityException, IOException {
	Bigquery bigquery = GoogleServices.getBigqueryServiceDomainWide();
	
	Dataset dataset = new Dataset();
    DatasetReference datasetRef = new DatasetReference();
    datasetRef.setProjectId(AppHelper.getAppId());
    datasetRef.setDatasetId(datasetName);
    dataset.setDatasetReference(datasetRef);
    
    try {
    	bigquery.datasets().insert(AppHelper.getAppId(), dataset).execute();
    } catch (GoogleJsonResponseException ex) {
		if (ex.getStatusCode() != 409) throw ex;
	}
}
 
开发者ID:andryfailli,项目名称:teampot,代码行数:16,代码来源:AnalyticsService.java

示例3: setUp

import com.google.api.services.bigquery.model.Dataset; //导入方法依赖的package包/类
@Before
public void setUp()
    throws IOException, GeneralSecurityException {
  MockitoAnnotations.initMocks(this);

  TestConfiguration configuration = TestConfiguration.getInstance();

  Logger.getLogger(GsonBigQueryInputFormat.class).setLevel(Level.DEBUG);
  Logger.getLogger(BigQueryOutputCommitter.class).setLevel(Level.DEBUG);
  Logger.getLogger(BigQueryOutputFormat.class).setLevel(Level.DEBUG);
  Logger.getLogger(BigQueryRecordWriter.class).setLevel(Level.DEBUG);
  Logger.getLogger(BigQueryUtils.class).setLevel(Level.DEBUG);
  Logger.getLogger(GsonRecordReader.class).setLevel(Level.DEBUG);

  // Use current time to label the test run.
  // TODO(user): Use a date formatter.
  testId = "bq_integration_test_" + System.currentTimeMillis();

  projectIdvalue = configuration.getProjectId();
  if (Strings.isNullOrEmpty(projectIdvalue)) {
    projectIdvalue = System.getenv(BIGQUERY_PROJECT_ID_ENVVARNAME);
  }

  Preconditions.checkArgument(
      !Strings.isNullOrEmpty(projectIdvalue), "Must provide %s", BIGQUERY_PROJECT_ID_ENVVARNAME);
  testDataset = testId + "_dataset";
  testBucket = testId + "_bucket";

  // We have to create the output dataset ourselves.
  // TODO(user): Extract dataset creation into a library which is also used by
  // BigQueryOutputCommitter.
  Dataset outputDataset = new Dataset();
  DatasetReference datasetReference = new DatasetReference();
  datasetReference.setProjectId(projectIdvalue);
  datasetReference.setDatasetId(testDataset);

  config = new Configuration();
  setConfigForGcsFromBigquerySettings();
  BigQueryFactory factory = new BigQueryFactory();
  bigqueryInstance = factory.getBigQuery(config);

  Bigquery.Datasets datasets = bigqueryInstance.datasets();
  outputDataset.setDatasetReference(datasetReference);
  LOG.info("Creating temporary dataset '{}' for project '{}'", testDataset, projectIdvalue);
  datasets.insert(projectIdvalue, outputDataset).execute();

  Path toCreate = new Path(String.format("gs://%s", testBucket));
  FileSystem fs = toCreate.getFileSystem(config);
  LOG.info("Creating temporary test bucket '{}'", toCreate);
  fs.mkdirs(toCreate);

  // Since the TaskAttemptContext and JobContexts are mostly used just to access a
  // "Configuration" object, we'll mock the two contexts to just return our fake configuration
  // object with which we'll provide the settings we want to test.
  config.clear();
  setConfigForGcsFromBigquerySettings();

  when(mockTaskAttemptContext.getConfiguration())
      .thenReturn(config);
  when(mockJobContext.getConfiguration())
      .thenReturn(config);

  // Have a realistic-looking fake TaskAttemptID.
  int taskNumber = 3;
  int taskAttempt = 2;
  int jobNumber = 42;
  String jobIdString = "jobid" + System.currentTimeMillis();
  JobID jobId = new JobID(jobIdString, jobNumber);
  TaskAttemptID taskAttemptId =
      new TaskAttemptID(new TaskID(jobId, false, taskNumber), taskAttempt);
  when(mockTaskAttemptContext.getTaskAttemptID())
      .thenReturn(taskAttemptId);
  when(mockJobContext.getJobID()).thenReturn(jobId);

  testTable = testId + "_table_" + jobIdString;

  // Instantiate an OutputFormat and InputFormat instance.
  outputFormat = new BigQueryOutputFormat();
}
 
开发者ID:GoogleCloudPlatform,项目名称:bigdata-interop,代码行数:80,代码来源:AbstractBigQueryIoIntegrationTestBase.java


注:本文中的com.google.api.services.bigquery.model.Dataset.setDatasetReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。