Github user JoshRosen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3803#discussion_r23881453
  
    --- Diff: 
streaming/src/main/scala/org/apache/spark/streaming/StreamingContext.scala ---
    @@ -372,6 +392,33 @@ class StreamingContext private[streaming] (
       }
     
       /**
    +   * Create an input stream that monitors a Hadoop-compatible filesystem
    +   * for new files and reads them as flat binary files, assuming a fixed 
length per record,
    +   * generating one byte array per record. Files must be written to the 
monitored directory
    +   * by "moving" them from another location within the same file system. 
File names
    +   * starting with . are ignored.
    +   *
    +   * '''Note:''' Normally getBytes returns an array padded with extra 
values,
    +   * but the FixedLengthBinaryInputFormat ensures that it will always be 
backed
    +   * by a byte array of the correct length (the recordLength)
    +   *
    +   * @param directory HDFS directory to monitor for new file
    +   * @param recordLength length of each record in bytes
    +   */
    +  def binaryRecordsStream(
    +      directory: String,
    +      recordLength: Int): DStream[Array[Byte]] = {
    +    val conf = sc_.hadoopConfiguration
    +    conf.setInt(FixedLengthBinaryInputFormat.RECORD_LENGTH_PROPERTY, 
recordLength)
    +    val br = fileStream[LongWritable, BytesWritable, 
FixedLengthBinaryInputFormat](directory, conf)
    +    val data = br.map{ case (k, v) =>
    +      val bytes = v.getBytes
    +      assert(bytes.length == recordLength, "Byte array does not have 
correct length")
    +      bytes}
    --- End diff --
    
    Same style nit applies in this file, too.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to