Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-46325

Remove unnecessary override functions when constructing `WrappedCloseableIterator` in `ResponseValidator#wrapIterator`

    XMLWordPrintableJSON

Details

    Description

      Should reuse functions defined in WrappedCloseableIterator instead of overriding them

       
      ResponseValidator#wrapIterator
       

      def wrapIterator[T <: GeneratedMessageV3, V <: CloseableIterator[T]](
          inner: V): WrappedCloseableIterator[T] = {
        new WrappedCloseableIterator[T] {
      
          override def innerIterator: Iterator[T] = inner
      
          override def hasNext: Boolean = {
            innerIterator.hasNext
          }
      
          override def next(): T = {
            verifyResponse {
              innerIterator.next()
            }
          }
      
          override def close(): Unit = {
            innerIterator match {
              case it: CloseableIterator[T] => it.close()
              case _ => // nothing
            }
          }
        }
      } 

      WrappedCloseableIterator
       

      private[sql] abstract class WrappedCloseableIterator[E] extends CloseableIterator[E] {
      
        def innerIterator: Iterator[E]
      
        override def next(): E = innerIterator.next()
      
        override def hasNext: Boolean = innerIterator.hasNext
      
        override def close(): Unit = innerIterator match {
          case it: CloseableIterator[E] => it.close()
          case _ => // nothing
        }
      } 

      Attachments

        Issue Links

          Activity

            People

              LuciferYang Yang Jie
              LuciferYang Yang Jie
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: