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

    https://github.com/apache/spark/pull/13957#discussion_r68907588
  
    --- Diff: 
examples/src/main/scala/org/apache/spark/examples/sql/streaming/EventTimeWindow.scala
 ---
    @@ -0,0 +1,114 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +// scalastyle:off println
    +package org.apache.spark.examples.sql.streaming
    +
    +import org.apache.spark.sql.SparkSession
    +import org.apache.spark.sql.functions._
    +import org.apache.spark.sql.types.{DoubleType, TimestampType}
    +
    +/**
    + * Computes the average signal from IoT device readings over a sliding 
window of
    + * configurable duration. The readings are received over the network and 
must be
    + * UTF8-encoded and separated by '\n'.
    + *
    + * A single reading should take the format
    + * <device name (string)>, <reading (double)>, <time (timestamp)>
    + *
    + * Usage: EventTimeWindow <hostname> <port> <window duration>
    + *   <slide duration> <checkpoint dir>
    + * <hostname> and <port> describe the TCP server that Structured Streaming 
would connect to
    + * receive data.
    + * <window duration> gives the size of window, specified as integer number 
of seconds, minutes,
    + * or days, e.g. "1 minute", "2 seconds"
    + * <slide duration> gives the amount of time successive windows are offset 
from one another,
    + * given in the same units as above
    + * (<window duration> and <slide duration> must be enclosed by quotes to 
ensure that
    + * they are processed as individual arguments)
    + *
    + * To run this on your local machine, you need to first run a Netcat server
    + *    `$ nc -lk 9999`
    + * and then run the example
    + *    `$ bin/run-example sql.streaming.EventTimeWindow
    + *    localhost 9999 <window duration> <slide duration> <checkpoint dir>`
    + *
    + * Type device readings in the format given above into Netcat.
    + *
    + * An example sequence of device readings:
    + * dev0,7.0,2015-03-18T12:00:00
    + * dev1,8.0,2015-03-18T12:00:10
    + * dev0,5.0,2015-03-18T12:00:20
    + * dev1,3.0,2015-03-18T12:00:30
    --- End diff --
    
    i dont like it that the user has to enter data in a particular format. that 
make this clumsy to use. 
    
    how about this. lets add an option in the socket source, that attaches the 
receiving time as a column in the data. so the returned schema would be (time, 
line) if that option is specified. then we can very easily write a simple 
sliding window word count example using that.
    what do you think?


---
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