@Test void testMapKeepingKeys() { DataSet result = INSTANCE.mapKeepingKeys(STRUCTURE, dp -> dp.getValues(NonIdentifier.class)); assertEquals(STRUCTURE, result.getMetadata()); assertEquals(new HashSet<>(Arrays.asList(DATAPOINTS)), result.stream().collect(toSet())); }
@Override public DataSet mapKeepingKeys(DataSetMetadata metadata, Function<? super DataPoint, ? extends Map<? extends DataStructureComponent<? extends NonIdentifier, ?, ?>, ? extends ScalarValue<?, ?, ?>>> operator) { final Set<DataStructureComponent<Identifier, ?, ?>> identifiers = dataStructure.getComponents(Identifier.class); if (!metadata.getComponents(Identifier.class).equals(identifiers)) throw new VTLInvariantIdentifiersException("map", identifiers, metadata.getComponents(Identifier.class)); LOGGER.trace("Creating dataset by mapping from {} to {}", dataStructure, metadata); UnaryOperator<DataPoint> extendingOperator = dp -> new DataPointBuilder(dp.getValues(Identifier.class)) .addAll(operator.apply(dp)) .build(metadata); return new AbstractDataSet(metadata) { private static final long serialVersionUID = 1L; @Override protected Stream<DataPoint> streamDataPoints() { return AbstractDataSet.this.stream().map(extendingOperator); } }; }
AbstractDataSet implements DataSet { @Override public DataSet mapKeepingKeys(DataSetMetadata metadata, Function<? super DataPoint, ? extends Map<? extends DataStructureComponent<? extends NonIdentifier, ?, ?>, ? extends ScalarValue<?, ?, ?>>> operator) { final Set<DataStructureComponent<Identifier, ?, ?>> identifiers = dataStructure.getComponents(Identifier.class); if (!metadata.getComponents(Identifier.class).equals(identifiers)) throw new VTLInvariantIdentifiersException("map", identifiers, metadata.getComponents(Identifier.class)); LOGGER.trace("Creating dataset by mapping from {} to {}", dataStructure, metadata); UnaryOperator<DataPoint> extendingOperator = dp -> new DataPointBuilder(dp.getValues(Identifier.class)) .addAll(operator.apply(dp)) .build(metadata); return new AbstractDataSet(metadata) { private static final long serialVersionUID = 1L; @Override protected Stream<DataPoint> streamDataPoints() { return AbstractDataSet.this.stream().map(extendingOperator); } }; } }
AbstractDataSet implements DataSet { @Override public DataSet mapKeepingKeys(DataSetMetadata metadata, Function<? super DataPoint, ? extends Map<? extends DataStructureComponent<? extends NonIdentifier, ?, ?>, ? extends ScalarValue<?, ?, ?>>> operator) { final Set<DataStructureComponent<Identifier, ?, ?>> identifiers = dataStructure.getComponents(Identifier.class); if (!metadata.getComponents(Identifier.class).equals(identifiers)) throw new VTLInvariantIdentifiersException("map", identifiers, metadata.getComponents(Identifier.class)); LOGGER.trace("Creating dataset by mapping from {} to {}", dataStructure, metadata); UnaryOperator<DataPoint> extendingOperator = dp -> new DataPointBuilder(dp.getValues(Identifier.class)) .addAll(operator.apply(dp)) .build(metadata); return new AbstractDataSet(metadata) { private static final long serialVersionUID = 1L; @Override protected Stream<DataPoint> streamDataPoints() { return AbstractDataSet.this.stream().map(extendingOperator); } }; } protected  AbstractDataSet(DataSetMetadata dataStructure); }
AbstractDataSet implements DataSet { @Override public DataSet mapKeepingKeys(DataSetMetadata metadata, Function<? super DataPoint, ? extends Map<? extends DataStructureComponent<? extends NonIdentifier, ?, ?>, ? extends ScalarValue<?, ?, ?>>> operator) { final Set<DataStructureComponent<Identifier, ?, ?>> identifiers = dataStructure.getComponents(Identifier.class); if (!metadata.getComponents(Identifier.class).equals(identifiers)) throw new VTLInvariantIdentifiersException("map", identifiers, metadata.getComponents(Identifier.class)); LOGGER.trace("Creating dataset by mapping from {} to {}", dataStructure, metadata); UnaryOperator<DataPoint> extendingOperator = dp -> new DataPointBuilder(dp.getValues(Identifier.class)) .addAll(operator.apply(dp)) .build(metadata); return new AbstractDataSet(metadata) { private static final long serialVersionUID = 1L; @Override protected Stream<DataPoint> streamDataPoints() { return AbstractDataSet.this.stream().map(extendingOperator); } }; } protected  AbstractDataSet(DataSetMetadata dataStructure); @Override DataSet membership(String componentName); @Override Optional<DataStructureComponent<?, ?, ?>> getComponent(String name); @Override DataSetMetadata getMetadata(); @Override DataSet filteredMappedJoin(DataSetMetadata metadata, DataSet other, BiPredicate<DataPoint,DataPoint> predicate, BinaryOperator<DataPoint> mergeOp); @Override DataSet mapKeepingKeys(DataSetMetadata metadata,
			Function<? super DataPoint, ? extends Map<? extends DataStructureComponent<? extends NonIdentifier, ?, ?>, ? extends ScalarValue<?, ?, ?>>> operator); @Override Stream<T> streamByKeys(Set<DataStructureComponent<Identifier, ?, ?>> keys, 
			Map<DataStructureComponent<Identifier, ?, ?>, ScalarValue<?, ?, ?>> filter,
			Collector<DataPoint, A, TT> groupCollector,
			BiFunction<TT, Map<DataStructureComponent<Identifier, ?, ?>, ScalarValue<?, ?, ?>>, T> finisher); @Override DataSet filter(Predicate<DataPoint> predicate); @Override final Stream<DataPoint> stream(); String toString(); }
AbstractDataSet implements DataSet { @Override public DataSet mapKeepingKeys(DataSetMetadata metadata, Function<? super DataPoint, ? extends Map<? extends DataStructureComponent<? extends NonIdentifier, ?, ?>, ? extends ScalarValue<?, ?, ?>>> operator) { final Set<DataStructureComponent<Identifier, ?, ?>> identifiers = dataStructure.getComponents(Identifier.class); if (!metadata.getComponents(Identifier.class).equals(identifiers)) throw new VTLInvariantIdentifiersException("map", identifiers, metadata.getComponents(Identifier.class)); LOGGER.trace("Creating dataset by mapping from {} to {}", dataStructure, metadata); UnaryOperator<DataPoint> extendingOperator = dp -> new DataPointBuilder(dp.getValues(Identifier.class)) .addAll(operator.apply(dp)) .build(metadata); return new AbstractDataSet(metadata) { private static final long serialVersionUID = 1L; @Override protected Stream<DataPoint> streamDataPoints() { return AbstractDataSet.this.stream().map(extendingOperator); } }; } protected  AbstractDataSet(DataSetMetadata dataStructure); @Override DataSet membership(String componentName); @Override Optional<DataStructureComponent<?, ?, ?>> getComponent(String name); @Override DataSetMetadata getMetadata(); @Override DataSet filteredMappedJoin(DataSetMetadata metadata, DataSet other, BiPredicate<DataPoint,DataPoint> predicate, BinaryOperator<DataPoint> mergeOp); @Override DataSet mapKeepingKeys(DataSetMetadata metadata,
			Function<? super DataPoint, ? extends Map<? extends DataStructureComponent<? extends NonIdentifier, ?, ?>, ? extends ScalarValue<?, ?, ?>>> operator); @Override Stream<T> streamByKeys(Set<DataStructureComponent<Identifier, ?, ?>> keys, 
			Map<DataStructureComponent<Identifier, ?, ?>, ScalarValue<?, ?, ?>> filter,
			Collector<DataPoint, A, TT> groupCollector,
			BiFunction<TT, Map<DataStructureComponent<Identifier, ?, ?>, ScalarValue<?, ?, ?>>, T> finisher); @Override DataSet filter(Predicate<DataPoint> predicate); @Override final Stream<DataPoint> stream(); String toString();  }