use of org.locationtech.geowave.core.index.CustomIndexStrategy in project geowave by locationtech.
the class BaseDataStoreUtils method getWriteInfo.
protected static <T> IntermediaryWriteEntryInfo getWriteInfo(final T entry, final InternalDataAdapter<T> adapter, final AdapterToIndexMapping indexMapping, final Index index, final VisibilityHandler visibilityHandler, final boolean secondaryIndex, final boolean dataIdIndex, final boolean visibilityEnabled) {
final CommonIndexModel indexModel = index.getIndexModel();
final short internalAdapterId = adapter.getAdapterId();
final byte[] dataId = adapter.getDataId(entry);
final AdapterPersistenceEncoding encodedData = adapter.encode(entry, indexMapping, index);
if (encodedData == null) {
// The entry could not be encoded to the index, but this could be due to a null value in one
// of the index fields, which is possible in attribute indices
LOGGER.info("Indexing failed to produce insertion ids; entry [" + StringUtils.stringFromBinary(adapter.getDataId(entry)) + "] not saved for index '" + index.getName() + "'.");
return new IntermediaryWriteEntryInfo(dataId, internalAdapterId, new InsertionIds(), new GeoWaveValueImpl[0]);
}
final InsertionIds insertionIds;
if (index instanceof CustomIndexStrategy) {
insertionIds = ((CustomIndexStrategy) index).getInsertionIds(entry);
} else {
insertionIds = dataIdIndex ? null : encodedData.getInsertionIds(index);
}
if (dataIdIndex) {
return getWriteInfoDataIDIndex(entry, dataId, encodedData, adapter, indexMapping, index, visibilityHandler, visibilityEnabled);
}
if (insertionIds.isEmpty()) {
// we can allow some entries to not be indexed within every index for flexibility, and
// therefore this should just be info level
LOGGER.info("Indexing failed to produce insertion ids; entry [" + StringUtils.stringFromBinary(adapter.getDataId(entry)) + "] not saved for index '" + index.getName() + "'.");
return new IntermediaryWriteEntryInfo(dataId, internalAdapterId, insertionIds, new GeoWaveValueImpl[0]);
}
final VisibilityComposer commonIndexVisibility = new VisibilityComposer();
if (visibilityEnabled && (visibilityHandler != null)) {
for (final Entry<String, Object> fieldValue : encodedData.getCommonData().getValues().entrySet()) {
addIndexFieldVisibility(entry, adapter, indexMapping, visibilityHandler, fieldValue.getKey(), commonIndexVisibility);
}
}
if (secondaryIndex && DataIndexUtils.adapterSupportsDataIndex(adapter)) {
return new IntermediaryWriteEntryInfo(dataId, internalAdapterId, insertionIds, new GeoWaveValue[] { new GeoWaveValueImpl(new byte[0], StringUtils.stringToBinary(commonIndexVisibility.composeVisibility()), new byte[0]) });
}
final List<FieldInfo<?>> fieldInfoList = new ArrayList<>();
addCommonFields(adapter, indexMapping, entry, index, indexModel, visibilityHandler, encodedData, visibilityEnabled, fieldInfoList);
for (final Entry<String, Object> fieldValue : encodedData.getAdapterExtendedData().getValues().entrySet()) {
if (fieldValue.getValue() != null) {
final FieldInfo<?> fieldInfo = getFieldInfo(adapter, adapter, indexMapping, fieldValue.getKey(), fieldValue.getValue(), entry, visibilityHandler, visibilityEnabled, false);
if (fieldInfo != null) {
fieldInfoList.add(fieldInfo);
}
}
}
return new IntermediaryWriteEntryInfo(dataId, internalAdapterId, insertionIds, BaseDataStoreUtils.composeFlattenedFields(fieldInfoList, indexModel, adapter, commonIndexVisibility, dataIdIndex));
}
Aggregations