You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@daffodil.apache.org by GitBox <gi...@apache.org> on 2019/03/04 20:27:02 UTC

[GitHub] [incubator-daffodil] mbeckerle commented on a change in pull request #192: Fix issue where suspensions with mixed byteOrder caused incorrect bitOrder to be used

mbeckerle commented on a change in pull request #192: Fix issue where suspensions with mixed byteOrder caused incorrect bitOrder to be used
URL: https://github.com/apache/incubator-daffodil/pull/192#discussion_r262228845
 
 

 ##########
 File path: daffodil-io/src/main/scala/org/apache/daffodil/io/DataOutputStreamImplMixin.scala
 ##########
 @@ -757,32 +757,46 @@ trait DataOutputStreamImplMixin extends DataStreamCommonState
    * Assumed to be called from inner loops, so should be fast as possible.
    */
   protected final def putLongUnchecked(signedLong: Long, bitLengthFrom1To64: Int, finfo: FormatInfo): Boolean = {
+    // The order we check bitOrder vs byteOrder here is actually very
+    // important, primarily due to how suspensions end up resolved and data
+    // output streams (DOS) collapsed. To explain why:
     //
-    // based on bit and byte order, dispatch to specific code
+    // When we create new a buffered DOS, no byteOrder is really associated
+    // with the DOS, because a DOS is just a series of bytes. To figure out
+    // what bytes to write to the DOS, we use the FormatInfo associated with an
+    // element, call the appropriate function below to convert that element to
+    // bytes, and then write those bytes to the DOS. This works as expected
+    // most of the time.
     //
+    // However, a buffered DOS maintains a fragment byte, and at some point we
+    // collapse that fragment byte into a direct DOS using this function. But
+    // we just said that there not really a byteOrder associated with a DOS,
+    // only with elements. So if we do not know the byteOrder of the fragment
+    // byte of a DOS, how do we know which function below to call when
+    // collapsing a fragment byte?
+    //
+    // Well, we do keep track of the bitOrder, since we need to know if we
 
 Review comment:
   Excellent comment. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services