Example #1
0
  public static void writePropagationContexts(MarshallerWriteContext context) throws IOException {
    ObjectOutputStream stream = context.stream;

    if (context.terminalTupleMap != null && context.terminalTupleMap.size() > 0) {
      Entry<LeftTuple, Integer>[] entries =
          context.terminalTupleMap.entrySet().toArray(new Entry[context.terminalTupleMap.size()]);
      Arrays.sort(entries, TupleSorter.instance);

      // Map<LeftTuple, Integer> tuples = context.terminalTupleMap;
      if (entries.length != 0) {
        Map<Long, PropagationContext> pcMap = new HashMap<Long, PropagationContext>();
        for (Entry<LeftTuple, Integer> entry : entries) {
          LeftTuple leftTuple = entry.getKey();
          if (leftTuple.getObject() != null) {
            PropagationContext pc = ((Activation) leftTuple.getObject()).getPropagationContext();
            if (!pcMap.containsKey(pc.getPropagationNumber())) {
              stream.writeShort(PersisterEnums.PROPAGATION_CONTEXT);
              writePropagationContext(context, pc);
              pcMap.put(pc.getPropagationNumber(), pc);
            }
          }
        }
      }
    }

    stream.writeShort(PersisterEnums.END);
  }
Example #2
0
  public static void writeLeftTuples(
      MarshallerWriteContext context, InternalFactHandle[] factHandles) throws IOException {
    ObjectOutputStream stream = context.stream;
    InternalWorkingMemory wm = context.wm;

    // Write out LeftTuples
    // context.out.println( "LeftTuples Start" );
    for (InternalFactHandle handle : factHandles) {
      // InternalFactHandle handle = (InternalFactHandle) it.next();

      for (LeftTuple leftTuple = handle.getFirstLeftTuple();
          leftTuple != null;
          leftTuple = (LeftTuple) leftTuple.getLeftParentNext()) {
        stream.writeShort(PersisterEnums.LEFT_TUPLE);
        int sinkId = leftTuple.getLeftTupleSink().getId();
        stream.writeInt(sinkId);
        stream.writeInt(handle.getId());

        // context.out.println( "LeftTuple sinkId:" + leftTuple.getLeftTupleSink().getId() + "
        // handleId:" + handle.getId() );
        writeLeftTuple(leftTuple, context, true);
      }
    }

    stream.writeShort(PersisterEnums.END);
    // context.out.println( "LeftTuples End" );
  }
Example #3
0
  public static void writeActivation(
      MarshallerWriteContext context,
      LeftTuple leftTuple,
      AgendaItem agendaItem,
      RuleTerminalNode ruleTerminalNode)
      throws IOException {
    ObjectOutputStream stream = context.stream;

    stream.writeLong(agendaItem.getActivationNumber());

    stream.writeInt(context.terminalTupleMap.get(leftTuple));

    stream.writeInt(agendaItem.getSalience());

    Rule rule = agendaItem.getRule();
    stream.writeUTF(rule.getPackage());
    stream.writeUTF(rule.getName());

    // context.out.println( "Rule " + rule.getPackage() + "." + rule.getName() );

    // context.out.println( "AgendaItem long:" +
    // agendaItem.getPropagationContext().getPropagationNumber() );
    stream.writeLong(agendaItem.getPropagationContext().getPropagationNumber());

    if (agendaItem.getActivationGroupNode() != null) {
      stream.writeBoolean(true);
      // context.out.println( "ActivationGroup bool:" + true );
      stream.writeUTF(agendaItem.getActivationGroupNode().getActivationGroup().getName());
      // context.out.println( "ActivationGroup string:" +
      // agendaItem.getActivationGroupNode().getActivationGroup().getName() );
    } else {
      stream.writeBoolean(false);
      // context.out.println( "ActivationGroup bool:" + false );
    }

    stream.writeBoolean(agendaItem.isActivated());
    // context.out.println( "AgendaItem bool:" + agendaItem.isActivated() );

    if (agendaItem.getFactHandle() != null) {
      stream.writeBoolean(true);
      stream.writeInt(agendaItem.getFactHandle().getId());
    } else {
      stream.writeBoolean(false);
    }

    org.drools.core.util.LinkedList list = agendaItem.getLogicalDependencies();
    if (list != null && !list.isEmpty()) {
      for (LogicalDependency node = (LogicalDependency) list.getFirst();
          node != null;
          node = (LogicalDependency) node.getNext()) {
        stream.writeShort(PersisterEnums.LOGICAL_DEPENDENCY);
        stream.writeInt(((InternalFactHandle) node.getJustified()).getId());
        // context.out.println( "Logical Depenency : int " + ((InternalFactHandle)
        // node.getFactHandle()).getId() );
      }
    }
    stream.writeShort(PersisterEnums.END);
  }
Example #4
0
  public static void writeRightTuples(InternalFactHandle handle, MarshallerWriteContext context)
      throws IOException {
    ObjectOutputStream stream = context.stream;
    // context.out.println( "RightTuples Start" );

    for (RightTuple rightTuple = handle.getFirstRightTuple();
        rightTuple != null;
        rightTuple = (RightTuple) rightTuple.getHandleNext()) {
      stream.writeShort(PersisterEnums.RIGHT_TUPLE);
      writeRightTuple(rightTuple, context);
    }
    stream.writeShort(PersisterEnums.END);
    // context.out.println( "RightTuples END" );
  }
 /**
  * Serializes this object to the specified output stream for JDK Serialization.
  *
  * @param out output stream used for Object serialization.
  * @throws IOException if any of this object's fields cannot be written to the stream.
  * @since 1.0
  */
 private void writeObject(ObjectOutputStream out) throws IOException {
   out.defaultWriteObject();
   short alteredFieldsBitMask = getAlteredFieldsBitMask();
   out.writeShort(alteredFieldsBitMask);
   if (id != null) {
     out.writeObject(id);
   }
   if (startTimestamp != null) {
     out.writeObject(startTimestamp);
   }
   if (stopTimestamp != null) {
     out.writeObject(stopTimestamp);
   }
   if (lastAccessTime != null) {
     out.writeObject(lastAccessTime);
   }
   if (timeout != 0l) {
     out.writeLong(timeout);
   }
   if (expired) {
     out.writeBoolean(expired);
   }
   if (host != null) {
     out.writeUTF(host);
   }
   if (!CollectionUtils.isEmpty(attributes)) {
     out.writeObject(attributes);
   }
 }
 /** java.io.ObjectOutputStream#writeShort(int) */
 public void test_writeShortI() throws Exception {
   // Test for method void java.io.ObjectOutputStream.writeShort(int)
   oos.writeShort(127);
   oos.close();
   ois = new ObjectInputStream(new ByteArrayInputStream(bao.toByteArray()));
   assertEquals("Wrote incorrect short value", 127, ois.readShort());
 }
Example #7
0
  public static void writeInitialFactHandleLeftTuples(MarshallerWriteContext context)
      throws IOException {
    ObjectOutputStream stream = context.stream;

    // context.out.println( "InitialFact LeftTuples Start" );
    InternalFactHandle handle = context.wm.getInitialFactHandle();
    for (LeftTuple leftTuple = handle.getFirstLeftTuple();
        leftTuple != null;
        leftTuple = (LeftTuple) leftTuple.getLeftParentNext()) {
      stream.writeShort(PersisterEnums.LEFT_TUPLE);

      stream.writeInt(leftTuple.getLeftTupleSink().getId());
      // context.out.println( "LeftTuple sinkId:" + leftTuple.getLeftTupleSink().getId() );
      writeLeftTuple(leftTuple, context, true);
    }
    stream.writeShort(PersisterEnums.END);
    // context.out.println( "InitialFact LeftTuples End" );
  }
 public boolean execute(short val) {
   try {
     stream.writeShort(val);
   } catch (IOException e) {
     this.exception = e;
     return false;
   }
   return true;
 }
/*      */   private void writeObject(ObjectOutputStream s) throws IOException {
/* 1284 */     long[] key = this.key;
/* 1285 */     short[] value = this.value;
/* 1286 */     MapIterator i = new MapIterator(null);
/* 1287 */     s.defaultWriteObject();
/* 1288 */     for (int j = this.size; j-- != 0; ) {
/* 1289 */       int e = i.nextEntry();
/* 1290 */       s.writeLong(key[e]);
/* 1291 */       s.writeShort(value[e]);
/*      */     }
/*      */   }
Example #10
0
  public static void writeActivations(MarshallerWriteContext context) throws IOException {
    ObjectOutputStream stream = context.stream;

    Entry<LeftTuple, Integer>[] entries =
        context.terminalTupleMap.entrySet().toArray(new Entry[context.terminalTupleMap.size()]);
    Arrays.sort(entries, TupleSorter.instance);

    // Map<LeftTuple, Integer> tuples = context.terminalTupleMap;
    if (entries.length != 0) {
      for (Entry<LeftTuple, Integer> entry : entries) {
        if (entry.getKey().getObject() != null) {
          LeftTuple leftTuple = entry.getKey();
          stream.writeShort(PersisterEnums.ACTIVATION);
          writeActivation(
              context,
              leftTuple,
              (AgendaItem) leftTuple.getObject(),
              (RuleTerminalNode) leftTuple.getLeftTupleSink());
        }
      }
    }
    stream.writeShort(PersisterEnums.END);
  }
 /** Run benchmark for given number of batches, with given number of cycles for each batch. */
 void doReps(
     ObjectOutputStream oout, ObjectInputStream oin, StreamBuffer sbuf, int nbatches, int ncycles)
     throws Exception {
   for (int i = 0; i < nbatches; i++) {
     sbuf.reset();
     for (int j = 0; j < ncycles; j++) {
       oout.writeShort(0);
     }
     oout.flush();
     for (int j = 0; j < ncycles; j++) {
       oin.readShort();
     }
   }
 }
Example #12
0
  public static void writeTruthMaintenanceSystem(MarshallerWriteContext context)
      throws IOException {
    ObjectOutputStream stream = context.stream;

    ObjectHashMap assertMap = context.wm.getTruthMaintenanceSystem().getAssertMap();

    EqualityKey[] keys = new EqualityKey[assertMap.size()];
    org.drools.core.util.Iterator it = assertMap.iterator();
    int i = 0;
    for (org.drools.core.util.ObjectHashMap.ObjectEntry entry =
            (org.drools.core.util.ObjectHashMap.ObjectEntry) it.next();
        entry != null;
        entry = (org.drools.core.util.ObjectHashMap.ObjectEntry) it.next()) {
      EqualityKey key = (EqualityKey) entry.getKey();
      keys[i++] = key;
    }

    Arrays.sort(keys, EqualityKeySorter.instance);

    // write the assert map of Equality keys
    for (EqualityKey key : keys) {
      stream.writeShort(PersisterEnums.EQUALITY_KEY);
      stream.writeInt(key.getStatus());
      InternalFactHandle handle = key.getFactHandle();
      stream.writeInt(handle.getId());
      // context.out.println( "EqualityKey int:" + key.getStatus() + " int:" + handle.getId() );
      if (key.getOtherFactHandle() != null && !key.getOtherFactHandle().isEmpty()) {
        for (InternalFactHandle handle2 : key.getOtherFactHandle()) {
          stream.writeShort(PersisterEnums.FACT_HANDLE);
          stream.writeInt(handle2.getId());
          // context.out.println( "OtherHandle int:" + handle2.getId() );
        }
      }
      stream.writeShort(PersisterEnums.END);
    }
    stream.writeShort(PersisterEnums.END);
  }
Example #13
0
 /*
  * When object is serialized writeReplace() causes this
  * SerializationProxy object to be written. Write it in a
  * custom way that includes a version ID so that clients
  * and servers can have two different versions of code.
  */
 private void writeObject(java.io.ObjectOutputStream stream) throws IOException {
   stream.writeShort(serializationVersion);
   stream.writeObject(vehicleId);
   stream.writeLong(time);
   stream.writeFloat(latitude);
   stream.writeFloat(longitude);
   stream.writeFloat(speed);
   stream.writeFloat(heading);
   stream.writeObject(source);
   stream.writeObject(assignmentId);
   stream.writeObject(assignmentType);
   stream.writeObject(driverId);
   stream.writeObject(licensePlate);
   stream.writeInt(passengerCount);
 }
Example #14
0
    /*
     * When object is serialized writeReplace() causes this
     * SerializationProxy object to be written. Write it in a custom way
     * that includes a version ID so that clients and servers can have two
     * different versions of code.
     */
    protected void writeObject(java.io.ObjectOutputStream stream) throws IOException {
      stream.writeShort(currentSerializationVersion);

      stream.writeObject(blockId);
      stream.writeObject(blockAssignmentMethod);
      stream.writeObject(avl);
      stream.writeFloat(heading);
      stream.writeObject(routeId);
      stream.writeObject(routeShortName);
      stream.writeObject(tripId);
      stream.writeObject(tripPatternId);
      stream.writeObject(directionId);
      stream.writeObject(headsign);
      stream.writeBoolean(predictable);
      stream.writeBoolean(schedBasedPred);
      stream.writeObject(realTimeSchdAdh);
      stream.writeBoolean(isDelayed);
      stream.writeBoolean(isLayover);
      stream.writeLong(layoverDepartureTime);
      stream.writeObject(nextStopId);
      stream.writeObject(nextStopName);
      stream.writeObject(vehicleType);
    }
 @Override
 protected void writeEvent(ObjectOutputStream out) throws IOException {
   out.writeObject(getSub());
   out.writeObject(getData());
   out.writeShort(id);
 }
Example #16
0
  public static void writeLeftTuple(
      LeftTuple leftTuple, MarshallerWriteContext context, boolean recurse) throws IOException {
    ObjectOutputStream stream = context.stream;
    InternalRuleBase ruleBase = context.ruleBase;
    InternalWorkingMemory wm = context.wm;

    LeftTupleSink sink = leftTuple.getLeftTupleSink();

    switch (sink.getType()) {
      case NodeTypeEnums.JoinNode:
        {
          // context.out.println( "JoinNode" );
          for (LeftTuple childLeftTuple = leftTuple.getFirstChild();
              childLeftTuple != null;
              childLeftTuple = (LeftTuple) childLeftTuple.getLeftParentNext()) {
            stream.writeShort(PersisterEnums.RIGHT_TUPLE);
            int childSinkId = childLeftTuple.getLeftTupleSink().getId();
            stream.writeInt(childSinkId);
            stream.writeInt(childLeftTuple.getRightParent().getFactHandle().getId());
            // context.out.println( "RightTuple int:" + childLeftTuple.getLeftTupleSink().getId() +
            // " int:" + childLeftTuple.getRightParent().getFactHandle().getId() );
            writeLeftTuple(childLeftTuple, context, recurse);
          }
          stream.writeShort(PersisterEnums.END);
          // context.out.println( "JoinNode   ---   END" );
          break;
        }
      case NodeTypeEnums.QueryRiaFixerNode:
      case NodeTypeEnums.EvalConditionNode:
        {
          // context.out.println( ".... EvalConditionNode" );
          for (LeftTuple childLeftTuple = leftTuple.getFirstChild();
              childLeftTuple != null;
              childLeftTuple = (LeftTuple) childLeftTuple.getLeftParentNext()) {
            stream.writeShort(PersisterEnums.LEFT_TUPLE);
            stream.writeInt(childLeftTuple.getLeftTupleSink().getId());
            writeLeftTuple(childLeftTuple, context, recurse);
          }
          stream.writeShort(PersisterEnums.END);
          // context.out.println( "---- EvalConditionNode   ---   END" );
          break;
        }
      case NodeTypeEnums.NotNode:
      case NodeTypeEnums.ForallNotNode:
        {
          if (leftTuple.getBlocker() == null) {
            // is not blocked so has children
            stream.writeShort(PersisterEnums.LEFT_TUPLE_NOT_BLOCKED);

            for (LeftTuple childLeftTuple = leftTuple.getFirstChild();
                childLeftTuple != null;
                childLeftTuple = (LeftTuple) childLeftTuple.getLeftParentNext()) {
              stream.writeShort(PersisterEnums.LEFT_TUPLE);
              stream.writeInt(childLeftTuple.getLeftTupleSink().getId());
              writeLeftTuple(childLeftTuple, context, recurse);
            }
            stream.writeShort(PersisterEnums.END);

          } else {
            stream.writeShort(PersisterEnums.LEFT_TUPLE_BLOCKED);
            stream.writeInt(leftTuple.getBlocker().getFactHandle().getId());
          }
          break;
        }
      case NodeTypeEnums.ExistsNode:
        {
          if (leftTuple.getBlocker() == null) {
            // is blocked so has children
            stream.writeShort(PersisterEnums.LEFT_TUPLE_NOT_BLOCKED);
          } else {
            stream.writeShort(PersisterEnums.LEFT_TUPLE_BLOCKED);
            stream.writeInt(leftTuple.getBlocker().getFactHandle().getId());

            for (LeftTuple childLeftTuple = leftTuple.getFirstChild();
                childLeftTuple != null;
                childLeftTuple = (LeftTuple) childLeftTuple.getLeftParentNext()) {
              stream.writeShort(PersisterEnums.LEFT_TUPLE);
              stream.writeInt(childLeftTuple.getLeftTupleSink().getId());
              writeLeftTuple(childLeftTuple, context, recurse);
            }
            stream.writeShort(PersisterEnums.END);
          }
          break;
        }
      case NodeTypeEnums.AccumulateNode:
        {
          // context.out.println( ".... AccumulateNode" );
          // accumulate nodes generate new facts on-demand and need special procedures when
          // serializing to persistent storage
          AccumulateMemory memory = (AccumulateMemory) context.wm.getNodeMemory((BetaNode) sink);
          AccumulateContext accctx = (AccumulateContext) leftTuple.getObject();
          // first we serialize the generated fact handle
          writeFactHandle(
              context,
              stream,
              context.objectMarshallingStrategyStore,
              accctx.result.getFactHandle());
          // then we serialize the associated accumulation context
          stream.writeObject(accctx.context);
          // then we serialize the boolean propagated flag
          stream.writeBoolean(accctx.propagated);

          // then we serialize all the propagated tuples
          for (LeftTuple childLeftTuple = leftTuple.getFirstChild();
              childLeftTuple != null;
              childLeftTuple = (LeftTuple) childLeftTuple.getLeftParentNext()) {
            if (leftTuple.getLeftTupleSink().getId() == childLeftTuple.getLeftTupleSink().getId()) {
              // this is a matching record, so, associate the right tuples
              // context.out.println( "RightTuple(match) int:" +
              // childLeftTuple.getLeftTupleSink().getId() + " int:" +
              // childLeftTuple.getRightParent().getFactHandle().getId() );
              stream.writeShort(PersisterEnums.RIGHT_TUPLE);
              stream.writeInt(childLeftTuple.getRightParent().getFactHandle().getId());
            } else {
              // this is a propagation record
              // context.out.println( "RightTuple(propagation) int:" +
              // childLeftTuple.getLeftTupleSink().getId() + " int:" +
              // childLeftTuple.getRightParent().getFactHandle().getId() );
              stream.writeShort(PersisterEnums.LEFT_TUPLE);
              int sinkId = childLeftTuple.getLeftTupleSink().getId();
              stream.writeInt(sinkId);
              writeLeftTuple(childLeftTuple, context, recurse);
            }
          }
          stream.writeShort(PersisterEnums.END);
          // context.out.println( "---- AccumulateNode   ---   END" );
          break;
        }
      case NodeTypeEnums.RightInputAdaterNode:
        {
          // context.out.println( ".... RightInputAdapterNode" );
          // RIANs generate new fact handles on-demand to wrap tuples and need special procedures
          // when serializing to persistent storage
          ObjectHashMap memory = (ObjectHashMap) context.wm.getNodeMemory((NodeMemory) sink);
          InternalFactHandle ifh = (InternalFactHandle) memory.get(leftTuple);
          // first we serialize the generated fact handle ID
          // context.out.println( "FactHandle id:"+ifh.getId() );
          stream.writeInt(ifh.getId());
          stream.writeLong(ifh.getRecency());

          writeRightTuples(ifh, context);

          stream.writeShort(PersisterEnums.END);
          // context.out.println( "---- RightInputAdapterNode   ---   END" );
          break;
        }
      case NodeTypeEnums.FromNode:
        {
          // context.out.println( ".... FromNode" );
          // FNs generate new fact handles on-demand to wrap objects and need special procedures
          // when serializing to persistent storage
          FromMemory memory = (FromMemory) context.wm.getNodeMemory((NodeMemory) sink);

          Map<Object, RightTuple> matches = (Map<Object, RightTuple>) leftTuple.getObject();
          for (RightTuple rightTuples : matches.values()) {
            // first we serialize the generated fact handle ID
            stream.writeShort(PersisterEnums.FACT_HANDLE);
            writeFactHandle(
                context,
                stream,
                context.objectMarshallingStrategyStore,
                rightTuples.getFactHandle());
            writeRightTuples(rightTuples.getFactHandle(), context);
          }
          stream.writeShort(PersisterEnums.END);
          for (LeftTuple childLeftTuple = leftTuple.getFirstChild();
              childLeftTuple != null;
              childLeftTuple = (LeftTuple) childLeftTuple.getLeftParentNext()) {
            stream.writeShort(PersisterEnums.RIGHT_TUPLE);
            stream.writeInt(childLeftTuple.getLeftTupleSink().getId());
            stream.writeInt(childLeftTuple.getRightParent().getFactHandle().getId());
            // context.out.println( "RightTuple int:" + childLeftTuple.getLeftTupleSink().getId() +
            // " int:" + childLeftTuple.getRightParent().getFactHandle().getId() );
            writeLeftTuple(childLeftTuple, context, recurse);
          }
          stream.writeShort(PersisterEnums.END);
          // context.out.println( "---- FromNode   ---   END" );
          break;
        }
      case NodeTypeEnums.UnificationNode:
        {
          // context.out.println( ".... UnificationNode" );

          QueryElementNode node = (QueryElementNode) sink;
          boolean isOpen = node.isOpenQuery();

          context.writeBoolean(isOpen);
          if (isOpen) {
            InternalFactHandle factHandle = (InternalFactHandle) leftTuple.getObject();
            DroolsQuery query = (DroolsQuery) factHandle.getObject();

            // context.out.println( "factHandle:" +  factHandle );

            factHandle.setObject(null);
            writeFactHandle(context, stream, context.objectMarshallingStrategyStore, 0, factHandle);
            factHandle.setObject(query);
            writeLeftTuples(context, new InternalFactHandle[] {factHandle});
          } else {
            for (LeftTuple childLeftTuple = leftTuple.getFirstChild();
                childLeftTuple != null;
                childLeftTuple = (LeftTuple) childLeftTuple.getLeftParentNext()) {
              stream.writeShort(PersisterEnums.LEFT_TUPLE);
              stream.writeInt(childLeftTuple.getLeftTupleSink().getId());
              InternalFactHandle factHandle = childLeftTuple.getLastHandle();
              writeFactHandle(
                  context, stream, context.objectMarshallingStrategyStore, 1, factHandle);
              writeLeftTuple(childLeftTuple, context, recurse);
            }
            stream.writeShort(PersisterEnums.END);
          }
          // context.out.println( "---- EvalConditionNode   ---   END" );
          break;
        }
      case NodeTypeEnums.RuleTerminalNode:
        {
          // context.out.println( "RuleTerminalNode" );
          int pos = context.terminalTupleMap.size();
          context.terminalTupleMap.put(leftTuple, pos);
          break;
        }
      case NodeTypeEnums.QueryTerminalNode:
        {
          // context.out.println( ".... QueryTerminalNode" );
          //                LeftTuple entry = leftTuple;
          //
          //                // find the DroolsQuery object
          //                while ( entry.getParent() != null ) {
          //                    entry = entry.getParent();
          //                }
          //
          //                // Now output all the child tuples in the caller network
          //                DroolsQuery query = (DroolsQuery) entry.getLastHandle().getObject();
          //                if ( query.getQueryResultCollector() instanceof
          // UnificationNodeViewChangedEventListener ) {
          //                    context.writeBoolean( true );
          //                    UnificationNodeViewChangedEventListener collector =
          // (UnificationNodeViewChangedEventListener) query.getQueryResultCollector();
          //                    leftTuple = collector.getLeftTuple();
          //
          context.writeBoolean(true);
          RightTuple rightTuple = (RightTuple) leftTuple.getObject();
          // context.out.println( "rightTuple:" +  rightTuple.getFactHandle() );
          writeFactHandle(
              context,
              stream,
              context.objectMarshallingStrategyStore,
              1,
              rightTuple.getFactHandle());

          for (LeftTuple childLeftTuple = rightTuple.firstChild;
              childLeftTuple != null;
              childLeftTuple = (LeftTuple) childLeftTuple.getRightParentNext()) {
            stream.writeShort(PersisterEnums.LEFT_TUPLE);
            stream.writeInt(childLeftTuple.getLeftTupleSink().getId());
            writeLeftTuple(childLeftTuple, context, recurse);
          }

          //                    for ( LeftTuple childLeftTuple = leftTuple.getFirstChild();
          // childLeftTuple != null; childLeftTuple = (LeftTuple) childLeftTuple.getLeftParentNext()
          // ) {
          //                        stream.writeShort( PersisterEnums.LEFT_TUPLE );
          //                        stream.writeInt( childLeftTuple.getLeftTupleSink().getId() );
          //                        writeFactHandle( context,
          //                                         stream,
          //                                         context.objectMarshallingStrategyStore,
          //                                         1,
          //                                         childLeftTuple.getLastHandle() );
          //                        writeLeftTuple( childLeftTuple,
          //                                        context,
          //                                        recurse );
          //                    }
          //                } else {
          //                    context.writeBoolean( false );
          //                }
          stream.writeShort(PersisterEnums.END);
          // context.out.println( "---- QueryTerminalNode   ---   END" );
          break;
        }
    }
  }
 protected void store() throws Exception {
   ObjectOutputStream oos = null;
   File tmpFile = null;
   try {
     tmpFile = File.createTempFile("RNS", ".tmp", storageDirBase);
     tmpFile.deleteOnExit();
     oos = new ObjectOutputStream(new FileOutputStream(tmpFile));
     /* 1 */
     oos.writeObject(rnsProps.getCreateTime());
     /* 2 */
     oos.writeObject(rnsProps.getAccessTime());
     /* 3 */
     oos.writeObject(rnsProps.getModificationTime());
     if (list == null || list.size() == 0) {
       /* 4 */
       oos.writeInt(0); // list size
     } else {
       /* 4 */
       oos.writeInt(list.size());
       Iterator<String> i = list.keySet().iterator();
       while (i.hasNext()) {
         String name = i.next();
         /* 5 */
         oos.writeUTF(name);
         RNSEntryData ent = list.get(name);
         /* 6 */
         oos.writeBoolean(ent.isDirectory());
         /* 7 */
         if (ent.getLocalID() == null) {
           oos.writeUTF("");
         } else {
           oos.writeUTF(ent.getLocalID());
         }
         /* 8 */
         String eprStr;
         if (ent.getEpr() == null) {
           eprStr = "";
         } else {
           eprStr = RNSUtil.toXMLString(ent.getEpr());
         }
         oos.writeUTF(eprStr);
         if (ent.getRNSMetadata() != null && ent.getRNSMetadata().get_any() != null) {
           MessageElement[] me = ent.getRNSMetadata().get_any();
           /* 9 */
           oos.writeInt(me.length);
           for (int n = 0; n < me.length; n++) {
             String xml = me[n].getAsString();
             /* 10 */
             oos.writeUTF(xml);
             // System.out.println(getID() + "/" + name +
             // ": store XML:  " + xml);
           }
         } else {
           oos.writeInt(0); /* 9 */
           /* 10: nothing */
         }
       }
     }
     /* ACL */
     if (aclents == null || aclents.length == 0) {
       oos.writeInt(0); /* 11 */
       /* 12: nothing */
     } else {
       oos.writeInt(aclents.length);
       for (ACLEntryType aet : aclents) {
         /* 12 */
         oos.writeShort(aet.getType());
         String aclname = aet.getName();
         if (aclname == null) {
           aclname = DUMMY;
         }
         oos.writeUTF(aclname);
         oos.writeShort(aet.getPerm());
       }
     }
     logger.debug("store id=" + id);
   } catch (Exception e) {
     if (tmpFile != null) {
       if (tmpFile.delete() == false) {
         logger.error("cannot delete: " + tmpFile.getAbsolutePath());
       }
     }
     logger.error("cannot store resource: id=" + id);
     throw e;
   } finally {
     if (oos != null) {
       try {
         oos.close();
       } catch (Exception e2) {
         logger.warn("cannot write-close: " + tmpFile.getAbsolutePath() + ": " + e2.getMessage());
       }
     }
   }
   File file = getIdAsFile(id, data_suffix);
   if (file == null) {
     logger.error("directory is not exist: id=" + id);
     throw new Exception("Failed to store resource");
   }
   if (file.exists()) {
     if (file.delete() == false) {
       logger.error("cannot delete: " + file.getAbsolutePath());
     }
   }
   if (!tmpFile.renameTo(file)) {
     if (tmpFile.delete() == false) {
       logger.error("cannot rename: " + tmpFile.getAbsolutePath());
     }
     throw new Exception("Failed to store resource");
   }
 }
 private void writeObject(ObjectOutputStream oos) throws IOException {
   oos.writeShort(VERSION);
 }
 @Override
 public void writeShort(int val) throws IOException {
   out.writeShort(val);
 }
 private void writeObject(ObjectOutputStream out) throws IOException {
   out.writeShort(VERSION);
   out.writeInt(value);
 }