Search in sources :

Example 11 with LabelCountMap

use of com.revolsys.util.count.LabelCountMap in project com.revolsys.open by revolsys.

the class StatisticsMultipleFilterProcess method processPredicate.

@Override
protected boolean processPredicate(final Record object, final Predicate<Record> filter, final Channel<Record> filterOut) {
    if (super.processPredicate(object, filter, filterOut)) {
        if (this.useStatistics) {
            LabelCountMap stats = this.statisticsMap.get(filter);
            String name;
            if (stats == null) {
                if (this.statisticsName != null) {
                    name = this.statisticsName + " " + filter.toString();
                } else {
                    name = filter.toString();
                }
                stats = new LabelCountMap(name);
                stats.connect();
                this.statisticsMap.put(filter, stats);
            }
            stats.addCount(object);
        }
        return true;
    } else {
        return false;
    }
}
Also used : LabelCountMap(com.revolsys.util.count.LabelCountMap)

Example 12 with LabelCountMap

use of com.revolsys.util.count.LabelCountMap in project com.revolsys.open by revolsys.

the class StatisticsProcess method preRun.

@Override
protected void preRun(final Channel<Record> in, final Channel<Record> out) {
    this.labelCountMap = new LabelCountMap(getBeanName());
    this.labelCountMap.connect();
}
Also used : LabelCountMap(com.revolsys.util.count.LabelCountMap)

Example 13 with LabelCountMap

use of com.revolsys.util.count.LabelCountMap in project com.revolsys.open by revolsys.

the class RecordStoreLayer method forEachRecordsPersisted.

@SuppressWarnings("unchecked")
public <R extends LayerRecord> void forEachRecordsPersisted(final Query query, final Consumer<? super R> consumer) {
    if (query != null && isExists()) {
        final RecordStore recordStore = getRecordStore();
        if (recordStore != null) {
            try (final BaseCloseable booleanValueCloseable = eventsDisabled();
                Transaction transaction = recordStore.newTransaction(Propagation.REQUIRES_NEW);
                final RecordReader reader = newRecordStoreRecordReader(query)) {
                final LabelCountMap labelCountMap = query.getProperty("statistics");
                for (final LayerRecord record : reader.<LayerRecord>i()) {
                    final Identifier identifier = getId(record);
                    R proxyRecord = null;
                    if (identifier == null) {
                        proxyRecord = (R) newProxyLayerRecordNoId(record);
                    } else {
                        synchronized (getSync()) {
                            final LayerRecord cachedRecord = getCachedRecord(identifier, record, true);
                            if (!cachedRecord.isDeleted()) {
                                proxyRecord = newProxyLayerRecord(identifier);
                            }
                        }
                    }
                    if (proxyRecord != null) {
                        consumer.accept(proxyRecord);
                        if (labelCountMap != null) {
                            labelCountMap.addCount(record);
                        }
                    }
                }
            }
        }
    }
}
Also used : BaseCloseable(com.revolsys.io.BaseCloseable) Identifier(com.revolsys.identifier.Identifier) Transaction(com.revolsys.transaction.Transaction) LabelCountMap(com.revolsys.util.count.LabelCountMap) RecordStore(com.revolsys.record.schema.RecordStore) RecordReader(com.revolsys.record.io.RecordReader)

Aggregations

LabelCountMap (com.revolsys.util.count.LabelCountMap)13 CategoryLabelCountMap (com.revolsys.util.count.CategoryLabelCountMap)4 PostConstruct (javax.annotation.PostConstruct)4 Identifier (com.revolsys.identifier.Identifier)1 BaseCloseable (com.revolsys.io.BaseCloseable)1 RecordReader (com.revolsys.record.io.RecordReader)1 RecordStore (com.revolsys.record.schema.RecordStore)1 Transaction (com.revolsys.transaction.Transaction)1 ConcurrentModificationException (java.util.ConcurrentModificationException)1