Search in sources :

Example 1 with BaseTuple

use of org.drools.core.reteoo.BaseTuple in project drools by kiegroup.

the class ProtobufOutputMarshaller method writeTuple.

public static Tuple writeTuple(MarshallerWriteContext context, Activation activation, boolean isDormient) {
    org.drools.core.spi.Tuple tuple = activation.getTuple();
    ProtobufMessages.Tuple.Builder _tb = ProtobufMessages.Tuple.newBuilder();
    boolean serializeObjects = isDormient && hasNodeMemory((BaseTuple) activation);
    if (tuple != null) {
        // tuple can be null if this is a rule network evaluation activation, instead of terminal node left tuple.
        for (org.drools.core.spi.Tuple entry = tuple.skipEmptyHandles(); entry != null; entry = entry.getParent()) {
            InternalFactHandle handle = entry.getFactHandle();
            _tb.addHandleId(handle.getId());
            if (serializeObjects) {
                ObjectMarshallingStrategy marshallingStrategy = context.getObjectMarshallingStrategyStore().getStrategyObject(handle.getObject());
                Integer strategyIndex = context.getStrategyIndex(marshallingStrategy);
                ProtobufMessages.SerializedObject.Builder _so = ProtobufMessages.SerializedObject.newBuilder();
                _so.setObject(serializeObject(context, marshallingStrategy, handle.getObject()));
                _so.setStrategyIndex(strategyIndex);
                _tb.addObject(_so.build());
            }
        }
    }
    return _tb.build();
}
Also used : BaseTuple(org.drools.core.reteoo.BaseTuple) ObjectMarshallingStrategy(org.kie.api.marshalling.ObjectMarshallingStrategy) InternalFactHandle(org.drools.core.common.InternalFactHandle) Tuple(org.drools.serialization.protobuf.ProtobufMessages.Tuple) BaseTuple(org.drools.core.reteoo.BaseTuple) LeftTuple(org.drools.core.reteoo.LeftTuple) RightTuple(org.drools.core.reteoo.RightTuple)

Aggregations

InternalFactHandle (org.drools.core.common.InternalFactHandle)1 BaseTuple (org.drools.core.reteoo.BaseTuple)1 LeftTuple (org.drools.core.reteoo.LeftTuple)1 RightTuple (org.drools.core.reteoo.RightTuple)1 Tuple (org.drools.serialization.protobuf.ProtobufMessages.Tuple)1 ObjectMarshallingStrategy (org.kie.api.marshalling.ObjectMarshallingStrategy)1