Skip to content

Commit

Permalink
.toIterator => .iterator change
Browse files Browse the repository at this point in the history
  • Loading branch information
pomadchin committed Apr 30, 2021
1 parent 0f60e97 commit 90e9007
Show file tree
Hide file tree
Showing 23 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ object AccumuloCollectionReader {
val codec = KeyValueRecordCodec[K, V]
val includeKey = (key: K) => queryKeyBounds.includeKey(key)

val ranges = queryKeyBounds.flatMap(decomposeBounds).toIterator
val ranges = queryKeyBounds.flatMap(decomposeBounds).iterator

implicit val ec = executionContext
implicit val cs = IO.contextShift(ec)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ object CassandraCollectionReader {
instance.withSessionDo { session =>
val statement = session.prepare(query)

IOUtils.parJoin[K, V](ranges.toIterator){ index: BigInt =>
IOUtils.parJoin[K, V](ranges.iterator){ index: BigInt =>
val row = session.execute(statement.bind(index: BigInteger))
if (row.asScala.nonEmpty) {
val bytes = row.one().getBytes("value").array()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,23 +246,23 @@ class GDALRasterSourceRDDSpec extends AnyFunSpec with TestEnvironment with Befor
// println(Thread.currentThread().getName())
// Thread.sleep((Math.random() * 100).toLong)
val lts = reprojRS(i)
lts.readAll(lts.keys.take(10).toIterator)
lts.readAll(lts.keys.take(10).iterator)
reprojRS(i).source.resolutions

dirtyCalls(reprojRS(i).source)
}, IO {
// println(Thread.currentThread().getName())
// Thread.sleep((Math.random() * 100).toLong)
val lts = reprojRS(i)
lts.readAll(lts.keys.take(10).toIterator)
lts.readAll(lts.keys.take(10).iterator)
reprojRS(i).source.resolutions

dirtyCalls(reprojRS(i).source)
}, IO {
// println(Thread.currentThread().getName())
// Thread.sleep((Math.random() * 100).toLong)
val lts = reprojRS(i)
lts.readAll(lts.keys.take(10).toIterator)
lts.readAll(lts.keys.take(10).iterator)
reprojRS(i).source.resolutions

dirtyCalls(reprojRS(i).source)
Expand Down
4 changes: 2 additions & 2 deletions layer/src/main/scala/geotrellis/layer/LayoutTileSource.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class LayoutTileSource[K: SpatialComponent](

/** Read all available tiles */
def readAll(): Iterator[(K, MultibandTile)] =
readAll(keys.toIterator)
readAll(keys.iterator)

/** Set of keys that can be read from this tile source */
def keys: Set[K] = {
Expand Down Expand Up @@ -174,7 +174,7 @@ class LayoutTileSource[K: SpatialComponent](
/** All intersecting RasterRegions with their respective keys */
def keyedRasterRegions(): Iterator[(K, RasterRegion)] =
keys
.toIterator
.iterator
.flatMap { key =>
val result = rasterRegionForKey(key)
result.map { region => (key, region) }
Expand Down
8 changes: 4 additions & 4 deletions raster/src/main/scala/geotrellis/raster/RasterSource.scala
Original file line number Diff line number Diff line change
Expand Up @@ -143,24 +143,24 @@ abstract class RasterSource extends CellGrid[Long] with RasterMetadata {
* @group read
*/
def readExtents(extents: Traversable[Extent], bands: Seq[Int]): Iterator[Raster[MultibandTile]] =
extents.toIterator.flatMap(read(_, bands).toIterator)
extents.toIterator.flatMap(read(_, bands).iterator)

/**
* @group read
*/
def readExtents(extents: Traversable[Extent]): Iterator[Raster[MultibandTile]] =
readExtents(extents, (0 until bandCount))
readExtents(extents, 0 until bandCount)
/**
* @group read
*/
def readBounds(bounds: Traversable[GridBounds[Long]], bands: Seq[Int]): Iterator[Raster[MultibandTile]] =
bounds.toIterator.flatMap(read(_, bands).toIterator)
bounds.toIterator.flatMap(read(_, bands).iterator)

/**
* @group read
*/
def readBounds(bounds: Traversable[GridBounds[Long]]): Iterator[Raster[MultibandTile]] =
bounds.toIterator.flatMap(read(_, (0 until bandCount)).toIterator)
bounds.toIterator.flatMap(read(_, 0 until bandCount).iterator)

private[raster] def targetCellType: Option[TargetCellType]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ trait CropMethods[T] extends MethodExtensions[T] {
* Crop out multiple [[GridBounds]] windows.
*/
def crop(windows: Seq[GridBounds[Int]]): Iterator[(GridBounds[Int], T)] = {
windows.toIterator.map { gb => (gb, crop(gb))}
windows.iterator.map { gb => (gb, crop(gb))}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class LazySegmentBytes(
def getSegments(indices: Traversable[Int]): Iterator[(Int, Array[Byte])] = {
val chunks = chunkSegments(indices)
chunks
.toIterator
.iterator
.flatMap(chunk => readChunk(chunk))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ case class MultibandGeoTiff(
val storageMethod = Tiled(blockSize, blockSize)
val overviewOptions = options.copy(subfileType = Some(ReducedImage), storageMethod = storageMethod)
val overviewTile = GeoTiffBuilder[MultibandTile].makeTile(
segments.toIterator, segmentLayout, cellType, options.compression
segments.iterator, segmentLayout, cellType, options.compression
)

MultibandGeoTiff(overviewTile, extent, crs, Tags.empty, overviewOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ case class SinglebandGeoTiff(
val storageMethod = Tiled(blockSize, blockSize)
val overviewOptions = options.copy(subfileType = Some(ReducedImage), storageMethod = storageMethod)
val overviewTile = GeoTiffBuilder[Tile].makeTile(
segments.toIterator, segmentLayout, cellType, options.compression
segments.iterator, segmentLayout, cellType, options.compression
)

SinglebandGeoTiff(overviewTile, extent, crs, Tags.empty, overviewOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class GeoTiffWriter(geoTiff: GeoTiffData, dos: DataOutputStream) {
def writeDouble(value: Double): Unit = { writeBytes(toBytes(value)) }

private def append(list: List[GeoTiffData]): Unit = {
val overviewsIter = (geoTiff +: geoTiff.overviews).toIterator
val overviewsIter = (geoTiff +: geoTiff.overviews).iterator
overviewsIter.foreach(append(_, !overviewsIter.hasNext))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class GeoTiffBuilderSpec extends AnyFunSpec with RasterMatchers with GeoTiffTest
BandInterleave,
BandType.forCellType(ct))

val tiff = GeoTiffBuilder[MultibandTile].makeTile(segments.toIterator, segmentLayout, ct, NoCompression)
val tiff = GeoTiffBuilder[MultibandTile].makeTile(segments.iterator, segmentLayout, ct, NoCompression)
val actualTile = tiff.tile.toArrayTile()

assertEqual(expectedTile, actualTile)
Expand All @@ -66,7 +66,7 @@ class GeoTiffBuilderSpec extends AnyFunSpec with RasterMatchers with GeoTiffTest
PixelInterleave,
BandType.forCellType(ct))

val tiff = GeoTiffBuilder[MultibandTile].makeTile(segments.toIterator, segmentLayout, ct, NoCompression)
val tiff = GeoTiffBuilder[MultibandTile].makeTile(segments.iterator, segmentLayout, ct, NoCompression)
val actualTile = tiff.tile.toArrayTile()

assertEqual(expectedTile, actualTile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class S3RDDReader(
val s3Client = this.s3Client
val writerSchema = kwWriterSchema.value.getOrElse(_recordCodec.schema)
partition flatMap { seq =>
GTIOUtils.parJoinEBO[K, V](seq.toIterator)({ index: BigInt =>
GTIOUtils.parJoinEBO[K, V](seq.iterator)({ index: BigInt =>
try {
val request = GetObjectRequest.builder()
.bucket(bucket)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class S3CollectionReader(
val recordCodec = KeyValueRecordCodec[K, V]
implicit val ec = executionContext

GTIOUtils.parJoin[K, V](ranges.toIterator){ index: BigInt =>
GTIOUtils.parJoin[K, V](ranges.iterator){ index: BigInt =>
try {
val getRequest = GetObjectRequest.builder()
.bucket(bucket)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ object RasterSourceRDD {
val m = keyExtractor.getMetadata(source)
val tileKeyTransform: SpatialKey => K = { sk => keyExtractor.getKey(m, sk) }
val tileSource = source.tileToLayout(layout, tileKeyTransform, NearestNeighbor, strategy)
tileSource.readAll(keys.map(tileKeyTransform).toIterator)
tileSource.readAll(keys.map(tileKeyTransform).iterator)
}

sourcesRDD.unpersist()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ object RasterizeRDD {
// key the geometry to intersecting tiles so it can be rasterized in the map-side combine
val keyed: RDD[(SpatialKey, (Feature[Geometry, Double], SpatialKey))] =
features.flatMap { feature =>
layout.mapTransform.keysForGeometry(feature.geom).toIterator
layout.mapTransform.keysForGeometry(feature.geom).iterator
.map(key => (key, (feature, key)) )
}

Expand Down Expand Up @@ -192,7 +192,7 @@ object RasterizeRDD {
// key the geometry to intersecting tiles so it can be rasterized in the map-side combine
val keyed: RDD[(SpatialKey, (Feature[Geometry, CellValue], SpatialKey))] =
features.flatMap { feature =>
layout.mapTransform.keysForGeometry(feature.geom).toIterator
layout.mapTransform.keysForGeometry(feature.geom).iterator
.map(key => (key, (feature, key)) )
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ abstract class COGLayerReader[ID] extends Serializable {
val keyDecoder = kwDecoder.value

partition flatMap { seq =>
IOUtils.parJoin[K, R](seq.toIterator) { index: BigInt =>
IOUtils.parJoin[K, R](seq.iterator) { index: BigInt =>
if (!pathExists(keyPath(index))) Vector()
else {
val uri = fullPath(keyPath(index))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ object FileRDDReader {
implicit val ec: ExecutionContext = executionContext

partition flatMap { seq =>
IOUtils.parJoin[K, V](seq.toIterator) { index: BigInt =>
IOUtils.parJoin[K, V](seq.iterator) { index: BigInt =>
val path = keyPath(index)
if (new File(path).exists) {
val bytes: Array[Byte] = Filesystem.slurp(path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ object HadoopRDDWriter {

// Write merged records
val writer = new MultiMapWriter(layerPathStr, 33, blockSize, indexInterval)
for ( (index, pairs) <- GroupConsecutiveIterator(kvs.toIterator)(r => keyIndex.toIndex(r._1))) {
for ( (index, pairs) <- GroupConsecutiveIterator(kvs.iterator)(r => keyIndex.toIndex(r._1))) {
writer.write(
new BigIntWritable(index.toByteArray),
new BytesWritable(AvroEncoder.toBinary(pairs.toVector)(codec)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class RasterRegionSpec extends AnyFunSpec with TestEnvironment with RasterMatche
val refRdd = srcRdd.flatMap { src =>
// too easy? whats missing
val tileSource = LayoutTileSource.spatial(src, layout)
tileSource.keys.toIterator.map { key => (key, tileSource.rasterRegionForKey(key).get) }
tileSource.keys.iterator.map { key => (key, tileSource.rasterRegionForKey(key).get) }
}

// TADA! Jobs done.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ object COGCollectionLayerReader {
else
baseQueryKeyBounds.flatMap(decomposeBounds)

IOUtils.parJoin[K, V](ranges.toIterator) { index: BigInt =>
IOUtils.parJoin[K, V](ranges.iterator) { index: BigInt =>
if (!pathExists(keyPath(index))) Vector()
else {
val uri = fullPath(keyPath(index))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ object FileCollectionReader {
val includeKey = (key: K) => KeyBounds.includeKey(queryKeyBounds, key)(boundable)
val _recordCodec = KeyValueRecordCodec[K, V]

IOUtils.parJoin[K, V](ranges.toIterator) { index: BigInt =>
IOUtils.parJoin[K, V](ranges.iterator) { index: BigInt =>
val path = keyPath(index)
if (new File(path).exists) {
val bytes: Array[Byte] = Filesystem.slurp(path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class HadoopCollectionReader(
if (queryKeyBounds.isEmpty) return Seq.empty[(K, V)]

val includeKey = (key: K) => KeyBounds.includeKey(queryKeyBounds, key)
val indexRanges = queryKeyBounds.flatMap(decomposeBounds).toIterator
val indexRanges = queryKeyBounds.flatMap(decomposeBounds).iterator

val codec = KeyValueRecordCodec[K, V]

Expand Down
2 changes: 1 addition & 1 deletion store/src/main/scala/geotrellis/store/util/IOUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ object IOUtils {
implicit val cs = IO.contextShift(ec)

val indices: Iterator[BigInt] = ranges.flatMap { case (start, end) =>
(start to end).toIterator
(start to end).iterator
}

val index: fs2.Stream[IO, BigInt] = fs2.Stream.fromIterator[IO](indices)
Expand Down

0 comments on commit 90e9007

Please sign in to comment.