use of com.swiftmq.impl.streams.comp.message.Message in project swiftmq-ce by iitsoftware.
the class GroupResult method min.
/**
* Determines the minimum value of a Property and returns the result as a new non-queue Memory with
* Messages that contains 2 Properties, the grouping Property and the minimum Property.
*
* @param propName Property Name
* @return Result
* @throws Exception
*/
public Memory min(String propName) throws Exception {
Memory child = new HeapMemory(ctx);
for (int i = 0; i < result.length; i++) {
Message message = result[i].first();
child.add(ctx.messageBuilder.message().property(groupPropName).set(message.property(groupPropName).value().toObject()).property(propName).set(result[i].min(propName)));
}
return child;
}
use of com.swiftmq.impl.streams.comp.message.Message in project swiftmq-ce by iitsoftware.
the class GroupResult method max.
/**
* Determines the maximum value of a Property and returns the result as a new non-queue Memory with
* Messages that contains 2 Properties, the grouping Property and the maximum Property.
*
* @param propName Property Name
* @return Result
* @throws Exception
*/
public Memory max(String propName) throws Exception {
Memory child = new HeapMemory(ctx);
for (int i = 0; i < result.length; i++) {
Message message = result[i].first();
child.add(ctx.messageBuilder.message().property(groupPropName).set(message.property(groupPropName).value().toObject()).property(propName).set(result[i].max(propName)));
}
return child;
}
use of com.swiftmq.impl.streams.comp.message.Message in project swiftmq-ce by iitsoftware.
the class GroupResult method average.
/**
* Determines the average value of a Property and returns the result as a new non-queue Memory with
* Messages that contains 2 Properties, the grouping Property and the average Property.
*
* @param propName Property Name
* @return Result
* @throws Exception
*/
public Memory average(String propName) throws Exception {
Memory child = new HeapMemory(ctx);
for (int i = 0; i < result.length; i++) {
Message message = result[i].first();
child.add(ctx.messageBuilder.message().property(groupPropName).set(message.property(groupPropName).value().toObject()).property(propName).set(result[i].average(propName)));
}
return child;
}
use of com.swiftmq.impl.streams.comp.message.Message in project swiftmq-ce by iitsoftware.
the class Memory method join.
/**
* Performs an inner join with the right Memory. Use this method to join 2 Memories over different Property names.
*
* @param right Memory to join with
* @param leftJoinProp left join Property name
* @param rightJoinProp right join Property name
* @return result Memory
* @throws Exception
*/
public Memory join(Memory right, String leftJoinProp, String rightJoinProp) throws Exception {
if (right.index(rightJoinProp) == null) {
right.createIndex(rightJoinProp);
}
Memory result = new HeapMemory(ctx);
for (int i = 0; i < size(); i++) {
Message leftMessage = at(i);
Memory rightResult = right.index(rightJoinProp).get(leftMessage.property(leftJoinProp).value().toObject());
for (int j = 0; j < rightResult.size(); j++) {
Message rightMessage = rightResult.at(j);
Message leftCopy = ctx.messageBuilder.copyMessage(leftMessage);
leftCopy.copyProperties(rightMessage);
result.add(leftCopy);
}
}
return result;
}
use of com.swiftmq.impl.streams.comp.message.Message in project swiftmq-ce by iitsoftware.
the class Memory method min.
/**
* Returns the Message with the minimum value of a Property.
*
* @param propName Property Name
* @return Message
* @throws Exception
*/
public Message min(String propName) throws Exception {
Comparable value = null;
Message selected = null;
for (int i = 0; i < size(); i++) {
Message message = at(i);
Property property = message.property(propName);
Comparable val = (Comparable) property.value().toObject();
if (value == null || val.compareTo(value) < 0) {
value = val;
selected = message;
}
}
return selected;
}
Aggregations