Skip to content

Commit 7b69856

Browse files
author
davitbzh
committedJan 14, 2025
java client
1 parent ccd049b commit 7b69856

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
 

‎docs/user_guides/integrations/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Hopsworks is an open platform aiming to be accessible from a variety of tools. Learn in this section how to connect to Hopsworks from
44

55
- [Python, AWS SageMaker, Google Colab, Kubeflow](python)
6+
- [Java](java)
67
- [Databricks](databricks/networking)
78
- [AWS EMR](emr/emr_configuration)
89
- [Azure HDInsight](hdinsight)

‎docs/user_guides/integrations/java.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
description: Documentation on how to connect to Hopsworks from a Java client.
3+
---
4+
5+
# Java client
6+
7+
This guide explains step by step how to connect to Hopsworks from a Java client.
8+
9+
10+
## Generate an API key
11+
12+
For instructions on how to generate an API key follow this [user guide](../projects/api_key/create_api_key.md). For the Java client to work correctly make sure you add the following scopes to your API key:
13+
14+
1. featurestore
15+
2. project
16+
3. job
17+
4. kafka
18+
19+
## Connecting to the Feature Store
20+
21+
You are now ready to connect to the Hopsworks Feature Store from a Java client:
22+
23+
```Java
24+
//Import necessary classes
25+
import com.logicalclocks.hsfs.FeatureStore;
26+
import com.logicalclocks.hsfs.FeatureView;
27+
import com.logicalclocks.hsfs.HopsworksConnection;
28+
29+
//Establish connection with Hopsworks.
30+
HopsworksConnection hopsworksConnection = HopsworksConnection.builder()
31+
.host("my_instance") // DNS of your Feature Store instance
32+
.port(443) // Port to reach your Hopsworks instance, defaults to 443
33+
.project("my_project") // Name of your Hopsworks Feature Store project
34+
.apiKeyValue("api_key") // The API key to authenticate with the feature store
35+
.hostnameVerification(false) // Disable for self-signed certificates
36+
.build();
37+
38+
//get feature store handle
39+
FeatureStore fs = hopsworksConnection.getFeatureStore();
40+
41+
//get feature view handle
42+
FeatureView fv = fs.getFeatureView(fvName, fvVersion);
43+
44+
// get feature vector
45+
List<Object> singleVector = fv.getFeatureVector(new HashMap<String, Object>() {{
46+
put("id", 100);
47+
}});
48+
```
49+
50+
## Next Steps
51+
For more information how to interact from Java client with the Hopsworks Feature store follow this [tutorial](https://github.com/logicalclocks/hopsworks-tutorials/tree/java_engine/java).

0 commit comments

Comments
 (0)