/** * Add underlying dataset specs. * @param specs specs to add * @return this builder object to allow chaining */ public Builder datasets(DatasetSpecification... specs) { return datasets(Arrays.asList(specs)); }
@Override public DatasetSpecification configure(String instanceName, DatasetProperties properties) { List<DatasetSpecification> specs = this.delegates.entrySet().stream() .map(impl -> impl.getValue().configure(impl.getKey(), properties)) .collect(Collectors.toList()); return DatasetSpecification.builder(instanceName, getName()) .properties(properties.getProperties()) .datasets(specs) .build(); }
@Override public DatasetSpecification reconfigure(String instanceName, DatasetProperties newProperties, DatasetSpecification currentSpec) throws IncompatibleUpdateException { List<DatasetSpecification> specs = new ArrayList<>(); for (Map.Entry<String, ? extends DatasetDefinition> impl : this.delegates.entrySet()) { specs.add(reconfigure(impl.getValue(), impl.getKey(), newProperties, currentSpec.getSpecification(impl.getKey()))); } return DatasetSpecification.builder(instanceName, getName()) .properties(newProperties.getProperties()) .datasets(specs) .build(); }
@Override public DatasetSpecification configure(String instanceName, DatasetProperties properties) { TableProperties.Builder tableProps = TableProperties.builder(); tableProps.addAll(properties.getProperties()); tableProps.setConflictDetection(ConflictDetection.COLUMN); Preconditions.checkNotNull(properties.getProperties().get(Constants.Scheduler.JOB_QUEUE_NUM_PARTITIONS), "Property '{}' must be given when creating job queue dataset", Constants.Scheduler.JOB_QUEUE_NUM_PARTITIONS); DatasetSpecification tableSpec = super.getDelegate(JobQueueDataset.EMBEDDED_TABLE_NAME).configure( JobQueueDataset.EMBEDDED_TABLE_NAME, tableProps.build()); return DatasetSpecification.builder(instanceName, getName()) .properties(properties.getProperties()) .datasets(Collections.singletonList(tableSpec)) .build(); }
@Override public DatasetSpecification configure(String instanceName, DatasetProperties properties) { String[] indexColumns = MetadataDataset.INDEX_COLUMNS.stream() .flatMap(indexCol -> Stream.of(indexCol.getCrossNamespaceColumn(), indexCol.getColumn())) .toArray(String[]::new); return DatasetSpecification.builder(instanceName, getName()) .properties(properties.getProperties()) .datasets( indexedTableDef.configure( METADATA_INDEX_TABLE_NAME, addIndexColumns(properties, indexColumns) ) ) .build(); }
@Test public void testNamespacing() { DatasetSpecification innerSpec = DatasetSpecification.builder("inner", "table") .build(); DatasetSpecification outerSpec = DatasetSpecification.builder("kv", "kvtable") .datasets(innerSpec) .build(); Assert.assertEquals("kv", outerSpec.getName()); Assert.assertEquals("kvtable", outerSpec.getType()); DatasetSpecification actualInner = outerSpec.getSpecification("inner"); Assert.assertEquals("kv.inner", actualInner.getName()); Assert.assertEquals("table", actualInner.getType()); Assert.assertTrue(actualInner.getSpecifications().isEmpty()); }
@Override public DatasetSpecification configure(String instanceName, DatasetProperties properties) { DatasetProperties factTableProperties = computeFactTableProperties(properties); List<DatasetSpecification> datasetSpecs = Lists.newArrayList(); // Configuring table that hold mappings of tag names and values and such datasetSpecs.add(metricsTableDef.configure("entity", properties)); // NOTE: we create a table per resolution; we later will use that to e.g. configure ttl separately for each for (int resolution : getResolutions(properties.getProperties())) { datasetSpecs.add(tableDef.configure(String.valueOf(resolution), factTableProperties)); } return DatasetSpecification.builder(instanceName, getName()) .properties(properties.getProperties()) .datasets(datasetSpecs) .build(); }
@Override public DatasetSpecification configure(String instanceName, DatasetProperties properties) { DatasetProperties factTableProperties = computeFactTableProperties(properties); List<DatasetSpecification> datasetSpecs = Lists.newArrayList(); // Configuring table that hold mappings of tag names and values and such datasetSpecs.add(metricsTableDef.configure("entity", properties)); // NOTE: we create a table per resolution; we later will use that to e.g. configure ttl separately for each for (int resolution : getResolutions(properties.getProperties())) { datasetSpecs.add(tableDef.configure(String.valueOf(resolution), factTableProperties)); } return DatasetSpecification.builder(instanceName, getName()) .properties(properties.getProperties()) .datasets(datasetSpecs) .build(); }
@Override public DatasetSpecification configure(String name, DatasetProperties properties) { return DatasetSpecification.builder(name, getName()) .properties(properties.getProperties()) .datasets(tableDefinition.configure(STATE_STORE_EMBEDDED_TABLE_NAME, properties)) .build(); }
@Override public DatasetSpecification reconfigure(String instanceName, DatasetProperties newProperties, DatasetSpecification currentSpec) throws IncompatibleUpdateException { // TODO (CDAP-6268): validate schema compatibility return DatasetSpecification.builder(instanceName, getName()) .properties(newProperties.getProperties()) .datasets(AbstractDatasetDefinition.reconfigure(tableDef, "objects", checkAndRemoveSchema(newProperties), currentSpec.getSpecification("objects"))) .build(); }
@Override public DatasetSpecification configure(String instanceName, DatasetProperties properties) { return DatasetSpecification.builder(instanceName, getName()) .properties(properties.getProperties()) .datasets(tableDef.configure("objects", checkAndRemoveSchema(properties))) .build(); }
@Override public DatasetSpecification reconfigure(String instanceName, DatasetProperties newProperties, DatasetSpecification currentSpec) throws IncompatibleUpdateException { // TODO (CDAP-6268): validate schema compatibility return DatasetSpecification.builder(instanceName, getName()) .properties(newProperties.getProperties()) .datasets(AbstractDatasetDefinition.reconfigure(tableDef, "objects", checkAndRemoveSchema(newProperties), currentSpec.getSpecification("objects"))) .build(); }
@Override public DatasetSpecification configure(String instanceName, DatasetProperties properties) { String schemaString = getSchemaString(properties); return DatasetSpecification.builder(instanceName, RecordDataset.class.getName()) .properties(properties.getProperties()) .property("schema", schemaString) .datasets(getDelegate("kv").configure("kv", DatasetProperties.EMPTY)) .build(); }
@Override public DatasetSpecification configure(String instanceName, DatasetProperties properties) { return DatasetSpecification.builder(instanceName, getName()) .properties(properties.getProperties()) .datasets(tableDef.configure("kv", properties)) .build(); }
@Override public DatasetSpecification configure(String instanceName, DatasetProperties properties) { return DatasetSpecification.builder(instanceName, getName()) .properties(properties.getProperties()) .datasets(tableDef.configure("objects", properties)) .build(); }
@Override public DatasetSpecification configure(String name, DatasetProperties properties) { TableProperties.Builder indexProps = TableProperties.builder(); indexProps.addAll(properties.getProperties()); indexProps.add(IndexedTable.INDEX_COLUMNS_CONF_KEY, ProgramScheduleStoreDataset.INDEX_COLUMNS); indexProps.setConflictDetection(ConflictDetection.COLUMN); DatasetSpecification indexSpec = getDelegate(ProgramScheduleStoreDataset.EMBEDDED_TABLE_NAME) .configure(ProgramScheduleStoreDataset.EMBEDDED_TABLE_NAME, indexProps.build()); return DatasetSpecification.builder(name, getName()).datasets(indexSpec).build(); }
@Override public DatasetSpecification configure(String instanceName, DatasetProperties properties) { return DatasetSpecification.builder(instanceName, getName()) .properties(properties.getProperties()) .datasets(tableDef.configure("table", properties)) .build(); }
@Override public DatasetSpecification configure(String name, DatasetProperties properties) { TableProperties.Builder indexProps = TableProperties.builder(); indexProps.addAll(properties.getProperties()); indexProps.add(IndexedTable.INDEX_COLUMNS_CONF_KEY, ProgramScheduleStoreDataset.INDEX_COLUMNS); indexProps.setConflictDetection(ConflictDetection.COLUMN); DatasetSpecification indexSpec = getDelegate(ProgramScheduleStoreDataset.EMBEDDED_TABLE_NAME) .configure(ProgramScheduleStoreDataset.EMBEDDED_TABLE_NAME, indexProps.build()); return DatasetSpecification.builder(name, getName()).datasets(indexSpec).build(); }
@Override public DatasetSpecification configure(String instanceName, DatasetProperties properties) { return DatasetSpecification.builder(instanceName, getName()) .properties(properties.getProperties()) .datasets(tableDef.configure("objects", checkAndRemoveSchema(properties))) .build(); }
@Override public DatasetSpecification configure(String instanceName, DatasetProperties properties) { return DatasetSpecification.builder(instanceName, getName()) .properties(properties.getProperties()) .datasets(tableDef.configure("objects", properties)) .build(); }