Search in sources :

Example 11 with ResultSet

use of org.polymap.recordstore.ResultSet in project polymap4-core by Polymap4.

the class RDataStore method deleteSchema.

public void deleteSchema(FeatureType schema, IProgressMonitor monitor) {
    // remove features
    try {
        RFeatureStore fs = (RFeatureStore) getFeatureSource(schema.getName());
        fs.removeFeatures(Filter.INCLUDE);
    } catch (Exception e) {
        log.debug("", e);
        throw new RuntimeException(e);
    }
    // remove schema
    Updater tx = store.prepareUpdate();
    try {
        ResultSet rs = store.find(new SimpleQuery().setMaxResults(1).eq("type", "FeatureType").eq("name", schema.getName().getLocalPart()).eq("namespace", schema.getName().getNamespaceURI()));
        assert rs.count() == 1 : "Illegal number of schemas found: " + rs.count();
        tx.remove(rs.get(0));
        tx.apply();
    } catch (Throwable e) {
        log.debug("", e);
        tx.discard();
        throw new RuntimeException(e);
    }
}
Also used : SimpleQuery(org.polymap.recordstore.SimpleQuery) Updater(org.polymap.recordstore.IRecordStore.Updater) ResultSet(org.polymap.recordstore.ResultSet) IOException(java.io.IOException)

Example 12 with ResultSet

use of org.polymap.recordstore.ResultSet in project polymap4-core by Polymap4.

the class AbstractRecordStoreTest method queryRecords.

protected void queryRecords(int loops) throws Exception {
    final Timer timer = new Timer();
    int found = 0;
    for (int i = 0; i < loops; i++) {
        // RecordQuery query = new SimpleQuery()
        // .eq( TestRecord.TYPE.count.name(), String.valueOf( i ) )
        // .eq( TestRecord.TYPE.type.name(), "2" )
        // .setMaxResults( 1 );
        SimpleQuery query = new SimpleQuery().setMaxResults(1);
        TestRecord template = new TestRecord(query);
        template.count.put(i);
        template.type.put("2");
        ResultSet result = store.find(query);
        // assertTrue( result.count() == 0);
        if (result.count() > 0) {
            found++;
        }
    // TestRecord record = new TestRecord( result.get( 0 ) );
    // dummy = record.type.get();
    }
    log.info("Records queried: " + found + " in " + timer.elapsedTime() + "ms -> " + (double) timer.elapsedTime() / loops + "ms/loop");
    store.close();
}
Also used : Timer(org.polymap.core.runtime.Timer) SimpleQuery(org.polymap.recordstore.SimpleQuery) ResultSet(org.polymap.recordstore.ResultSet)

Aggregations

ResultSet (org.polymap.recordstore.ResultSet)12 IOException (java.io.IOException)9 IRecordState (org.polymap.recordstore.IRecordState)8 SimpleQuery (org.polymap.recordstore.SimpleQuery)8 Timer (org.polymap.core.runtime.Timer)4 RecordQuery (org.polymap.recordstore.RecordQuery)4 FeatureType (org.opengis.feature.type.FeatureType)3 LuceneRecordQuery (org.polymap.recordstore.lucene.LuceneRecordQuery)3 ArrayList (java.util.ArrayList)2 Feature (org.opengis.feature.Feature)2 Updater (org.polymap.recordstore.IRecordStore.Updater)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 FeatureSource (org.geotools.data.FeatureSource)1 NameImpl (org.geotools.feature.NameImpl)1 ReferencedEnvelope (org.geotools.geometry.jts.ReferencedEnvelope)1 FeatureVisitor (org.opengis.feature.FeatureVisitor)1 Name (org.opengis.feature.type.Name)1 PropertyDescriptor (org.opengis.feature.type.PropertyDescriptor)1 ExcludeFilter (org.opengis.filter.ExcludeFilter)1