Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates two Scala scripts that handle packing operations for region data, improving their robustness and consistency. The changes enhance error reporting, refactor bounds handling, and add support for custom bounds specifications.
Changes:
- Added line number tracking to CSV parsing for better error diagnostics
- Introduced support for 9-parameter region format with custom X/Z bounds
- Refactored bounds representation from single size values to 6-tuple (minX, maxX, minY, maxY, minZ, maxZ) for more precise control
- Added error logging for invalid CSV lines
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| scripts/rtree-packing.scala.sc | Updated regionsFromFile function to add zipWithIndex for line tracking, introduced bounds variable for clarity, added new 9-parameter case for custom X/Z bounds, and added error logging for invalid lines |
| scripts/outlier-packing.scala.sc | Updated regionsFromFile function with same improvements as rtree-packing.scala.sc, plus fixed destructuring bug in the BoundingBox creation to properly handle the new 6-tuple bounds format |
Comments suppressed due to low confidence (2)
scripts/rtree-packing.scala.sc:445
- Empty lines from the CSV file will trigger the error message "Invalid line at index". Consider filtering out empty lines before processing to avoid noisy output. You can add
.filter(_.nonEmpty)afterzipWithIndexor before processing the lines.
val dataPoints = lines.zipWithIndex
.flatMap { case (line, index) =>
line.split(",").map(_.trim) match {
case Array(id, dim, x, y, z) =>
val s = defaultSize.get
val bounds = (s, s, s, s, s, s)
Some(dim -> (id.toInt -> (Int3(x.toInt, y.toInt, z.toInt), bounds)))
case Array(id, dim, x, y, z, size) =>
val s = Math.max(size.toInt, 32)
val bounds = (s, s, s, s, s, s)
Some(dim -> (id.toInt -> (Int3(x.toInt, y.toInt, z.toInt), bounds)))
case Array(id, dim, x, y, z, minX, maxX, minZ, maxZ) =>
val s = defaultSize.get
val bounds = (s + minX.toInt, s + maxX.toInt, s, s, s + minZ.toInt, s + maxZ.toInt)
Some(dim -> (id.toInt -> (Int3(x.toInt, y.toInt, z.toInt), bounds)))
case _ =>
println(s"Invalid line at index $index: $line")
None
scripts/outlier-packing.scala.sc:267
- Empty lines from the CSV file will trigger the error message "Invalid line at index". Consider filtering out empty lines before processing to avoid noisy output. You can add
.filter(_.nonEmpty)afterzipWithIndexor before processing the lines.
val dataPoints = lines.zipWithIndex
.flatMap {
case (line, index) => line.split(",").map(_.trim) match {
case Array(id, dim, x, y, z) =>
val s = defaultSize.get
val bounds = (s, s, s, s, s, s)
Some(dim -> (id.toInt -> (Int3(x.toInt, y.toInt, z.toInt), bounds)))
case Array(id, dim, x, y, z, size) =>
val s = Math.max(size.toInt, 32)
val bounds = (s, s, s, s, s, s)
Some(dim -> (id.toInt -> (Int3(x.toInt, y.toInt, z.toInt), bounds)))
case Array(id, dim, x, y, z, minX, maxX, minZ, maxZ) =>
val s = defaultSize.get
val bounds = (s + minX.toInt, s + maxX.toInt, s, s, s + minZ.toInt, s + maxZ.toInt)
Some(dim -> (id.toInt -> (Int3(x.toInt, y.toInt, z.toInt), bounds)))
case _ =>
println(s"Invalid line at index $index: $line")
None
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
haiiro2gou
approved these changes
Feb 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.