spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From budde <...@git.apache.org>
Subject [GitHub] spark pull request #18029: [SPARK-20168] [DStream] Add changes to use kinesi...
Date Fri, 18 Aug 2017 22:39:43 GMT
Github user budde commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18029#discussion_r134067693
  
    --- Diff: external/kinesis-asl/src/main/scala/org/apache/spark/streaming/kinesis/InitialPosition.scala
---
    @@ -0,0 +1,107 @@
    +/*
    + * 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.
    + */
    +package org.apache.spark.streaming.kinesis
    +
    +import java.util.Date
    +
    +import com.amazonaws.services.kinesis.clientlibrary.lib.worker.InitialPositionInStream
    +
    +/**
    + * Trait for Kinesis's InitialPositionInStream.
    + * This will be overridden by more specific types.
    + */
    +sealed trait InitialPosition {
    +  var initialPositionInStream: InitialPositionInStream
    +}
    +
    +/**
    + * Case object for Kinesis's InitialPositionInStream.LATEST.
    + */
    +case object Latest extends InitialPosition {
    +  def instance: InitialPosition = this
    +  override var initialPositionInStream: InitialPositionInStream
    +    = InitialPositionInStream.LATEST
    +}
    +
    +/**
    + * Case object for Kinesis's InitialPositionInStream.TRIM_HORIZON.
    + */
    +case object TrimHorizon extends InitialPosition {
    +  def instance: InitialPosition = this
    +  override var initialPositionInStream: InitialPositionInStream
    +    = InitialPositionInStream.TRIM_HORIZON
    +}
    +
    +/**
    + * Case object for Kinesis's InitialPositionInStream.AT_TIMESTAMP.
    + */
    +case class AtTimestamp(timestamp: Date) extends InitialPosition {
    +  def instance: InitialPosition = this
    +  override var initialPositionInStream: InitialPositionInStream
    +    = InitialPositionInStream.AT_TIMESTAMP
    +}
    +
    +/**
    + * Companion object for InitialPosition that returns
    + * appropriate version of InitialPositionInStream.
    + */
    +object InitialPosition {
    +
    +  /**
    +   * Returns instance of Latest with InitialPositionInStream.LATEST.
    +   * @return [[Latest]]
    +   */
    +  def latest() : InitialPosition = {
    +    Latest
    +  }
    +
    +  /**
    +   * Returns instance of Latest with InitialPositionInStream.TRIM_HORIZON.
    +   * @return [[TrimHorizon]]
    +   */
    +  def trimHorizon() : InitialPosition = {
    +    TrimHorizon
    +  }
    +
    +  /**
    +   * Returns instance of AtTimestamp with InitialPositionInStream.AT_TIMESTAMP.
    +   * @return [[AtTimestamp]]
    +   */
    +  def atTimestamp(timestamp: Date) : InitialPosition = {
    +    AtTimestamp(timestamp)
    +  }
    +
    +  /**
    +   * Returns instance of [[InitialPosition]] based on the passed [[InitialPositionInStream]].
    +   * @return [[InitialPosition]]
    +   */
    +  def kinesisInitialPositionInStream(
    --- End diff --
    
    Is this method really necessary? Especially if it can only be used for a subset of the
official ```InitialPositionInStream``` implementations?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message