@Override public MemoryEntry getEntry() { return (MemoryEntry) super.getEntry(); }
@Override /** * We are already holding onto our transaction from ContentState; however this method does check * that the transaction is correct. */ public synchronized void setTransaction(Transaction transaction) { if (this.transaction != null && transaction == null) { // clear ContentEntry transaction to fix GEOT-3315 state.getEntry().clearTransaction(this.transaction); } this.transaction = transaction; }
/** * Creates a new state from a previous one. * * <p>All state from the specified <tt>state</tt> is copied. Therefore subclasses extending this * constructor should clone all mutable objects. * * @param state The existing state. */ protected ContentState(ContentState state) { this(state.getEntry()); featureType = state.featureType; count = state.count; bounds = state.bounds == null ? null : ReferencedEnvelope.reference(state.bounds); batchFeatureEvent = null; }
public MemoryFeatureReader(ContentState state, Query query) throws IOException { featureType = state.getFeatureType(); MemoryEntry entry = (MemoryEntry) state.getEntry(); final List<SimpleFeature> internalCollection = new ArrayList<>(entry.getMemory().values()); iterator = internalCollection.iterator(); }
public PropertyFeatureWriter( ContentFeatureSource source, ContentState contentState, Query query, boolean append) throws IOException { this.state = contentState; this.featureSource = source; PropertyDataStore store = (PropertyDataStore) contentState.getEntry().getDataStore(); String namespaceURI = store.getNamespaceURI(); String typeName = query.getTypeName(); File dir = store.dir; read = new File(store.dir, typeName + ".properties"); write = File.createTempFile(typeName + System.currentTimeMillis(), null, dir); // start reading delegate = new PropertyFeatureReader(namespaceURI, read); type = delegate.getFeatureType(); // open writer writer = new BufferedWriter(new FileWriter(write)); // write header writer.write("_="); writer.write(DataUtilities.encodeType(type)); } // constructor end
ContentEntry entry = state.getEntry(); Name name = entry.getName(); ContentDataStore dataStore = entry.getDataStore();
/** * Creates a new state from a previous one. * <p> * All state from the specified <tt>state</tt> is copied. Therefore subclasses * extending this constructor should clone all mutable objects. * </p> * * @param state The existing state. */ protected ContentState(ContentState state) { this(state.getEntry()); featureType = state.featureType; count = state.count; bounds = state.bounds == null ? null : new ReferencedEnvelope( state.bounds ); batchFeatureEvent = null; }
@Override /** * We are already holding onto our transaction from * ContentState; however this method does check that * the transaction is correct. */ public synchronized void setTransaction(Transaction transaction) { if (this.transaction != null && transaction == null) { // clear ContentEntry transaction to fix GEOT-3315 state.getEntry().clearTransaction(this.transaction); } this.transaction = transaction; }
protected SimpleFeature buildFeature() { row += 1; return builder.buildFeature( state.getEntry().getTypeName()+"."+row ); }
public ElasticFeatureReader(ContentState contentState, List<ElasticHit> hits, Map<String,ElasticAggregation> aggregations, float maxScore) { this.state = contentState; this.featureType = state.getFeatureType(); this.searchHitIterator = hits.iterator(); this.builder = new SimpleFeatureBuilder(featureType); this.parserUtil = new ElasticParserUtil(); this.maxScore = maxScore; this.aggregationIterator = Collections.emptyIterator(); if (aggregations != null && !aggregations.isEmpty()) { String aggregationName = aggregations.keySet().stream().findFirst().orElse(null); if (aggregations.size() > 1) { LOGGER.info("Result has multiple aggregations. Using " + aggregationName); } if (aggregations.get(aggregationName).getBuckets() != null) { this.aggregationIterator = aggregations.get(aggregationName).getBuckets().iterator(); } } if (contentState.getEntry() != null && contentState.getEntry().getDataStore() != null) { final ElasticDataStore dataStore; dataStore = (ElasticDataStore) contentState.getEntry().getDataStore(); this.arrayEncoding = dataStore.getArrayEncoding(); } else { this.arrayEncoding = ArrayEncoding.valueOf((String) ElasticDataStoreFactory.ARRAY_ENCODING.getDefaultValue()); } this.mapper = new ObjectMapper(); }
@Override public void close() throws IOException { if (!scrollIds.isEmpty()) { final ElasticDataStore dataStore; dataStore = (ElasticDataStore) contentState.getEntry().getDataStore(); dataStore.getClient().clearScroll(scrollIds); } delegate.close(); }
public CSVFeatureReader(ContentState contentState) throws IOException { this.state = contentState; CSVDataStore csv = (CSVDataStore) contentState.getEntry().getDataStore(); reader = csv.read(); // this may throw an IOException if it could not connect boolean header = reader.readHeaders(); if (! header ){ throw new IOException("Unable to read csv header"); } builder = new SimpleFeatureBuilder( state.getFeatureType() ); geometryFactory = JTSFactoryFinder.getGeometryFactory(null); row = 0; }
@Override public void close() throws IOException { if (this.appending) { return; } this.checkPendingWrite(); super.close(); this.csvWriter.close(); ((CSVDataStore) this.state.getEntry().getDataStore()).write(this.tempFile); }
private void advanceScroll() throws IOException { final ElasticDataStore dataStore; dataStore = (ElasticDataStore) contentState.getEntry().getDataStore(); processResponse(dataStore.getClient().scroll(nextScrollId, dataStore.getScrollTime())); }
public MemoryFeatureWriterWithProvidedFIDSupport(ContentState state, Query query) throws IOException { this.state = state; featureType = state.getFeatureType(); String typeName = featureType.getTypeName(); MemoryDataStoreWithProvidedFIDSupport store = (MemoryDataStoreWithProvidedFIDSupport) state .getEntry().getDataStore(); contents = store.entry(typeName).getMemory(); iterator = contents.values().iterator(); }
public MemoryFeatureWriterWithProvidedFIDSupport(ContentState state, Query query) throws IOException { this.state = state; featureType = state.getFeatureType(); String typeName = featureType.getTypeName(); MemoryDataStoreWithProvidedFIDSupport store = (MemoryDataStoreWithProvidedFIDSupport) state .getEntry().getDataStore(); contents = store.entry(typeName).getMemory(); iterator = contents.values().iterator(); }
public GeobufFeatureWriter(ContentState state, Query query, int precision, int dimension) throws IOException { this.state = state; String typeName = query.getTypeName(); DataStore dataStore = state.getEntry().getDataStore(); if (dataStore instanceof GeobufDirectoryDataStore) { this.file = ((GeobufDirectoryDataStore) dataStore).getDataStore(typeName).getFile(); } else { this.file = ((GeobufDataStore) dataStore).getFile(); } File directory = file.getParentFile(); this.temp = File.createTempFile(typeName + System.currentTimeMillis(), "geobuf", directory); this.dataBuilder = Geobuf.Data.newBuilder(); GeobufFeatureType geobufFeatureType = new GeobufFeatureType(); geobufFeatureType.encode(state.getFeatureType(), dataBuilder); dataBuilder.build().writeTo(new FileOutputStream(this.temp)); this.featureCollectionBuilder = Geobuf.Data.FeatureCollection.newBuilder(); this.geobufFeature = new GeobufFeature(new GeobufGeometry(precision, dimension)); this.delegate = new GeobufFeatureReader(state, query, precision, dimension); }
return state.getEntry().getTypeName() + "." + hit.getId();
@Override public SimpleFeature next() throws IOException, IllegalArgumentException, NoSuchElementException { if (this.append) { this.builder.addAll(new Object[this.state.getEntry().getDataStore().getSchema(this.getFeatureType().getTypeName()).getAttributeCount()]); this.each = this.buildFeature(); return this.each; } this.checkPendingWrite(); return this.each = super.next(); }
public GeobufFeatureReader(ContentState state, Query query, int precision, int dimension) throws IOException { this.state = state; this.geobufGeometry = new GeobufGeometry(precision, dimension, JTSFactoryFinder.getGeometryFactory(null)); this.geobufFeature = new GeobufFeature(geobufGeometry); this.featureBuilder = new SimpleFeatureBuilder(state.getFeatureType()); File file; DataStore dataStore = state.getEntry().getDataStore(); if (dataStore instanceof GeobufDirectoryDataStore) { file = ((GeobufDirectoryDataStore) dataStore) .getDataStore(state.getFeatureType().getTypeName()) .getFile(); } else { file = ((GeobufDataStore) dataStore).getFile(); } this.in = new FileInputStream(file); this.data = Geobuf.Data.parseFrom(in); }