org.apache.kylin.common.persistence.ResourceStore.getAllResources()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中org.apache.kylin.common.persistence.ResourceStore.getAllResources方法的一些代码示例,展示了ResourceStore.getAllResources的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ResourceStore.getAllResources方法的具体详情如下:
包路径:org.apache.kylin.common.persistence.ResourceStore
类名称:ResourceStore
方法名:getAllResources

ResourceStore.getAllResources介绍

[英]Read all resources under a folder. Return empty list if folder not exist. NOTE: Exceptions thrown by ContentReader are swallowed in order to load every resource at best effort.
[中]读取文件夹下的所有资源。如果文件夹不存在,返回空列表。注意:ContentReader抛出的异常会被忽略,以便尽最大努力加载每个资源。

代码示例

代码示例来源:origin: apache/kylin

public List<ExecutablePO> getJobs() throws PersistentException {
  try {
    return store.getAllResources(ResourceStore.EXECUTE_RESOURCE_ROOT, JOB_SERIALIZER);
  } catch (IOException e) {
    logger.error("error get all Jobs:", e);
    throw new PersistentException(e);
  }
}

代码示例来源:origin: apache/kylin

/**
 * Read all resources under a folder. Return empty list if folder not exist.
 *
 * NOTE: Exceptions thrown by ContentReader are swallowed in order to load every resource at best effort.
 */
final public <T extends RootPersistentEntity> List<T> getAllResources(String folderPath, Serializer<T> serializer)
    throws IOException {
  return getAllResources(folderPath, false, null, new ContentReader(serializer));
}

代码示例来源:origin: apache/kylin

public List<ExecutableOutputPO> getJobOutputs() throws PersistentException {
  try {
    return store.getAllResources(ResourceStore.EXECUTE_OUTPUT_RESOURCE_ROOT, JOB_OUTPUT_SERIALIZER);
  } catch (IOException e) {
    logger.error("error get all Jobs:", e);
    throw new PersistentException(e);
  }
}

代码示例来源:origin: apache/kylin

public List<SnapshotTable> getSnapshots(String tableName, TableSignature sourceTableSignature) throws IOException {
  List<SnapshotTable> result = Lists.newArrayList();
  String tableSnapshotsPath = SnapshotTable.getResourceDir(tableName);
  ResourceStore store = TableMetadataManager.getInstance(this.config).getStore();
  result.addAll(store.getAllResources(tableSnapshotsPath, SnapshotTableSerializer.INFO_SERIALIZER));
  if (sourceTableSignature != null) {
    String oldTableSnapshotsPath = SnapshotTable.getOldResourceDir(sourceTableSignature);
    result.addAll(store.getAllResources(oldTableSnapshotsPath, SnapshotTableSerializer.INFO_SERIALIZER));
  }
  return result;
}

代码示例来源:origin: apache/kylin

public List<ExecutablePO> getJobs(long timeStart, long timeEndExclusive) throws PersistentException {
  try {
    return store.getAllResources(ResourceStore.EXECUTE_RESOURCE_ROOT, false,
        new ResourceStore.VisitFilter(timeStart, timeEndExclusive), new ContentReader(JOB_SERIALIZER));
  } catch (IOException e) {
    logger.error("error get all Jobs:", e);
    throw new PersistentException(e);
  }
}

代码示例来源:origin: apache/kylin

public List<ExecutableOutputPO> getJobOutputs(long timeStart, long timeEndExclusive) throws PersistentException {
  try {
    return store.getAllResources(ResourceStore.EXECUTE_OUTPUT_RESOURCE_ROOT, false,
        new ResourceStore.VisitFilter(timeStart, timeEndExclusive),
        new ContentReader(JOB_OUTPUT_SERIALIZER));
  } catch (IOException e) {
    logger.error("error get all Jobs:", e);
    throw new PersistentException(e);
  }
}

代码示例来源:origin: apache/kylin

public List<ExtTableSnapshotInfo> getSnapshots(String tableName) throws IOException {
  String tableSnapshotsPath = ExtTableSnapshotInfo.getResourceDir(tableName);
  ResourceStore store = TableMetadataManager.getInstance(this.config).getStore();
  return store.getAllResources(tableSnapshotsPath, SNAPSHOT_SERIALIZER);
}

代码示例来源:origin: apache/kylin

private DictionaryInfo findLargestDictInfo(DictionaryInfo dictInfo) throws IOException {
  final ResourceStore store = getStore();
  final List<DictionaryInfo> allResources = store.getAllResources(dictInfo.getResourceDir(), DictionaryInfoSerializer.INFO_SERIALIZER);
  DictionaryInfo largestDict = null;
  for (DictionaryInfo dictionaryInfo : allResources) {
    if (largestDict == null) {
      largestDict = dictionaryInfo;
      continue;
    }
    if (largestDict.getCardinality() < dictionaryInfo.getCardinality()) {
      largestDict = dictionaryInfo;
    }
  }
  return largestDict;
}

代码示例来源:origin: apache/kylin

private String checkDupByInfo(DictionaryInfo dictInfo) throws IOException {
  final ResourceStore store = getStore();
  final List<DictionaryInfo> allResources = store.getAllResources(dictInfo.getResourceDir(), DictionaryInfoSerializer.INFO_SERIALIZER);
  TableSignature input = dictInfo.getInput();
  for (DictionaryInfo dictionaryInfo : allResources) {
    if (input.equals(dictionaryInfo.getInput())) {
      return dictionaryInfo.getResourcePath();
    }
  }
  return null;
}

代码示例来源:origin: apache/kylin

@Test
public void testGetAllCubes() throws Exception {
  final ResourceStore store = ResourceStore.getStore(getTestConfig());
  final NavigableSet<String> cubePath = store.listResources(ResourceStore.CUBE_RESOURCE_ROOT);
  assertTrue(cubePath.size() > 1);
  final List<CubeInstance> cubes = store.getAllResources(ResourceStore.CUBE_RESOURCE_ROOT,
      CubeManager.CUBE_SERIALIZER);
  assertEquals(cubePath.size(), cubes.size());
}

代码示例来源:origin: apache/kylin

private static void testGetAllResources(ResourceStore store) throws IOException {
  final String folder = "/testFolder";
  List<StringEntity> result;
  // reset any leftover garbage
  new ResourceTool().resetR(store, folder);
  store.checkAndPutResource(folder + "/res1", new StringEntity("data1"), 1000, StringEntity.serializer);
  store.checkAndPutResource(folder + "/res2", new StringEntity("data2"), 2000, StringEntity.serializer);
  store.checkAndPutResource(folder + "/sub/res3", new StringEntity("data3"), 3000, StringEntity.serializer);
  store.checkAndPutResource(folder + "/res4", new StringEntity("data4"), 4000, StringEntity.serializer);
  result = store.getAllResources(folder, StringEntity.serializer);
  Collections.sort(result);
  assertEntity(result.get(0), "data1", 1000);
  assertEntity(result.get(1), "data2", 2000);
  assertEntity(result.get(2), "data4", 4000);
  assertEquals(3, result.size());
  result = store.getAllResources(folder, false, new ResourceStore.VisitFilter(2000, 4000),
      new ContentReader(StringEntity.serializer));
  assertEntity(result.get(0), "data2", 2000);
  assertEquals(1, result.size());
  new ResourceTool().resetR(store, folder);
}

代码示例来源:origin: org.apache.kylin/kylin-core-job

public List<ExecutablePO> getJobs() throws PersistentException {
  try {
    return store.getAllResources(ResourceStore.EXECUTE_RESOURCE_ROOT, JOB_SERIALIZER);
  } catch (IOException e) {
    logger.error("error get all Jobs:", e);
    throw new PersistentException(e);
  }
}

代码示例来源:origin: org.apache.kylin/kylin-core-common

/**
 * Read all resources under a folder. Return empty list if folder not exist.
 *
 * NOTE: Exceptions thrown by ContentReader are swallowed in order to load every resource at best effort.
 */
final public <T extends RootPersistentEntity> List<T> getAllResources(String folderPath, Serializer<T> serializer)
    throws IOException {
  return getAllResources(folderPath, false, null, new ContentReader(serializer));
}

代码示例来源:origin: org.apache.kylin/kylin-core-job

public List<ExecutableOutputPO> getJobOutputs() throws PersistentException {
  try {
    return store.getAllResources(ResourceStore.EXECUTE_OUTPUT_RESOURCE_ROOT, JOB_OUTPUT_SERIALIZER);
  } catch (IOException e) {
    logger.error("error get all Jobs:", e);
    throw new PersistentException(e);
  }
}

代码示例来源:origin: org.apache.kylin/kylin-core-dictionary

public List<SnapshotTable> getSnapshots(String tableName, TableSignature sourceTableSignature) throws IOException {
  List<SnapshotTable> result = Lists.newArrayList();
  String tableSnapshotsPath = SnapshotTable.getResourceDir(tableName);
  ResourceStore store = TableMetadataManager.getInstance(this.config).getStore();
  result.addAll(store.getAllResources(tableSnapshotsPath, SnapshotTableSerializer.INFO_SERIALIZER));
  if (sourceTableSignature != null) {
    String oldTableSnapshotsPath = SnapshotTable.getOldResourceDir(sourceTableSignature);
    result.addAll(store.getAllResources(oldTableSnapshotsPath, SnapshotTableSerializer.INFO_SERIALIZER));
  }
  return result;
}

代码示例来源:origin: org.apache.kylin/kylin-core-job

public List<ExecutableOutputPO> getJobOutputs(long timeStart, long timeEndExclusive) throws PersistentException {
  try {
    return store.getAllResources(ResourceStore.EXECUTE_OUTPUT_RESOURCE_ROOT, false,
        new ResourceStore.VisitFilter(timeStart, timeEndExclusive),
        new ContentReader(JOB_OUTPUT_SERIALIZER));
  } catch (IOException e) {
    logger.error("error get all Jobs:", e);
    throw new PersistentException(e);
  }
}

代码示例来源:origin: org.apache.kylin/kylin-core-job

public List<ExecutablePO> getJobs(long timeStart, long timeEndExclusive) throws PersistentException {
  try {
    return store.getAllResources(ResourceStore.EXECUTE_RESOURCE_ROOT, false,
        new ResourceStore.VisitFilter(timeStart, timeEndExclusive), new ContentReader(JOB_SERIALIZER));
  } catch (IOException e) {
    logger.error("error get all Jobs:", e);
    throw new PersistentException(e);
  }
}

代码示例来源:origin: org.apache.kylin/kylin-core-dictionary

public List<ExtTableSnapshotInfo> getSnapshots(String tableName) throws IOException {
  String tableSnapshotsPath = ExtTableSnapshotInfo.getResourceDir(tableName);
  ResourceStore store = TableMetadataManager.getInstance(this.config).getStore();
  return store.getAllResources(tableSnapshotsPath, SNAPSHOT_SERIALIZER);
}

代码示例来源:origin: org.apache.kylin/kylin-core-dictionary

private DictionaryInfo findLargestDictInfo(DictionaryInfo dictInfo) throws IOException {
  final ResourceStore store = getStore();
  final List<DictionaryInfo> allResources = store.getAllResources(dictInfo.getResourceDir(), DictionaryInfoSerializer.INFO_SERIALIZER);
  DictionaryInfo largestDict = null;
  for (DictionaryInfo dictionaryInfo : allResources) {
    if (largestDict == null) {
      largestDict = dictionaryInfo;
      continue;
    }
    if (largestDict.getCardinality() < dictionaryInfo.getCardinality()) {
      largestDict = dictionaryInfo;
    }
  }
  return largestDict;
}

代码示例来源:origin: org.apache.kylin/kylin-core-dictionary

private String checkDupByInfo(DictionaryInfo dictInfo) throws IOException {
  final ResourceStore store = getStore();
  final List<DictionaryInfo> allResources = store.getAllResources(dictInfo.getResourceDir(), DictionaryInfoSerializer.INFO_SERIALIZER);
  TableSignature input = dictInfo.getInput();
  for (DictionaryInfo dictionaryInfo : allResources) {
    if (input.equals(dictionaryInfo.getInput())) {
      return dictionaryInfo.getResourcePath();
    }
  }
  return null;
}

相关文章