Search in sources :

Example 11 with Message

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;
}
Also used : Message(com.swiftmq.impl.streams.comp.message.Message)

Example 12 with Message

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;
}
Also used : Message(com.swiftmq.impl.streams.comp.message.Message)

Example 13 with Message

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;
}
Also used : Message(com.swiftmq.impl.streams.comp.message.Message)

Example 14 with Message

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;
}
Also used : Message(com.swiftmq.impl.streams.comp.message.Message)

Example 15 with Message

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;
}
Also used : Message(com.swiftmq.impl.streams.comp.message.Message) Property(com.swiftmq.impl.streams.comp.message.Property)

Aggregations

Message (com.swiftmq.impl.streams.comp.message.Message)21 Property (com.swiftmq.impl.streams.comp.message.Property)4 POMgmtMessage (com.swiftmq.impl.streams.processor.po.POMgmtMessage)3 ManagementInput (com.swiftmq.impl.streams.comp.io.ManagementInput)2 QueueWireTapInput (com.swiftmq.impl.streams.comp.io.QueueWireTapInput)2 MessageSelector (com.swiftmq.ms.MessageSelector)2 Input (com.swiftmq.impl.streams.comp.io.Input)1 HeapMemory (com.swiftmq.impl.streams.comp.memory.HeapMemory)1 Memory (com.swiftmq.impl.streams.comp.memory.Memory)1 MessageImpl (com.swiftmq.jms.MessageImpl)1 QueueImpl (com.swiftmq.jms.QueueImpl)1 BigDecimal (java.math.BigDecimal)1 ResultSet (java.sql.ResultSet)1 ResultSetMetaData (java.sql.ResultSetMetaData)1 Statement (java.sql.Statement)1