Skip to content
Snippets Groups Projects

Enable geo-shape decimation for all the kinds that have spatial location

Merged Zhibin Mai requested to merge geo_shape_decimation_extension into master
5 files
+ 297
22
Compare changes
  • Side-by-side
  • Inline
Files
5
@@ -211,32 +211,34 @@ public class StorageIndexerPayloadMapper {
}
private void mapVirtualPropertiesPayload(IndexSchema storageSchema, String recordId, Map<String, Object> dataCollectorMap) {
if (dataCollectorMap.isEmpty() || this.virtualPropertiesSchemaCache.get(storageSchema.getKind()) == null) {
if (dataCollectorMap.isEmpty()) {
return;
}
VirtualProperties virtualProperties = (VirtualProperties) this.virtualPropertiesSchemaCache.get(storageSchema.getKind());
String originalGeoShapeProperty = null;
for (Map.Entry<String, VirtualProperty> entry : virtualProperties.getProperties().entrySet()) {
if (entry.getValue().getPriorities() == null || entry.getValue().getPriorities().size() == 0) {
continue;
}
Priority priority = chooseOriginalProperty(entry.getKey(), entry.getValue().getPriorities(), dataCollectorMap);
String virtualPropertyPath = VirtualPropertyUtil.removeDataPrefix(entry.getKey());
String originalPropertyPath = VirtualPropertyUtil.removeDataPrefix(priority.getPath());
if(this.virtualPropertiesSchemaCache.get(storageSchema.getKind()) != null) {
VirtualProperties virtualProperties = (VirtualProperties) this.virtualPropertiesSchemaCache.get(storageSchema.getKind());
for (Map.Entry<String, VirtualProperty> entry : virtualProperties.getProperties().entrySet()) {
if (entry.getValue().getPriorities() == null || entry.getValue().getPriorities().size() == 0) {
continue;
}
Priority priority = chooseOriginalProperty(entry.getKey(), entry.getValue().getPriorities(), dataCollectorMap);
String virtualPropertyPath = VirtualPropertyUtil.removeDataPrefix(entry.getKey());
String originalPropertyPath = VirtualPropertyUtil.removeDataPrefix(priority.getPath());
// Populate the virtual property values from the chosen original property
List<String> originalPropertyNames = dataCollectorMap.keySet().stream()
.filter(originalPropertyName -> VirtualPropertyUtil.isPropertyPathMatched(originalPropertyName, originalPropertyPath))
.collect(Collectors.toList());
originalPropertyNames.forEach(originalPropertyName -> {
String virtualPropertyName = virtualPropertyPath + originalPropertyName.substring(originalPropertyPath.length());
dataCollectorMap.put(virtualPropertyName, dataCollectorMap.get(originalPropertyName));
});
if(virtualPropertyPath.equals(VirtualPropertyUtil.VIRTUAL_DEFAULT_LOCATION) &&
dataCollectorMap.containsKey(VirtualPropertyUtil.VIRTUAL_DEFAULT_LOCATION_WGS84_PATH)) {
originalGeoShapeProperty = originalPropertyPath + VirtualPropertyUtil.FIELD_WGS84_COORDINATES;
// Populate the virtual property values from the chosen original property
List<String> originalPropertyNames = dataCollectorMap.keySet().stream()
.filter(originalPropertyName -> VirtualPropertyUtil.isPropertyPathMatched(originalPropertyName, originalPropertyPath))
.collect(Collectors.toList());
originalPropertyNames.forEach(originalPropertyName -> {
String virtualPropertyName = virtualPropertyPath + originalPropertyName.substring(originalPropertyPath.length());
dataCollectorMap.put(virtualPropertyName, dataCollectorMap.get(originalPropertyName));
});
if(virtualPropertyPath.equals(VirtualPropertyUtil.VIRTUAL_DEFAULT_LOCATION) &&
dataCollectorMap.containsKey(VirtualPropertyUtil.VIRTUAL_DEFAULT_LOCATION_WGS84_PATH)) {
originalGeoShapeProperty = originalPropertyPath + VirtualPropertyUtil.FIELD_WGS84_COORDINATES;
}
}
}
Loading