You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spark.apache.org by Sandeep Katta <sa...@gmail.com> on 2018/10/17 16:25:11 UTC

some doubt on code understanding

Hi Guys,

I am trying to understand structured streaming code flow by doing so I came
across below code flow

def nextBatchTime(now: Long): Long = {
  if (intervalMs == 0) now else now / intervalMs * intervalMs + intervalMs
}

 else part could also have been written as

now + intervalMs

is there any specific reason why that code is written like above,or is
it by mistake ?


Apologies upfront if this is really silly/basic question.


Regards

Sandeep Katta

Re: some doubt on code understanding

Posted by Reynold Xin <rx...@databricks.com>.
Rounding.

On Wed, Oct 17, 2018 at 6:25 PM Sandeep Katta <
sandeep0102.opensource@gmail.com> wrote:

> Hi Guys,
>
> I am trying to understand structured streaming code flow by doing so I
> came across below code flow
>
> def nextBatchTime(now: Long): Long = {
>   if (intervalMs == 0) now else now / intervalMs * intervalMs + intervalMs
> }
>
>  else part could also have been written as
>
> now + intervalMs
>
> is there any specific reason why that code is written like above,or is it by mistake ?
>
>
> Apologies upfront if this is really silly/basic question.
>
>
> Regards
>
> Sandeep Katta
>
>

Re: some doubt on code understanding

Posted by Sandeep Katta <sa...@gmail.com>.
:) thanks I am wondering how did I miss that :) :)

On Wed, 17 Oct 2018 at 21:58, Sean Owen <sr...@gmail.com> wrote:

> "/" is integer division, so "x / y * y" is not x, but more like the
> biggest multiple of y that's <= x.
> On Wed, Oct 17, 2018 at 11:25 AM Sandeep Katta
> <sa...@gmail.com> wrote:
> >
> > Hi Guys,
> >
> > I am trying to understand structured streaming code flow by doing so I
> came across below code flow
> >
> > def nextBatchTime(now: Long): Long = {
> >   if (intervalMs == 0) now else now / intervalMs * intervalMs +
> intervalMs
> > }
> >
> >  else part could also have been written as
> >
> > now + intervalMs
> >
> > is there any specific reason why that code is written like above,or is
> it by mistake ?
> >
> >
> > Apologies upfront if this is really silly/basic question.
> >
> >
> > Regards
> >
> > Sandeep Katta
>

Re: some doubt on code understanding

Posted by Sean Owen <sr...@gmail.com>.
"/" is integer division, so "x / y * y" is not x, but more like the
biggest multiple of y that's <= x.
On Wed, Oct 17, 2018 at 11:25 AM Sandeep Katta
<sa...@gmail.com> wrote:
>
> Hi Guys,
>
> I am trying to understand structured streaming code flow by doing so I came across below code flow
>
> def nextBatchTime(now: Long): Long = {
>   if (intervalMs == 0) now else now / intervalMs * intervalMs + intervalMs
> }
>
>  else part could also have been written as
>
> now + intervalMs
>
> is there any specific reason why that code is written like above,or is it by mistake ?
>
>
> Apologies upfront if this is really silly/basic question.
>
>
> Regards
>
> Sandeep Katta

---------------------------------------------------------------------
To unsubscribe e-mail: dev-unsubscribe@spark.apache.org