Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-45667][CORE][SQL][CONNECT] Clean up the deprecated API usage related to IterableOnceExtensionMethods. #43532

Closed
wants to merge 2 commits into from

Conversation

LuciferYang
Copy link
Contributor

@LuciferYang LuciferYang commented Oct 26, 2023

What changes were proposed in this pull request?

This PR cleans up the use of the following APIs in IterableOnceExtensionMethods, as they have been deprecated after Scala 2.13.0:

  • .toSeq -> .iterator.to(Seq)
  • .toIterable -> .iterator.to(Iterable)
  • .toTraversable -> .iterator.to(Iterable)
  • .toArray -> .iterator.toArray
  • .map -> .iterator.map
  • .foreach -> .iterator.foreach
  • .isEmpty -> .iterator.isEmpty
  @deprecated("Use .iterator.to(Seq) instead", "2.13.0")
  @`inline` def toSeq: immutable.Seq[A] = immutable.Seq.from(it)

  @deprecated("Use .iterator.to(Iterable) instead", "2.13.0")
  @`inline` final def toIterable: Iterable[A] = Iterable.from(it)

  @deprecated("Use .iterator.to(Iterable) instead", "2.13.0")
  @`inline` final def toTraversable: Traversable[A] = toIterable

  @deprecated("Use .iterator.toArray", "2.13.0")
  def toArray[B >: A: ClassTag]: Array[B] = it match {
    case it: Iterable[B] => it.toArray[B]
    case _ => it.iterator.toArray[B]
  }

  @deprecated("Use .iterator.map instead or consider requiring an Iterable", "2.13.0")
  def map[B](f: A => B): IterableOnce[B] = it match {
    case it: Iterable[A] => it.map(f)
    case _ => it.iterator.map(f)
  }

  @deprecated("Use .iterator.foreach(...) instead", "2.13.0")
  @`inline` def foreach[U](f: A => U): Unit = it match {
    case it: Iterable[A] => it.foreach(f)
    case _ => it.iterator.foreach(f)
  }

  @deprecated("Use .iterator.isEmpty instead", "2.13.0")
  def isEmpty: Boolean = it match {
    case it: Iterable[A] => it.isEmpty
    case _ => it.iterator.isEmpty
  }

Why are the changes needed?

Clean up deprecated API usage.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Pass GitHub Acitons.

Was this patch authored or co-authored using generative AI tooling?

No

Copy link
Contributor

@beliefer beliefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM. Are these all occurrences?

@LuciferYang
Copy link
Contributor Author

Yes, all the cases related to IterableOnceExtensionMethods are here.

@LuciferYang
Copy link
Contributor Author

Merged into master for Spark 4.0. Thanks @dongjoon-hyun @beliefer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants