Package ai.chalk.client
Class ChalkClientImpl
java.lang.Object
ai.chalk.client.ChalkClientImpl
- All Implemented Interfaces:
ChalkClient,AutoCloseable
-
Nested Class Summary
Nested classes/interfaces inherited from interface ai.chalk.client.ChalkClient
ChalkClient.Builder -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()onlineQuery(OnlineQueryParamsComplete params) OnlineQuery computes features values using online resolvers.intping(int num) Pings the Chalk engine withnumand returns the number echoed by the engine.voidPrints the current ChalkClient configuration and its sources to stdout.uploadFeatures(UploadFeaturesParams params) UploadFeatures synchronously persists feature values to the online store and offline store.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ai.chalk.client.ChalkClient
ping
-
Constructor Details
-
ChalkClientImpl
- Throws:
ChalkException
-
-
Method Details
-
onlineQuery
Description copied from interface:ChalkClientOnlineQuery computes features values using online resolvers.See
OnlineQueryParamsfor more details on the parameters.Example usage for bulk queries:
{@code OnlineQueryParamsComplete params = OnlineQueryParams.builder() .withInput("user.id", Arrays.asList(1, 2, 3)) .withOutputs("user.email", "user.transactions") .build(); try (OnlineQueryResult result = client.onlineQuery(params)) { // do something with the result } </pre> </p> <p> Example usage for single-row queries using SingleRowInput: <pre> {@code var singleRow = new OnlineQueryParams.SingleRowInput() .withInput("user.id", 123) .withInput("user.email", "test@example.com") .withInput("user.favorite_foods", Arrays.asList("pizza", "pasta")); OnlineQueryParamsComplete params = OnlineQueryParams.builder() .withInput(singleRow) .withOutputs("user.credit_score", "user.transactions") .build(); try (OnlineQueryResult result = client.onlineQuery(params)) { // do something with the result } </pre> </p> @return {@link OnlineQueryResult } @throws ChalkException @see <a href="https://docs.chalk.ai/docs/query-basics">query basics</a>- Specified by:
onlineQueryin interfaceChalkClient- Throws:
ChalkException
-
ping
Description copied from interface:ChalkClientPings the Chalk engine withnumand returns the number echoed by the engine.- Specified by:
pingin interfaceChalkClient- Parameters:
num- the number to send to the engine- Returns:
- the number echoed by the engine
- Throws:
ChalkException- if the engine cannot be reached
-
uploadFeatures
Description copied from interface:ChalkClientUploadFeatures synchronously persists feature values to the online store and offline store.See
UploadFeaturesParamsfor more details on the parameters.Example usage:
{@code var userIds = Arrays.asList("777", "888", "999"); var scoreList = Arrays.asList(600, 700, 800); UploadFeaturesParams params = UploadFeaturesParams.builder() .withInputs(Map.of("user.id", userIds,"user.credit_score", scoreList)) .withInput(Features.user.email, List.of("user1@email.com", "user2@email.com", "user3@email.com")) .build(); UploadFeaturesResult res = client.uploadFeatures(params); if (client.uploadFeatures(params).getErrors().size() > 0) { throw new Exception("upload failed"); } </pre> </p>- Specified by:
uploadFeaturesin interfaceChalkClient- Throws:
ChalkException
-
printConfig
public void printConfig()Description copied from interface:ChalkClientPrints the current ChalkClient configuration and its sources to stdout.- Specified by:
printConfigin interfaceChalkClient
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-