Skip to content

fix: update RocksdbClient to use getDeclaredConstructor for options instantiation #749

Open
SYaoJun wants to merge 1 commit intoapache:masterfrom
SYaoJun:228_deprecated
Open

fix: update RocksdbClient to use getDeclaredConstructor for options instantiation #749
SYaoJun wants to merge 1 commit intoapache:masterfrom
SYaoJun:228_deprecated

Conversation

@SYaoJun
Copy link
Contributor

@SYaoJun SYaoJun commented Feb 28, 2026

update some the deprecated methods to use new methods.

  1. update RocksdbClient to use getDeclaredConstructor for options instantiation
  2. replace deprecated KnnVectorField with KnnFloatVectorField in GraphVectorIndex
The method newInstance() from the type Class<capture#1-of ?> is deprecated
The type KnnVectorField is deprecatedJava(16777221)

What changes were proposed in this pull request?

How was this PR tested?

  • Tests have Added for the changes
  • Production environment verified

…nstantiation and replace deprecated KnnVectorField with KnnFloatVectorField in GraphVectorIndex
Copy link
Contributor

@Leomrlin Leomrlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert on these changes, just shared a few comments. Could @tanghaodong25 please review this PR? He originally developed and submitted this part of the code, so he might have more thorough insights.

LOGGER.info("rocksdb optionClass {}", optionClass);
try {
this.rocksDBOptions = (IRocksDBOptions) Class.forName(optionClass).newInstance();
this.rocksDBOptions = (IRocksDBOptions) Class.forName(optionClass).getDeclaredConstructor().newInstance();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do all implementation classes of optionClass have a no-argument constructor?
If some classes do not have a no-argument constructor, will getDeclaredConstructor() throw an exception?

TopDocs topDocs = searcher.search(knnQuery, topK);

Document firstDoc = searcher.doc(topDocs.scoreDocs[0].doc);
Document firstDoc = searcher.storedFields().document(topDocs.scoreDocs[0].doc);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the version requirements for Lucene regarding the storedFields() method? Does this change affect performance (by adding an extra method call)?

@Leomrlin Leomrlin requested a review from tanghaodong25 March 2, 2026 02:36
Copy link
Contributor

@tanghaodong25 tanghaodong25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants