# aliyun-pairec-config-java-sdk **Repository Path**: aliyun/aliyun-pairec-config-java-sdk ## Basic Information - **Project Name**: aliyun-pairec-config-java-sdk - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-08 - **Last Updated**: 2025-09-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # aliyun-pairec-config-java-sdk Java sdk for PA-REC config server. Aliyun product [link](https://pairec.console.aliyun.com/v2). ## Installation ``` com.aliyun.openservices.aiservice pairec-sdk 1.0.5 ``` ## Usage ```java package com.aliyun.openservices.pairec; import com.aliyun.openservices.pairec.api.ApiClient; import com.aliyun.openservices.pairec.api.Configuration; import com.aliyun.openservices.pairec.common.Constants; import com.aliyun.openservices.pairec.model.ExperimentContext; import com.aliyun.openservices.pairec.model.ExperimentResult; public class ExperimentTest { static ExperimentClient experimentClient; public static void main(String[] args) throws Exception { String regionId = "cn-hangzhou"; String instanceId = System.getenv("INSTANCE_ID"); // pai-rec instance id String accessId = System.getenv("ACCESS_ID"); // aliyun accessKeyId String accessKey = System.getenv("ACCESS_KEY"); // aliyun accessKeySecret Configuration configuration = new Configuration(regionId, accessId, accessKey, instanceId); // set experiment environment configuration.setEnvironment(Constants.Environment_Product_Desc); ApiClient apiClient = new ApiClient(configuration); experimentClient = new ExperimentClient(apiClient); // init client experimentClient.init(); // set expeirment context ExperimentContext experimentContext = new ExperimentContext(); experimentContext.setUid("103441638"); experimentContext.setRequestId("pvid"); // match experiment, use scence and experimentContext ExperimentResult experimentResult = experimentClient.matchExperiment("home_feed", experimentContext); // exp id System.out.println(experimentResult.getExpId()); // exp log info System.out.println(experimentResult.info()); // get experiment param value System.out.println(experimentResult.getExperimentParams().getString("rank_version", "not exist")); System.out.println(experimentResult.getExperimentParams().getString("version", "not exist")); System.out.println(experimentResult.getExperimentParams().getString("recall", "not exist")); System.out.println(experimentResult.getExperimentParams().getDouble("recall_d", 0.0)); // get experiment param value by pecific layer name System.out.println(experimentResult.getLayerParams("recall").getString("rank_version", "not exist")); System.out.println(experimentResult.getLayerParams("rank").getString("version", "not exist")); } } ``` ## 版本说明 1.0.5 (2024-07-05) * 修复实验组设置过滤条件时,上下文不传过滤参数时抛出异常 1.0.4 (2024-04-17) * 修复实验组随机流量匹配bug, 无法匹配所有人的实验组 1.0.3 (2024-03-23) * 增加实验组随机流量的匹配逻辑 1.0.2 (2024-03-07) * 优先匹配带有过滤条件或者指定人群的实验组