private static void createAndLoadSecondaryIndexesForTarget(Dataset source, Dataset target,
MetadataProvider metadataProvider, IHyracksClientConnection hcc) throws Exception {
for (Index index : metadataProvider.getDatasetIndexes(source.getDataverseName(), source.getDatasetName())) {
if (!index.isSecondaryIndex()) {
continue;
}
JobSpecification indexCreationJobSpec =
IndexUtil.buildSecondaryIndexCreationJobSpec(target, index, metadataProvider, null);
JobUtils.runJob(hcc, indexCreationJobSpec, true);
JobSpecification indexLoadingJobSpec =
IndexUtil.buildSecondaryIndexLoadingJobSpec(target, index, metadataProvider, null);
JobUtils.runJob(hcc, indexLoadingJobSpec, true);
}
}