gouthamaenugu opened a new pull request, #8155:
URL: https://github.com/apache/geode/pull/8155

   # PR 3: `gfsh` Vector Index Commands, Cluster Configuration XML Persistence, 
and Vector Metrics
   
   > **Dependency Note:** Stacked on **PR 1 (#8154, 
`gouthamaenugu:feature/GEODE-vector-pr1-knn-field`)**. Because upstream 
`apache/geode` does not host feature branches, this Draft PR targets 
`apache:develop` and therefore includes PR 1's commits until #8154 lands. 
Review the PR 3 delta (`8b51aa312a..5a23353669`, `27 files changed, +2149 / 
-68`); merge after #8154.
   
   - **Branch:** `gouthamaenugu:feature/GEODE-vector-pr3-gfsh-cli`
   - **Base / Stack Dependency:** Stacked on PR 1 (#8154, 
`feature/GEODE-vector-pr1-knn-field` @ `8b51aa312a`); GitHub PR base set to 
`apache:develop` (`46643af515`)
   - **Head Commit:** `5a233536693e5199adb529d0e9eb71d77e2f512f` (`27 files 
changed, +2149 / -68` vs PR 1 #8154)
   - **Modules:** `geode-lucene` (verified alongside `:geode-gfsh:test`)
   
   ---
   
   ### For all changes, please confirm:
   - [ ] Is there a JIRA ticket associated with this PR? Is it referenced in 
the commit message? *(Draft PR ready for upstream `GEODE-*` JIRA ticket 
assignment and commit prefix update.)*
   - [x] Has your PR been rebased against the latest commit within the target 
branch (typically `develop`)? *(Cleanly rebased on PR 1 #8154 `8b51aa312a`, 
which is based on `develop` `46643af515`.)*
   - [ ] Is your initial contribution a single, squashed commit? *(2 PR 3 
commits atop PR 1 #8154 — feature implementation + review hardening — ready to 
squash once #8154 merges.)*
   - [x] Does `gradlew build` run cleanly? *(Verified 
`:geode-lucene:spotlessCheck`, `:geode-gfsh:spotlessCheck`, 
`:geode-lucene:checkPom`, `:geode-lucene:javadoc`, `:geode-lucene:test 
--rerun`, `:geode-gfsh:test`, `:geode-lucene:distributedTest`, and 
`AnalyzeLuceneSerializablesIntegrationTest.testSerializables`.)*
   - [x] Have you written or updated unit tests to verify your changes? *(20 
new PR 3 unit tests across 4 JUnit suites + 2 multi-node Cluster Configuration 
DUnit tests, plus 46 inherited PR 1 vector unit tests.)*
   - [x] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)? *(No new external 
dependencies added; uses Geode 2.1's bundled Apache Lucene `9.12.3`.)*
   
   ---
   
   ## Summary / Motivation
   
   Building on PR 1 (#8154)'s `VectorIndexMetadata`, 
`LuceneIndexFactory.addVectorField(...)` API, and bounded vector segment 
compaction, operators need first-class `gfsh` commands, Cluster Configuration 
Service XML persistence, and JMX/MXBean observability to create, inspect, 
query, and monitor vector indexes across an Apache Geode cluster.
   
   This PR adds:
   1. **`gfsh` CLI Support:** Vector index creation (`create lucene index 
--vector-field=...`) and k-NN / filtered k-NN querying (`search lucene 
--query-vector=... --vector-field=... --k=... --filter-query=...`), plus vector 
metadata reporting in `describe lucene index` / `list lucene indexes`.
   2. **Cluster Configuration & `cache.xml` Round-Trip:** Extends 
`lucene-1.0.xsd`, JAXB `Index` / `Index.VectorField`, `LuceneXmlParser`, and 
`LuceneIndexXmlGenerator` so vector indexes persist across locator restarts and 
automatically apply to newly joining servers.
   3. **Observability & Metrics:** Exposes live `segmentMemoryBytes` (backed by 
the Lucene `fileAndChunkRegion` partitioned datastore byte count) and 
`vectorFields` metadata through `LuceneIndexStats`, `LuceneIndexStatsMonitor`, 
`LuceneIndexMetrics`, and `LuceneIndexDetails`.
   
   ---
   
   ## Key Changes
   
   ### `gfsh` Commands, Functions & Query Execution
   - **`LuceneCreateIndexCommand`** & **`LuceneCreateIndexFunction`**:
     - Added `--vector-field` option supporting 
`name:dimension[:similarity[:sq8[:M[:efConstruction]]]]` specs 
(repeatable/comma-separated), allowing pure-vector indexes without requiring 
`--field`.
     - Strict CLI validation rejecting malformed specs, duplicate 
`--vector-field` names, and overlap between `--field` and `--vector-field` with 
`UserErrorException`.
     - Persists `Index.VectorField` definitions into Cluster Configuration 
(`updateConfigForGroup`).
   - **`LuceneSearchIndexCommand`**, **`LuceneSearchIndexFunction`**, 
**`LuceneQueryInfo`**, & **`VectorKnnQueryProvider`**:
     - Added `--query-vector`, `--vector-field`, `--k`, and `--filter-query` 
options.
     - Strict input validation rejecting `--limit <= 0`, unmatched brackets, 
empty/trailing vector commas (`split(",", -1)`), and orphan 
`--vector-field`/`--k`/`--filter-query` flags without `--query-vector`.
     - `LuceneSearchIndexFunction` respects `queryInfo.getLimit()` while 
passing `k` to `VectorKnnQueryProvider`; 
`VectorKnnQueryProvider.parseFilterQuery` closes fallback `StandardAnalyzer` 
cleanly via try-with-resources and fails fast on unqualified `--filter-query` 
against pure-vector indexes.
   - **`LuceneIndexInfo`** & **`LuceneIndexDetails`**:
     - Extended CLI transfer objects to carry `vectorFields` metadata and live 
`segmentMemoryBytes`.
   
   ### XML Schema & Cluster Configuration Persistence
   - **`lucene-1.0.xsd`**, **`Index`** (`Index.VectorField`), 
**`LuceneXmlParser`**, **`LuceneIndexXmlGenerator`**, **`LuceneXmlConstants`**:
     - Added optional `<lucene:vector-field name="..." dimension="..." 
similarity="..." max-connections="..." beam-width="..." quantize-sq8="..."/>` 
element to `lucene-1.0.xsd` (backward compatible with existing `cache.xml` 
documents).
     - Strict XML parsing validates `quantize-sq8` (`true`/`false` only) and 
rejects duplicate `<vector-field>` definitions with `CacheXmlException`.
   
   ### Metrics & JMX Observability
   - **`LuceneIndexStats`**, **`LuceneIndexForPartitionedRegion`**, 
**`LuceneIndexStatsMonitor`**, **`StatsKey`**, **`LuceneIndexMetrics`**:
     - Wired a live `volatile LongSupplier` in `LuceneIndexStats` connected 
directly to `getFileAndChunkRegion().getPrStats().getDataStoreBytesInUse()`, 
ensuring `getSegmentMemoryBytes()` reflects live memory usage even when 
`statistic-sampling-enabled=false`.
     - Exposed `getSegmentMemoryBytes()` and `getVectorFields()` on 
`LuceneIndexMetrics` MXBean CompositeType while retaining all legacy 
constructors for backward compatibility.
   
   ### New Unit & Distributed Tests (20 PR 3 Unit + 2 DUnit)
   - `LuceneVectorCommandsJUnitTest` (7 tests): CLI parsing, pure-vector index 
creation, duplicate/overlap rejection, malformed vector/bracket/limit 
validation, and search flag validation.
   - `LuceneVectorFunctionsJUnitTest` (6 tests): `LuceneCreateIndexFunction`, 
`LuceneSearchIndexFunction` limit vs `k`, `VectorKnnQueryProvider` filtered 
k-NN, and unqualified filter fail-fast checks.
   - `LuceneVectorMetricsJUnitTest` (4 tests): live `segmentMemoryBytes` 
without statistics sampling, `LuceneIndexStatsMonitor`, `LuceneIndexMetrics` 
backward-compatible constructors and MXBean getters.
   - `LuceneVectorXmlRoundTripJUnitTest` (3 tests): `cache.xml` + 
`LuceneIndexXmlGenerator` / `LuceneXmlParser` round-trip, strict `quantize-sq8` 
validation, and duplicate `<vector-field>` rejection.
   - `LuceneVectorClusterConfigurationDUnitTest` (2 DUnit tests): real locator 
+ servers creating a vector index via `gfsh`, persisting XML in Cluster 
Configuration, joining a new server dynamically, and executing `search lucene 
--query-vector=...` end-to-end.
   
   ---
   
   ## Backward Compatibility & Serialization Notes
   
   - **Backward-Compatible Schema & MXBean:** `<lucene:vector-field>` is 
optional (`minOccurs="0" maxOccurs="unbounded"`) in `lucene-1.0.xsd`. Legacy 
`LuceneIndexMetrics`, `LuceneIndexInfo`, `LuceneIndexDetails`, and 
`LuceneQueryInfo` constructors are preserved as delegating overloads.
   - **Sanctioned Serializables:** Updated 
`sanctioned-geode-lucene-serializables.txt` for `VectorKnnQueryProvider`, 
`Index`, `Index$VectorField`, `LuceneIndexInfo`, `LuceneIndexDetails`, and 
`LuceneQueryInfo`, verified with 
`AnalyzeLuceneSerializablesIntegrationTest.testSerializables` and real P2P 
serialization in `LuceneVectorClusterConfigurationDUnitTest`.
   
   ---
   
   ## Exact Gradle Verification Commands & Pass Counts
   
   ```bash
   ./gradlew --no-daemon --max-workers=2 \
     :geode-lucene:spotlessCheck \
     :geode-gfsh:spotlessCheck \
     :geode-lucene:checkPom \
     :geode-lucene:javadoc \
     :geode-lucene:test --rerun \
     :geode-gfsh:test
   
   ./gradlew --no-daemon --max-workers=2 \
     :geode-lucene:distributedTest --tests 
"*LuceneVectorClusterConfigurationDUnitTest*"
   
   ./gradlew --no-daemon --max-workers=2 \
     :geode-lucene:integrationTest \
     --tests 
"org.apache.geode.codeAnalysis.AnalyzeLuceneSerializablesIntegrationTest.testSerializables"
   ```
   
   | Verification Suite | Total | Passed | Failed | Skipped | Status |
   | :--- | ---: | ---: | ---: | ---: | :--- |
   | `:geode-lucene:test --rerun` | 349 | 345 | 0 | 4 *(pre-existing)* | 
**PASS** |
   | Vector Unit Suites (20 PR 3 + 46 PR 1) | 66 | 66 | 0 | 0 | **PASS** |
   | `:geode-gfsh:test` | 966 | 964 | 0 | 2 *(pre-existing)* | **PASS** |
   | `LuceneVectorClusterConfigurationDUnitTest` | 2 | 2 | 0 | 0 | **PASS** 
(`19.51s`) |
   | `AnalyzeLuceneSerializablesIntegrationTest.testSerializables` | 1 | 1 | 0 
| 0 | **PASS** |
   | `spotlessCheck` (`geode-lucene`, `geode-gfsh`), `checkPom`, `javadoc` | — 
| — | 0 | — | **PASS** |
   
   ### Per-Suite Vector & DUnit Test Breakdown
   
   ```text
   PR 3 (:geode-lucene:test): total=349, passed=345, failed=0, errors=0, 
skipped=4
     - org.apache.geode.cache.lucene.VectorIndexMetadataJUnitTest: 10/10 passed 
(0 failed, 0 errors, 0 skipped, 0.265s)
     - 
org.apache.geode.cache.lucene.internal.VectorIndexProfileAndFactoryJUnitTest: 
13/13 passed (0 failed, 0 errors, 0 skipped, 0.009s)
     - org.apache.geode.cache.lucene.internal.VectorSegmentCompactionJUnitTest: 
5/5 passed (0 failed, 0 errors, 0 skipped, 2.614s)
     - 
org.apache.geode.cache.lucene.internal.cli.commands.LuceneVectorCommandsJUnitTest:
 7/7 passed (0 failed, 0 errors, 0 skipped, 0.243s)
     - 
org.apache.geode.cache.lucene.internal.cli.functions.LuceneVectorFunctionsJUnitTest:
 6/6 passed (0 failed, 0 errors, 0 skipped, 0.033s)
     - 
org.apache.geode.cache.lucene.internal.management.LuceneVectorMetricsJUnitTest: 
4/4 passed (0 failed, 0 errors, 0 skipped, 0.003s)
     - 
org.apache.geode.cache.lucene.internal.repository.serializer.VectorCodecRecallJUnitTest:
 4/4 passed (0 failed, 0 errors, 0 skipped, 0.287s)
     - 
org.apache.geode.cache.lucene.internal.repository.serializer.VectorFieldMapperJUnitTest:
 14/14 passed (0 failed, 0 errors, 0 skipped, 0.014s)
     - 
org.apache.geode.cache.lucene.internal.xml.LuceneVectorXmlRoundTripJUnitTest: 
3/3 passed (0 failed, 0 errors, 0 skipped, 0.112s)
   PR 3 (:geode-gfsh:test): total=966, passed=964, failed=0, errors=0, skipped=2
   PR 3 (:geode-lucene:distributedTest): total=2, passed=2, failed=0, errors=0, 
skipped=0
     - 
org.apache.geode.cache.lucene.internal.configuration.LuceneVectorClusterConfigurationDUnitTest:
 2/2 passed (0 failed, 0 errors, 0 skipped, 19.505s)
   ```
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to