@Test void testMembership() { Stream<Entry<DataStructureComponent<?, ?, ?>, Stream<DataStructureComponent<?, ?, ?>>>> expected = Stream.of( new SimpleEntry<>(STR_ID, Stream.of(STR_ID, INT_ID, new DataStructureComponentImpl<>(STRINGDS.getVarName(), Measure.class, STRINGDS))), new SimpleEntry<>(INT_ID, Stream.of(STR_ID, INT_ID, new DataStructureComponentImpl<>(INTEGERDS.getVarName(), Measure.class, INTEGERDS))), new SimpleEntry<>(INT_ME, Stream.of(STR_ID, INT_ID, INT_ME)), new SimpleEntry<>(BOL_ME, Stream.of(STR_ID, INT_ID, BOL_ME))); expected.map(keepingKey(s -> s.reduce(new DataStructureBuilder(), DataStructureBuilder::addComponent, DataStructureBuilder::merge).build())) .map(e -> new SimpleEntry<>(e.getValue(), INSTANCE.membership(e.getKey().getName()).getMetadata())) .forEach(e -> assertEquals(e.getKey(), e.getValue(), "Structural mismatch in membership")); verify(INSTANCE, times(4)).membership(anyString()); }
@Override public DataSet membership(String componentName) { final DataSetMetadata membershipStructure = dataStructure.membership(componentName); LOGGER.trace("Creating dataset by membership on {} from {} to {}", componentName, dataStructure, membershipStructure); DataStructureComponent<?, ?, ?> sourceComponent = dataStructure.getComponent(componentName) .orElseThrow(() -> new VTLMissingComponentsException(componentName, dataStructure)); DataStructureComponent<? extends Measure, ?, ?> membershipMeasure = membershipStructure.getComponents(Measure.class).iterator().next(); return mapKeepingKeys(membershipStructure, dp -> { if (!dp.containsKey(sourceComponent)) throw new VTLMissingComponentsException(sourceComponent, dp); final ScalarValue<?, ?, ?> gotValue = dp.get(sourceComponent); return singletonMap(membershipMeasure, gotValue); }); }
AbstractDataSet implements DataSet { @Override public DataSet membership(String componentName) { final DataSetMetadata membershipStructure = dataStructure.membership(componentName); LOGGER.trace("Creating dataset by membership on {} from {} to {}", componentName, dataStructure, membershipStructure); DataStructureComponent<?, ?, ?> sourceComponent = dataStructure.getComponent(componentName) .orElseThrow(() -> new VTLMissingComponentsException(componentName, dataStructure)); DataStructureComponent<? extends Measure, ?, ?> membershipMeasure = membershipStructure.getComponents(Measure.class).iterator().next(); return mapKeepingKeys(membershipStructure, dp -> { if (!dp.containsKey(sourceComponent)) throw new VTLMissingComponentsException(sourceComponent, dp); final ScalarValue<?, ?, ?> gotValue = dp.get(sourceComponent); return singletonMap(membershipMeasure, gotValue); }); } }
AbstractDataSet implements DataSet { @Override public DataSet membership(String componentName) { final DataSetMetadata membershipStructure = dataStructure.membership(componentName); LOGGER.trace("Creating dataset by membership on {} from {} to {}", componentName, dataStructure, membershipStructure); DataStructureComponent<?, ?, ?> sourceComponent = dataStructure.getComponent(componentName) .orElseThrow(() -> new VTLMissingComponentsException(componentName, dataStructure)); DataStructureComponent<? extends Measure, ?, ?> membershipMeasure = membershipStructure.getComponents(Measure.class).iterator().next(); return mapKeepingKeys(membershipStructure, dp -> { if (!dp.containsKey(sourceComponent)) throw new VTLMissingComponentsException(sourceComponent, dp); final ScalarValue<?, ?, ?> gotValue = dp.get(sourceComponent); return singletonMap(membershipMeasure, gotValue); }); } protected  AbstractDataSet(DataSetMetadata dataStructure); }
AbstractDataSet implements DataSet { @Override public DataSet membership(String componentName) { final DataSetMetadata membershipStructure = dataStructure.membership(componentName); LOGGER.trace("Creating dataset by membership on {} from {} to {}", componentName, dataStructure, membershipStructure); DataStructureComponent<?, ?, ?> sourceComponent = dataStructure.getComponent(componentName) .orElseThrow(() -> new VTLMissingComponentsException(componentName, dataStructure)); DataStructureComponent<? extends Measure, ?, ?> membershipMeasure = membershipStructure.getComponents(Measure.class).iterator().next(); return mapKeepingKeys(membershipStructure, dp -> { if (!dp.containsKey(sourceComponent)) throw new VTLMissingComponentsException(sourceComponent, dp); final ScalarValue<?, ?, ?> gotValue = dp.get(sourceComponent); return singletonMap(membershipMeasure, gotValue); }); } 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 membership(String componentName) { final DataSetMetadata membershipStructure = dataStructure.membership(componentName); LOGGER.trace("Creating dataset by membership on {} from {} to {}", componentName, dataStructure, membershipStructure); DataStructureComponent<?, ?, ?> sourceComponent = dataStructure.getComponent(componentName) .orElseThrow(() -> new VTLMissingComponentsException(componentName, dataStructure)); DataStructureComponent<? extends Measure, ?, ?> membershipMeasure = membershipStructure.getComponents(Measure.class).iterator().next(); return mapKeepingKeys(membershipStructure, dp -> { if (!dp.containsKey(sourceComponent)) throw new VTLMissingComponentsException(sourceComponent, dp); final ScalarValue<?, ?, ?> gotValue = dp.get(sourceComponent); return singletonMap(membershipMeasure, gotValue); }); } 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();  }