implicit class AutoCloseableProducingArray[A] extends MapsSafely[A, Array[A]]
- Alphabetic
- By Inheritance
- AutoCloseableProducingArray
- MapsSafely
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @HotSpotIntrinsicCandidate()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- val in: Array[A]
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
safeMap[B <: AutoCloseable](fn: (A) ⇒ B)(implicit arg0: ClassTag[B]): Array[B]
safeMap: implicit map on a Seq[A] that produces Seq[B], where B is a subclass of AutoCloseable.
safeMap: implicit map on a Seq[A] that produces Seq[B], where B is a subclass of AutoCloseable. See MapsSafely.safeMap for a more detailed explanation.
- B
the type of the elements produced in the safeMap (should be subclasses of AutoCloseable)
- fn
a function that takes A, and produces B (a subclass of AutoCloseable)
- returns
a sequence of B, in the success case
-
def
safeMap[B <: AutoCloseable, That](in: SeqLike[A, Array[A]], fn: (A) ⇒ B)(implicit bf: CanBuildFrom[Array[A], B, That]): That
safeMap: safeMap implementation that is leveraged by other type-specific implicits.
safeMap: safeMap implementation that is leveraged by other type-specific implicits.
safeMap has the added safety net that as you produce AutoCloseable values they are tracked, and if an exception were to occur within the maps's body, it will make every attempt to close each produced value.
Note: safeMap will close in case of errors, without any knowledge of whether it should or not. Use safeMap only in these circumstances if
fnincreases the reference count, producing an AutoCloseable, and nothing else is tracking these references: a) seq.safeMap(x => {...; x.incRefCount; x}) b) seq.safeMap(x => GpuColumnVector.from(...))Usage of safeMap chained with other maps is a bit confusing:
seq.map(GpuColumnVector.from).safeMap(couldThrow)
Will close the column vectors produced from couldThrow up until the time where safeMap throws.
The correct pattern of usage in cases like this is:
val closeTheseLater = seq.safeMap(GpuColumnVector.from) closeTheseLater.safeMap{ x => var success = false try { val res = couldThrow(x.incRefCount()) success = true res // return a ref count of 2 } finally { if (!success) { // in case of an error, we close x as part of normal error handling // the exception will be caught by the safeMap, and it will close all // AutoCloseables produced before x // - Sequence looks like: [2, 2, 2, ..., 2] + x, which has also has a refcount of 2 x.close() // x now has a ref count of 1, the rest of the sequence has 2s } } } // safeMap cleaned, and now everything has 1s for ref counts (as they were before)
closeTheseLater.safeClose() // go from 1 to 0 in all things inside closeTheseLater
- B
the type of the elements produced in the safeMap (should be subclasses of AutoCloseable)
- That
the type of the output collection (needed by builder)
- in
the Seq[A] to map on
- fn
a function that takes A, and produces B (a subclass of AutoCloseable)
- returns
a sequence of B, in the success case
- Attributes
- protected
- Definition Classes
- MapsSafely
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )