You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@graphar.apache.org by "keksmd (via GitHub)" <gi...@apache.org> on 2026/08/24 14:21:53 UTC

[PR] feat(java): add chunk and edge-range primitives [incubator-graphar]

keksmd opened a new pull request, #968:
URL: https://github.com/apache/incubator-graphar/pull/968

   ### Reason for this PR
   
   Implements the first, value-only slice of #967 (and relates to #947/#944): common long-safe GraphAr chunk and half-open edge-range arithmetic.
   
   ### What changes are included in this PR?
   
   - Adds the dependency-free `graphar-core` Maven module.
   - Adds `ChunkMath`, `ChunkRange`, and `EdgeRange` with explicit non-negative, positive-size, and monotonic-offset invariants.
   - Covers empty ranges and the end-exclusive cross-chunk boundary: `[1008, 1061)` at chunk size `1024` intersects chunks `[0, 2)`.
   
   This intentionally does not resolve `EdgeInfo` URIs, read offset files, or add Parquet/storage dependencies; those belong in the following metadata/reader slice.
   
   ### Are these changes tested?
   
   Yes.
   
   ```shell
   mvn --no-transfer-progress -f maven-projects/pom.xml -pl core -am clean verify -Dspotless.check.skip=true
   mvn --no-transfer-progress -f maven-projects/pom.xml -pl core -am spotless:check
   ```
   
   The focused reactor passes 6 tests. `pre-commit run --files ...` and `git diff --check` also pass.
   
   ### Are there any user-facing changes?
   
   Yes. Java consumers can now use the new `graphar-core` value types; there is no reader or storage behavior change yet.
   
   ## Checklist
   
   - [x] I have self-reviewed this PR
   - [ ] I have run `make cpplint` (if this PR contains C++ changes)
   - [x] I have run `pre-commit`
   - [x] I have run the relevant tests


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org
For additional commands, e-mail: commits-help@graphar.apache.org


Re: [PR] feat(java): add chunk and edge-range primitives [incubator-graphar]

Posted by "SemyonSinchenko (via GitHub)" <gi...@apache.org>.
SemyonSinchenko commented on PR #968:
URL: https://github.com/apache/incubator-graphar/pull/968#issuecomment-5598835413

   I left a few minor comments. ~LGTM overall


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org
For additional commands, e-mail: commits-help@graphar.apache.org


Re: [PR] feat(java): add chunk and edge-range primitives [incubator-graphar]

Posted by "keksmd (via GitHub)" <gi...@apache.org>.
keksmd commented on PR #968:
URL: https://github.com/apache/incubator-graphar/pull/968#issuecomment-5566662645

   @SemyonSinchenko @SYaoJun could you take a look when you have a moment? This one is rebased on current `main`, conflicts are resolved and CI is green.
   
   Note that the `test` job only builds `-pl storage-api -am`, so `graphar-core` is not exercised upstream yet. Locally the module is green: `OrderedAdjacencyResolverFixtureTest` 2/0/0 and `ChunkRangeTest` 6/0/0 from `core/target/surefire-reports`. The fixture test resolves the canonical data through `GAR_TEST_DATA` (then `gar.test.data`, then the usual relative fallbacks) and skips cleanly when the testing repository is absent, matching the convention in `graphar-info`.
   
   I can follow up with a separate PR widening `SDK_MODULES` so the newer SDK modules are actually compiled and tested in CI, if that sounds right to you.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org
For additional commands, e-mail: commits-help@graphar.apache.org


Re: [PR] feat(java): add chunk and edge-range primitives [incubator-graphar]

Posted by "keksmd (via GitHub)" <gi...@apache.org>.
keksmd commented on code in PR #968:
URL: https://github.com/apache/incubator-graphar/pull/968#discussion_r3966509368


##########
maven-projects/core/src/main/java/org/apache/graphar/core/EdgeRange.java:
##########
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.graphar.core;
+
+/** A validated half-open range of edge rows within one GraphAr vertex partition. */
+public final class EdgeRange {
+    private final long begin;
+    private final long end;
+
+    private EdgeRange(long begin, long end) {
+        this.begin = begin;
+        this.end = end;
+    }
+
+    /**
+     * Creates an edge range from the two adjacent values of an ordered offset table.
+     *
+     * @param begin the first included edge row
+     * @param end the first excluded edge row
+     * @return the validated half-open edge range
+     */
+    public static EdgeRange fromOffsets(long begin, long end) {
+        if (begin < 0) {
+            throw new IllegalArgumentException("Edge range begin must be non-negative: " + begin);
+        }
+        if (end < begin) {
+            throw new IllegalArgumentException(
+                    "Offset values must be monotonic: begin=" + begin + ", end=" + end);
+        }
+        return new EdgeRange(begin, end);
+    }
+
+    /**
+     * Returns the first included edge row.
+     *
+     * @return the first included edge row
+     */
+    public long begin() {
+        return begin;
+    }
+
+    /**
+     * Returns the first excluded edge row.
+     *
+     * @return the first excluded edge row
+     */
+    public long end() {
+        return end;
+    }
+
+    /**
+     * Returns the number of selected edge rows.
+     *
+     * @return the number of selected edge rows
+     */
+    public long length() {
+        return end - begin;
+    }
+
+    /**
+     * Returns whether this range selects no edge rows.
+     *
+     * @return whether the range is empty
+     */
+    public boolean isEmpty() {
+        return begin == end;
+    }
+
+    /**
+     * Returns the half-open range of edge chunks intersecting this edge range.
+     *
+     * @param edgeChunkSize a positive number of edge rows per chunk
+     * @return the chunk range intersecting this edge range
+     */
+    public ChunkRange edgeChunks(long edgeChunkSize) {
+        ChunkMath.validateChunkSize(edgeChunkSize);

Review Comment:
   Done in 2412d03 — `EdgeRange.edgeChunks` now calls `ChunkMath.chunkIndex(begin, size)` and `ChunkMath.chunkCount(end, size)` instead of repeating the division, so the arithmetic (and its validation) lives in one place.



##########
maven-projects/core/src/main/java/org/apache/graphar/core/ChunkRange.java:
##########


Review Comment:
   Added in 2412d03: `equals`/`hashCode`/`toString` on `ChunkRange`, `EdgeRange` and `OffsetLocation`. The fixture test now asserts whole values (`assertEquals(new ChunkRange(0, 2), resolved.edgeChunks())`) instead of begin/end field by field. `ResolvedAdjacency` got `toString` only — it holds an `EdgeInfo`, which has no value equality, so equals there would not be well defined.



##########
maven-projects/core/src/main/java/org/apache/graphar/core/OrderedAdjacencyResolver.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.graphar.core;
+
+import java.net.URI;
+import java.util.Objects;
+import org.apache.graphar.info.EdgeInfo;
+import org.apache.graphar.info.type.AdjListType;
+
+/** Resolves GraphAr ordered adjacency metadata into offset and edge-chunk locations. */
+public final class OrderedAdjacencyResolver {
+    private final EdgeInfo edgeInfo;
+    private final AdjListType adjListType;
+    private final long vertexChunkSize;
+
+    public OrderedAdjacencyResolver(EdgeInfo edgeInfo, AdjListType adjListType) {
+        this.edgeInfo = Objects.requireNonNull(edgeInfo, "Edge info cannot be null.");
+        this.adjListType =
+                Objects.requireNonNull(adjListType, "Adjacency list type cannot be null.");
+        if (!adjListType.isOrdered()) {
+            throw new IllegalArgumentException(
+                    "An ordered adjacency resolver requires an ordered layout: " + adjListType);
+        }
+        if (!edgeInfo.hasAdjListType(adjListType)) {
+            throw new IllegalArgumentException(
+                    "Edge info does not declare adjacency layout: " + adjListType);
+        }
+        this.vertexChunkSize =
+                adjListType == AdjListType.ordered_by_source
+                        ? edgeInfo.getSrcChunkSize()
+                        : edgeInfo.getDstChunkSize();
+        ChunkMath.validateChunkSize(vertexChunkSize);
+        ChunkMath.validateChunkSize(edgeInfo.getChunkSize());
+    }
+
+    /** Locates the offset pair that the physical reader must fetch for {@code vertexId}. */
+    public OffsetLocation locate(long vertexId) {
+        long vertexChunkIndex = ChunkMath.chunkIndex(vertexId, vertexChunkSize);
+        long offsetIndex = ChunkMath.offsetInChunk(vertexId, vertexChunkSize);
+        URI offsetChunkUri = edgeInfo.getOffsetChunkUri(adjListType, vertexChunkIndex);
+        return new OffsetLocation(vertexId, vertexChunkIndex, offsetIndex, offsetChunkUri);
+    }
+
+    /** Combines a vertex location and its two ordered-offset values into exact edge chunks. */
+    public ResolvedAdjacency resolve(long vertexId, long offsetBegin, long offsetEnd) {
+        OffsetLocation offsetLocation = locate(vertexId);
+        EdgeRange edgeRange = EdgeRange.fromOffsets(offsetBegin, offsetEnd);
+        return resolved(offsetLocation, edgeRange);
+    }
+
+    /** Resolves a vertex using a complete, validated offset chunk read by a physical backend. */
+    public ResolvedAdjacency resolve(long vertexId, OffsetChunk offsetChunk) {
+        OffsetLocation offsetLocation = locate(vertexId);
+        Objects.requireNonNull(offsetChunk, "Offset chunk cannot be null.");

Review Comment:
   Fixed in 2412d03, and the null check was only half the problem. `OffsetChunk.of` now takes the vertex chunk index it was read from and exposes `vertexChunkIndex()`; `resolve(vertexId, offsetChunk)` does `requireNonNull` first, then rejects a chunk whose index does not match the located vertex chunk. Before this, passing an offset chunk from another vertex chunk returned a plausible but wrong edge range instead of failing. New test `rejectsAnOffsetChunkReadFromAnotherVertexChunk` pins it. The API is unreleased, so I changed the factory rather than adding an overload.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org
For additional commands, e-mail: commits-help@graphar.apache.org


Re: [PR] feat(java): add chunk and edge-range primitives [incubator-graphar]

Posted by "SYaoJun (via GitHub)" <gi...@apache.org>.
SYaoJun merged PR #968:
URL: https://github.com/apache/incubator-graphar/pull/968


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org
For additional commands, e-mail: commits-help@graphar.apache.org


Re: [PR] feat(java): add chunk and edge-range primitives [incubator-graphar]

Posted by "keksmd (via GitHub)" <gi...@apache.org>.
keksmd commented on PR #968:
URL: https://github.com/apache/incubator-graphar/pull/968#issuecomment-5573363514

   Update on the CI gap I mentioned above: the fix landed in #966 rather than as a separate PR, since @SYaoJun raised the same point there. The workflow now builds `storage-api,storage-local,io-api,storage-s3`.
   
   `core` is deliberately not in that list yet — it only exists once this PR merges. I will add it here, or in a follow-up, whichever you prefer.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org
For additional commands, e-mail: commits-help@graphar.apache.org


Re: [PR] feat(java): add chunk and edge-range primitives [incubator-graphar]

Posted by "keksmd (via GitHub)" <gi...@apache.org>.
keksmd commented on PR #968:
URL: https://github.com/apache/incubator-graphar/pull/968#issuecomment-5584287605

   Rebased on `main` after #966 merged — the only conflict was the module list in `maven-projects/pom.xml`, where `storage-s3` and `core` were added at the same line; both are kept.
   
   I also pushed the answer to the CI question I raised earlier, rather than leaving it open: the workflow already watches `maven-projects/core/**` in its path filters, so a change here triggers the job, but `SDK_MODULES` left `core` out and the reactor never compiled or tested it — a green run proved nothing about this module. `SDK_MODULES` is now `storage-api,storage-local,io-api,storage-s3,core`. The fixture-backed test skips itself when the canonical `testing` dataset is absent, so the job stays green without the submodule and gains real coverage when it is present.
   
   Local verification against `main` with the fixtures available:
   
   ```
   ChunkRangeTest                        Tests run: 6, Failures: 0, Errors: 0, Skipped: 0
   OrderedAdjacencyResolverFixtureTest   Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
   BUILD SUCCESS
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org
For additional commands, e-mail: commits-help@graphar.apache.org


Re: [PR] feat(java): add chunk and edge-range primitives [incubator-graphar]

Posted by "keksmd (via GitHub)" <gi...@apache.org>.
keksmd commented on PR #968:
URL: https://github.com/apache/incubator-graphar/pull/968#issuecomment-5396701134

   Updated this PR into the complete ordered-adjacency core vertical (now 848 additions): validated offset chunks, metadata URI resolution, and the canonical LDBC cross-chunk fixture. It remains independent of #961 by keeping Parquet reads out of core.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org
For additional commands, e-mail: commits-help@graphar.apache.org


Re: [PR] feat(java): add chunk and edge-range primitives [incubator-graphar]

Posted by "keksmd (via GitHub)" <gi...@apache.org>.
keksmd commented on PR #968:
URL: https://github.com/apache/incubator-graphar/pull/968#issuecomment-5501011823

   cc @SemyonSinchenko @SYaoJun — green CI, would appreciate a look when you have time.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org
For additional commands, e-mail: commits-help@graphar.apache.org


Re: [PR] feat(java): add chunk and edge-range primitives [incubator-graphar]

Posted by "keksmd (via GitHub)" <gi...@apache.org>.
keksmd commented on PR #968:
URL: https://github.com/apache/incubator-graphar/pull/968#issuecomment-5396572461

   Hi @SemyonSinchenko — this is a deliberately small, independent Java core slice (419 lines, 6 focused tests) after #960/#962. It provides only the long-safe half-open chunk/range value layer; metadata URI resolution and IO stay out of this PR. I would appreciate your review when convenient.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org
For additional commands, e-mail: commits-help@graphar.apache.org


Re: [PR] feat(java): add chunk and edge-range primitives [incubator-graphar]

Posted by "SemyonSinchenko (via GitHub)" <gi...@apache.org>.
SemyonSinchenko commented on code in PR #968:
URL: https://github.com/apache/incubator-graphar/pull/968#discussion_r3966260408


##########
maven-projects/core/src/main/java/org/apache/graphar/core/ChunkRange.java:
##########


Review Comment:
   This composite value type (like ChunkRange, EdgeRange, and OffsetLocation) lacks equals/hashCode/toString. Without them, callers cannot assert whole results in tests (current tests must compare field by field), use results in collections, or log a diagnostic summary of a resolved adjacency. Consider implementing equals/hashCode over the final fields and a toString that summarizes the vertex chunk, edge range, and chunk range.



##########
maven-projects/core/src/main/java/org/apache/graphar/core/EdgeRange.java:
##########
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.graphar.core;
+
+/** A validated half-open range of edge rows within one GraphAr vertex partition. */
+public final class EdgeRange {
+    private final long begin;
+    private final long end;
+
+    private EdgeRange(long begin, long end) {
+        this.begin = begin;
+        this.end = end;
+    }
+
+    /**
+     * Creates an edge range from the two adjacent values of an ordered offset table.
+     *
+     * @param begin the first included edge row
+     * @param end the first excluded edge row
+     * @return the validated half-open edge range
+     */
+    public static EdgeRange fromOffsets(long begin, long end) {
+        if (begin < 0) {
+            throw new IllegalArgumentException("Edge range begin must be non-negative: " + begin);
+        }
+        if (end < begin) {
+            throw new IllegalArgumentException(
+                    "Offset values must be monotonic: begin=" + begin + ", end=" + end);
+        }
+        return new EdgeRange(begin, end);
+    }
+
+    /**
+     * Returns the first included edge row.
+     *
+     * @return the first included edge row
+     */
+    public long begin() {
+        return begin;
+    }
+
+    /**
+     * Returns the first excluded edge row.
+     *
+     * @return the first excluded edge row
+     */
+    public long end() {
+        return end;
+    }
+
+    /**
+     * Returns the number of selected edge rows.
+     *
+     * @return the number of selected edge rows
+     */
+    public long length() {
+        return end - begin;
+    }
+
+    /**
+     * Returns whether this range selects no edge rows.
+     *
+     * @return whether the range is empty
+     */
+    public boolean isEmpty() {
+        return begin == end;
+    }
+
+    /**
+     * Returns the half-open range of edge chunks intersecting this edge range.
+     *
+     * @param edgeChunkSize a positive number of edge rows per chunk
+     * @return the chunk range intersecting this edge range
+     */
+    public ChunkRange edgeChunks(long edgeChunkSize) {
+        ChunkMath.validateChunkSize(edgeChunkSize);

Review Comment:
   This method re-implements, inline, the same arithmetic that ChunkMath centralizes in this package: `begin / edgeChunkSize` is `ChunkMath.chunkIndex(begin, edgeChunkSize)` and `1 + (end - 1) / edgeChunkSize` is exactly `ChunkMath.chunkCount(end, edgeChunkSize)` (the existing tests assert both with identical inputs, e.g. 201/100 -> 3 and Long.MAX_VALUE/1 -> MAX_VALUE). Duplicating the long-safe formulas risks them drifting apart if the overflow-safe expressions in ChunkMath are ever revised. Delegate to ChunkMath so this package has a single home for chunk arithmetic.



##########
maven-projects/core/src/main/java/org/apache/graphar/core/OrderedAdjacencyResolver.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.graphar.core;
+
+import java.net.URI;
+import java.util.Objects;
+import org.apache.graphar.info.EdgeInfo;
+import org.apache.graphar.info.type.AdjListType;
+
+/** Resolves GraphAr ordered adjacency metadata into offset and edge-chunk locations. */
+public final class OrderedAdjacencyResolver {
+    private final EdgeInfo edgeInfo;
+    private final AdjListType adjListType;
+    private final long vertexChunkSize;
+
+    public OrderedAdjacencyResolver(EdgeInfo edgeInfo, AdjListType adjListType) {
+        this.edgeInfo = Objects.requireNonNull(edgeInfo, "Edge info cannot be null.");
+        this.adjListType =
+                Objects.requireNonNull(adjListType, "Adjacency list type cannot be null.");
+        if (!adjListType.isOrdered()) {
+            throw new IllegalArgumentException(
+                    "An ordered adjacency resolver requires an ordered layout: " + adjListType);
+        }
+        if (!edgeInfo.hasAdjListType(adjListType)) {
+            throw new IllegalArgumentException(
+                    "Edge info does not declare adjacency layout: " + adjListType);
+        }
+        this.vertexChunkSize =
+                adjListType == AdjListType.ordered_by_source
+                        ? edgeInfo.getSrcChunkSize()
+                        : edgeInfo.getDstChunkSize();
+        ChunkMath.validateChunkSize(vertexChunkSize);
+        ChunkMath.validateChunkSize(edgeInfo.getChunkSize());
+    }
+
+    /** Locates the offset pair that the physical reader must fetch for {@code vertexId}. */
+    public OffsetLocation locate(long vertexId) {
+        long vertexChunkIndex = ChunkMath.chunkIndex(vertexId, vertexChunkSize);
+        long offsetIndex = ChunkMath.offsetInChunk(vertexId, vertexChunkSize);
+        URI offsetChunkUri = edgeInfo.getOffsetChunkUri(adjListType, vertexChunkIndex);
+        return new OffsetLocation(vertexId, vertexChunkIndex, offsetIndex, offsetChunkUri);
+    }
+
+    /** Combines a vertex location and its two ordered-offset values into exact edge chunks. */
+    public ResolvedAdjacency resolve(long vertexId, long offsetBegin, long offsetEnd) {
+        OffsetLocation offsetLocation = locate(vertexId);
+        EdgeRange edgeRange = EdgeRange.fromOffsets(offsetBegin, offsetEnd);
+        return resolved(offsetLocation, edgeRange);
+    }
+
+    /** Resolves a vertex using a complete, validated offset chunk read by a physical backend. */
+    public ResolvedAdjacency resolve(long vertexId, OffsetChunk offsetChunk) {
+        OffsetLocation offsetLocation = locate(vertexId);
+        Objects.requireNonNull(offsetChunk, "Offset chunk cannot be null.");

Review Comment:
   Two robustness gaps in this overload: (1) `Objects.requireNonNull(offsetChunk)` runs after `locate(vertexId)`, so when both arguments are invalid the null-chunk error is masked by the vertexId error — validate arguments up front. (2) `OffsetChunk` carries no identity of the vertex chunk it was read from, so passing a chunk read via a different `locate()` call (e.g., a cached or stale chunk) is silently accepted and yields a plausible but wrong edge range. Consider recording the source vertex chunk index in `OffsetChunk` (factory like `of(long vertexChunkIndex, long[] offsets)`) and verifying it matches `offsetLocation.vertexChunkIndex()` here, turning silent misuse into a clear error.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@graphar.apache.org
For additional commands, e-mail: commits-help@graphar.apache.org