in src/main/java/com/amazonaws/services/neptune/profiles/neptune_ml/v1/PropertyGraphTrainingDataConfigWriterV1.java [214:260]
private void writeNodeFeatureOverride(Label label,
FeatureOverrideConfigV1 featureOverride,
Collection<PropertySchema> propertySchemas,
LabelSchema labelSchema) throws IOException {
if (featureOverride.isSinglePropertyOverride()) {
PropertySchema propertySchema = propertySchemas.stream()
.filter(p -> p.nameWithoutDataType().equals(featureOverride.firstProperty()))
.findFirst()
.orElse(null);
if (propertySchema == null) {
warnings.add(String.format("Unable to add node feature: Node of type '%s' does not contain property '%s'.",
label.fullyQualifiedLabel(),
featureOverride.firstProperty()));
} else {
FeatureTypeV1 featureType = featureOverride.featureType();
if (FeatureTypeV1.category == featureType) {
writeCategoricalNodeFeature(label, Collections.singletonList(propertySchema), featureOverride.separator());
} else if (FeatureTypeV1.numerical == featureType) {
writeNumericalNodeFeature(label, Collections.singletonList(propertySchema), featureOverride.norm(), labelSchema, featureOverride.separator());
}
}
} else {
boolean allPropertiesPresent = featureOverride.properties().stream()
.allMatch(p ->
propertySchemas.stream()
.anyMatch(s -> s.nameWithoutDataType().equals(p)));
if (!allPropertiesPresent) {
warnings.add(String.format("Unable to add multi-property node feature: Node of type '%s' does not contain one or more of the following properties: %s.",
label.fullyQualifiedLabel(),
featureOverride.properties().stream()
.map(s -> String.format("'%s'", s))
.collect(Collectors.joining(", "))));
} else {
FeatureTypeV1 featureType = featureOverride.featureType();
List<PropertySchema> multiPropertySchemas = propertySchemas.stream()
.filter(p -> featureOverride.properties().contains(p.nameWithoutDataType()))
.collect(Collectors.toList());
if (FeatureTypeV1.category == featureType) {
writeCategoricalNodeFeature(label, multiPropertySchemas);
} else if (FeatureTypeV1.numerical == featureType) {
writeNumericalNodeFeature(label, multiPropertySchemas, featureOverride.norm(), labelSchema);
}
}
}
}