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;
}
}
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();
}
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);
}
}
}
}
}
}
}
Aggregations