Modern Apps git

← Modern-Apps.git

maps: keep PoiIndex.kt under the 800-line lint limit (#planet5)

Commit
32237d82d3aa3321bc5f879ac33d4a0b1c8d6ff8
Author
Vayun Mathur <[email protected]>
When
2026-11-14 04:24 UTC (22 days ago)
Parents
3a001b6
The block-POI reader change took PoiIndex.kt to 806 lines and the
fatal FileLength lint rule failed :maps:lintDev (the only finding;
all 1,062 maps unit tests passed in the same run). attrsFromBuffer is
now an expression body and the malformed-block-table log moves into a
small blockTableRefused helper shared with the null path: 799 lines,
same behaviour.

Verified: gbuild :maps:lint (rerun after the planet build frees the
heavy lock).

Diff

maps/src/main/java/com/vayunmathur/maps/util/PoiIndex.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/util/PoiIndex.kt b/maps/src/main/java/com/vayunmathur/maps/util/PoiIndex.ktindex eb2119681e..d866de5629 100644--- a/maps/src/main/java/com/vayunmathur/maps/util/PoiIndex.kt+++ b/maps/src/main/java/com/vayunmathur/maps/util/PoiIndex.kt@@ -466,19 +466,10 @@ object PoiIndex {         }     } -    /**-     * Buffer core of the attrs sidecar, reused by the single-archive path. A planet5 archive-     * stores it block-compressed ([PoiBlockSection]); [PoiBytes.of] reads either form.-     */-    internal fun attrsFromBuffer(buf: MappedByteBuffer, count: Int): Pair<PoiBytes, Int>? {-        return runCatching {-            val bytes = PoiBytes.of(buf) ?: run {-                Log.status(TAG, "$ATTRS_FILE block table is malformed; ignoring it")-                return null-            }-            readAttrs(bytes, count)-        }.getOrElse { bufferFailure(it, ATTRS_FILE) }-    }+    /** Buffer core of the attrs sidecar (raw, or planet5 block-compressed: [PoiBytes.of]). */+    internal fun attrsFromBuffer(buf: MappedByteBuffer, count: Int): Pair<PoiBytes, Int>? =+        runCatching { PoiBytes.of(buf)?.let { readAttrs(it, count) } ?: blockTableRefused(ATTRS_FILE) }+            .getOrElse { bufferFailure(it, ATTRS_FILE) }      private fun readAttrs(buf: PoiBytes, count: Int): Pair<PoiBytes, Int>? {         if (buf.size < ATTRS_HEADER_BYTES) {@@ -512,6 +503,9 @@ object PoiIndex {         return buf to blobStart     } +    /** Null, logged: a block-compressed section whose table did not validate (or a refused file). */+    internal fun <T> blockTableRefused(file: String): T? = null.also { Log.status(TAG, "$file refused") }+     /**      * Yield null (with a log line) for the failures a corrupt/truncated file      * can actually produce — buffer overruns and bounds checks. Anything else