Skip to content

feat: add Java client and server framework#69

Merged
jackye1995 merged 7 commits into
lance-format:mainfrom
jackye1995:java-framework
May 21, 2025
Merged

feat: add Java client and server framework#69
jackye1995 merged 7 commits into
lance-format:mainfrom
jackye1995:java-framework

Conversation

@jackye1995

@jackye1995 jackye1995 commented May 20, 2025

Copy link
Copy Markdown
Collaborator

This PR introduces the basic client and server interactions expected in Lance namespace:

  1. any implementation must implement core's LanceNamespace interface to support Java
  2. I have added a basic LanceRestNamespace as example, but other implementation like LanceHiveNamespace can also be provided as separated modules.
  3. I have implemented the SpringBoot controllers and a server as a Lance REST adapter. The controllers take a delegate, which can be updated later to be based on configs, for example if user configs hive, then the server can initiate a LanceHiveNamespace and delegate executions all to it. This will directly provides a REST server implementation for Hive.

@jackye1995 jackye1995 requested a review from yanghua May 20, 2025 05:19
@github-actions github-actions Bot added enhancement New feature or request java Java features labels May 20, 2025
Comment on lines +16 to +27
import com.lancedb.lance.namespace.client.apache.model.CreateNamespaceRequest;
import com.lancedb.lance.namespace.client.apache.model.DropNamespaceRequest;
import com.lancedb.lance.namespace.client.apache.model.GetNamespaceRequest;
import com.lancedb.lance.namespace.client.apache.model.GetNamespaceResponse;
import com.lancedb.lance.namespace.client.apache.model.GetTableRequest;
import com.lancedb.lance.namespace.client.apache.model.GetTableResponse;
import com.lancedb.lance.namespace.client.apache.model.ListNamespacesRequest;
import com.lancedb.lance.namespace.client.apache.model.ListNamespacesResponse;
import com.lancedb.lance.namespace.client.apache.model.NamespaceExistsRequest;
import com.lancedb.lance.namespace.client.apache.model.RegisterTableRequest;
import com.lancedb.lance.namespace.client.apache.model.RegisterTableResponse;
import com.lancedb.lance.namespace.client.apache.model.TableExistsRequest;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we refactor (or re-generate) the package to be com.lancedb.lance.namspace.model.XXXX?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

let me do that in another PR then, this change will make this PR too many changes.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

#71

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OK

import com.lancedb.lance.namespace.client.apache.model.RegisterTableResponse;
import com.lancedb.lance.namespace.client.apache.model.TableExistsRequest;

public interface LanceNamespace {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add some TODO to remember to add comments?

Comment on lines +42 to +44
converted.setNamespace(response.getNamespace());
converted.setName(response.getName());
converted.setProperties(response.getProperties());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can it be generated automatically? If we add a property to the spec, do we also need to add a setter here manually?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

currently yes, because they are different client & server models.

Comment on lines +16 to +19
import com.lancedb.lance.namespace.server.springboot.model.GetNamespaceResponse;
import com.lancedb.lance.namespace.server.springboot.model.GetTableResponse;
import com.lancedb.lance.namespace.server.springboot.model.ListNamespacesResponse;
import com.lancedb.lance.namespace.server.springboot.model.RegisterTableResponse;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we find a way to put the req/resp entities under the same packages?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

need to do some experiments with that, let me check if that is feasible

@jackye1995 jackye1995 May 20, 2025

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

https://openapi-generator.tech/docs/generators/java

https://openapi-generator.tech/docs/generators/spring

Looks like there is not a way to let them be the same model, because both always generate models... so some sort of conversion is necessary to work between server and client models although they are exactly the same.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

In that case we probably need to add some enforcement that spec changes must also update client and server model mapping.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added #72 to track this

@github-actions github-actions Bot added python Python features spec Restful openapi spec rust Rust features labels May 21, 2025
@jackye1995

Copy link
Copy Markdown
Collaborator Author

@yanghua fixed the exists API inconsistency by returning a proper TableExistsResponse and NamespaceExistsResponse to make it consistent with other APIs. If we keep the original way of only returning 200 vs 4XX error in the REST API to indicate exists or not, it ends up having to convert back and forth between that and the boolean expression so I did not go with that direction.

@yanghua yanghua left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall, LGTM. Let's iterate in the further PR if we find issues.

@jackye1995 jackye1995 merged commit a710d7a into lance-format:main May 21, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request java Java features python Python features rust Rust features spec Restful openapi spec

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants