protected synchronized void store(final InternalDataAdapter<?> adapter) { if (!adapterStore.adapterExists(adapter.getAdapterId())) { adapterStore.addAdapter(adapter); } }
public void initForWrite() { // this is ensuring the adapter is properly initialized with the // indicies and writing it to the adapterStore, in cases where the // featuredataadapter was created from geotools datastore's createSchema if (adapter instanceof InitializeWithIndicesDataAdapter) { ((InitializeWithIndicesDataAdapter) adapter).init(adapterIndices); } final short internalAdapterId = gtStore.getInternalAdapterStore().getAdapterId(adapter.getTypeName()); final InternalDataAdapter<?> internalDataAdapter = new InternalDataAdapterWrapper(adapter, internalAdapterId); gtStore.adapterStore.addAdapter(internalDataAdapter); }
@Override public void createSchema(final SimpleFeatureType featureType) { if (featureType.getGeometryDescriptor() == null) { throw new UnsupportedOperationException("Schema missing geometry"); } final FeatureDataAdapter adapter = new FeatureDataAdapter(featureType, visibilityManagement); final short adapterId = internalAdapterStore.addTypeName(adapter.getTypeName()); if (!adapterStore.adapterExists(adapterId)) { // it is questionable whether createSchema *should* write the // adapter to the store, it is missing the proper index information // at this stage adapter.init(new SpatialDimensionalityTypeProvider().createIndex(new SpatialOptions())); if (featureNameSpaceURI != null) { adapter.setNamespace(featureNameSpaceURI.toString()); } final InternalDataAdapter<?> internalAdapter = new InternalDataAdapterWrapper(adapter, adapterId); adapterStore.addAdapter(internalAdapter); } }
protected InternalDataAdapter<?> getAdapter( final PropertyManagement runTimeProperties, final ParameterEnum dataTypeEnum, final ParameterEnum dataNameSpaceEnum) throws Exception { final String projectionDataTypeId = runTimeProperties.storeIfEmpty(dataTypeEnum, "convex_hull").toString(); final PersistentAdapterStore adapterStore = getAdapterStore(runTimeProperties); final InternalAdapterStore internalAdapterStore = getInternalAdapterStore(runTimeProperties); final Short convexHullInternalAdapterId = internalAdapterStore.getAdapterId(projectionDataTypeId); if (convexHullInternalAdapterId == null) { final String namespaceURI = runTimeProperties.storeIfEmpty( dataNameSpaceEnum, BasicFeatureTypes.DEFAULT_NAMESPACE).toString(); final FeatureDataAdapter adapter = AnalyticFeature.createGeometryFeatureAdapter( projectionDataTypeId, new String[0], namespaceURI, ClusteringUtils.CLUSTERING_CRS); final short internalAdapterId = internalAdapterStore.addTypeName(adapter.getTypeName()); final InternalDataAdapter<?> internalAdapter = new InternalDataAdapterWrapper<>(adapter, internalAdapterId); adapterStore.addAdapter(internalAdapter); return internalAdapter; } return adapterStore.getAdapter(convexHullInternalAdapterId); }
private void internalAddIndices( final InternalDataAdapter<?> adapter, final Index[] indices, final boolean updateAdapter) { if (adapter.getAdapter() instanceof InitializeWithIndicesDataAdapter) { if (((InitializeWithIndicesDataAdapter) adapter.getAdapter()).init(indices) && updateAdapter) { adapterStore.removeAdapter(adapter.getAdapterId()); adapterStore.addAdapter(adapter); } } indexMappingStore.addAdapterIndexMapping( new AdapterToIndexMapping( internalAdapterStore.addTypeName(adapter.getTypeName()), indices)); for (final Index index : indices) { store(index); initOnIndexWriterCreate(adapter, index); } }