Exemplo n.º 1
0
  private static DatasetSpecification getDatasetSpec(Configuration conf, Id.DatasetInstance id)
      throws IOException {
    ContextManager.Context context = ContextManager.getContext(conf);
    if (context == null) {
      throw new NullJobConfException();
    }

    try {
      DatasetFramework framework = context.getDatasetFramework();
      return framework.getDatasetSpec(id);
    } catch (DatasetManagementException e) {
      throw new IOException(e);
    } finally {
      context.close();
    }
  }
Exemplo n.º 2
0
  private static Dataset instantiate(@Nullable Configuration conf, Id.DatasetInstance dsInstanceId)
      throws IOException {
    ContextManager.Context context = ContextManager.getContext(conf);
    if (context == null) {
      throw new NullJobConfException();
    }

    Id.DatasetInstance datasetInstanceId =
        dsInstanceId != null ? dsInstanceId : getDatasetInstanceId(conf);

    if (datasetInstanceId == null) {
      throw new IOException("Dataset name property could not be found.");
    }

    try {
      DatasetFramework framework = context.getDatasetFramework();

      if (conf == null) {
        return framework.getDataset(datasetInstanceId, DatasetDefinition.NO_ARGUMENTS, null);
      }

      String queryId = conf.get(Constants.Explore.QUERY_ID);
      if (queryId == null) {
        throw new IOException("QueryId property could not be found");
      }
      QueryHandle queryHandle = QueryHandle.fromId(queryId);
      ClassLoader classLoader =
          DATASET_CLASSLOADER_MAP.getUnchecked(queryHandle).get(datasetInstanceId);
      Dataset dataset;
      if (classLoader == null) {
        classLoader = conf.getClassLoader();
        dataset = firstLoad(framework, queryHandle, datasetInstanceId, classLoader);
      } else {
        dataset =
            framework.getDataset(datasetInstanceId, DatasetDefinition.NO_ARGUMENTS, classLoader);
      }
      return dataset;
    } catch (DatasetManagementException e) {
      throw new IOException(e);
    } finally {
      context.close();
    }
  }