use of org.locationtech.geowave.core.store.adapter.FieldDescriptorBuilder in project geowave by locationtech.
the class FeatureDataAdapter method initializeFieldDescriptors.
private void initializeFieldDescriptors() {
final List<AttributeDescriptor> attributes = featureType.getAttributeDescriptors();
fieldDescriptors = new FieldDescriptor[attributes.size()];
for (int i = 0; i < attributes.size(); i++) {
final AttributeDescriptor attribute = attributes.get(i);
if (attribute instanceof GeometryDescriptor) {
final SpatialFieldDescriptorBuilder<?> builder = new SpatialFieldDescriptorBuilder<>(attribute.getType().getBinding());
builder.fieldName(attribute.getName().getLocalPart());
builder.crs(((GeometryDescriptor) attribute).getCoordinateReferenceSystem());
if ((featureType.getGeometryDescriptor() != null) && featureType.getGeometryDescriptor().equals(attribute)) {
builder.spatialIndexHint();
}
fieldDescriptors[i] = builder.build();
} else if ((timeDescriptors != null) && attribute.equals(timeDescriptors.getTime())) {
fieldDescriptors[i] = new TemporalFieldDescriptorBuilder<>(attribute.getType().getBinding()).fieldName(attribute.getName().getLocalPart()).timeIndexHint().build();
} else if ((timeDescriptors != null) && attribute.equals(timeDescriptors.getStartRange())) {
fieldDescriptors[i] = new TemporalFieldDescriptorBuilder<>(attribute.getType().getBinding()).fieldName(attribute.getName().getLocalPart()).startTimeIndexHint().build();
} else if ((timeDescriptors != null) && attribute.equals(timeDescriptors.getEndRange())) {
fieldDescriptors[i] = new TemporalFieldDescriptorBuilder<>(attribute.getType().getBinding()).fieldName(attribute.getName().getLocalPart()).endTimeIndexHint().build();
} else {
fieldDescriptors[i] = new FieldDescriptorBuilder<>(attribute.getType().getBinding()).fieldName(attribute.getName().getLocalPart()).build();
}
}
// this assumes attribute names are unique, which *should* be a fair assumption
descriptorsMap = Arrays.stream(fieldDescriptors).collect(Collectors.toMap(FieldDescriptor::fieldName, descriptor -> descriptor));
}
use of org.locationtech.geowave.core.store.adapter.FieldDescriptorBuilder in project geowave by locationtech.
the class BaseAnnotatedFieldDescriptorBuilder method buildFieldDescriptor.
@Override
public FieldDescriptor<?> buildFieldDescriptor(Field field) {
if (field.isAnnotationPresent(GeoWaveField.class)) {
final GeoWaveField fieldAnnotation = field.getAnnotation(GeoWaveField.class);
final String fieldName;
if (fieldAnnotation.name().isEmpty()) {
fieldName = field.getName();
} else {
fieldName = fieldAnnotation.name();
}
final String[] indexHints = fieldAnnotation.indexHints();
final FieldDescriptorBuilder<?, ?, ?> builder = new FieldDescriptorBuilder<>(BasicDataTypeAdapter.normalizeClass(field.getType()));
for (final String hint : indexHints) {
builder.indexHint(new IndexDimensionHint(hint));
}
return builder.fieldName(fieldName).build();
}
throw new RuntimeException("Field is missing GeoWaveField annotation.");
}
Aggregations