play.inject.Injector.instanceOf()

Here are the examples of the java api play.inject.Injector.instanceOf() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

61 Examples 7

19 Source : PlayResourceFactory.java
with BSD 2-Clause "Simplified" License
from linkedin

@Override
public <R> R create(Clreplaced<R> resourceClreplaced) {
    return _injector.instanceOf(resourceClreplaced);
}

19 Source : TensorFlowBatchIndexerTest.java
with MIT License
from grouplens

@Test
public void testTensorFlowBatchIndex() {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    MockIndexer mockIndexer = new MockIndexer(config, configService, injector, "daoConfig", config);
    SpaceProducer spaceProducer = injector.instanceOf(SpaceProducer.clreplaced);
    List<FeatureExtractor> featureExtractors = new ArrayList<>();
    FeatureExtractor itemExtractor = new SeparatedStringExtractor("ITEM", "item", "item", "\\|", false, null, null);
    featureExtractors.add(itemExtractor);
    FeatureExtractor attrExtractor = new SeparatedStringExtractor("ATTR", "attr", "attr", "\\|", false, "null", null);
    featureExtractors.add(attrExtractor);
    FeatureExtractor sizeExtractor = new SeparatedStringSizeExtractor("SEQ_LEN", "item", "sequence_length", "|", null);
    featureExtractors.add(sizeExtractor);
    TensorFlowModel model = new TensorFlowModelProducer(spaceProducer).createTensorFlowModelModelFromGraphDef("name", SpaceMode.DEFAULT, "shouldNotExist.graph", null, new ArrayList<>(), null, Lists.newArrayList("ITEM", "ATTR", "SEQ_LEN"), featureExtractors, "loss", "update", "output", "init", "top_k", "topKId", "topKValue", "ITEM");
    TensorFlowBatchIndexer batchIndexer = new TensorFlowBatchIndexer(configService, config, injector, config, "daoConfig", mockIndexer, model, 1, "tstamp");
    ArrayNode batch = Json.newArray();
    ObjectNode user1 = Json.newObject();
    user1.put("item", "20|49|10|2|4");
    user1.put("attr", "jid|cjk|je|je|cjk");
    batch.add(user1);
    ObjectNode user2 = Json.newObject();
    user2.put("item", "14|19|2|5|20|15|2");
    user2.put("attr", "cjk|mn|je|lk|jid|null|je");
    batch.add(user2);
    RequestContext requestContext = new RequestContext(Json.newObject(), "test");
    batchIndexer.index(batch, requestContext);
    ArrayNode indexed = mockIndexer.getIndexed();
    replacedertEquals("1,2,3,4,5,6,7,4,8,1,9,4", indexed.get(0).get("item_idx").asText());
    replacedertEquals("1,2,3,3,2,2,4,3,5,1,6,3", indexed.get(0).get("attr_idx").asText());
    replacedertEquals("5.0,7.0", indexed.get(0).get("sequence_length_val").asText());
    batch.removeAll();
    indexed.removeAll();
    ObjectNode item1 = Json.newObject();
    item1.put("item", "20");
    item1.put("attr", "jid");
    batch.add(item1);
    ObjectNode item2 = Json.newObject();
    item2.put("item", "15");
    batch.add(item2);
    ObjectNode item3 = Json.newObject();
    item3.put("item", "40");
    item3.put("attr", "cjk");
    batch.add(item3);
    ObjectNode item4 = Json.newObject();
    item4.put("item", "41");
    item4.put("attr", "djkfds");
    batch.add(item4);
    batchIndexer.index(batch, requestContext);
    replacedertEquals("1,9,10,11", indexed.get(0).get("item_idx").asText());
    replacedertEquals("1,6,2,7", indexed.get(0).get("attr_idx").asText());
}

19 Source : XGBoostPredictorConfig.java
with MIT License
from grouplens

public static PredictorConfig getPredictorConfig(Configuration predictorConfig, Injector injector) {
    FeaturizerConfigParser parser = injector.instanceOf(FeatureExtractorListConfigParser.clreplaced);
    Configuration daoConfigs = predictorConfig.getConfig(ConfigKey.ENreplacedY_DAOS_CONFIG.get());
    List<FeatureExtractorConfig> feaExtConfigs = parser.parse(predictorConfig.getConfig(ConfigKey.PREDICTOR_FEATURIZER_CONFIG.get()));
    List<Configuration> expanders = ExpanderUtilities.getEnreplacedyExpandersConfig(predictorConfig);
    int round = predictorConfig.getInt("numTrees");
    return new XGBoostPredictorConfig(predictorConfig.getString("modelName"), feaExtConfigs, predictorConfig.getStringList("features"), predictorConfig.getString("labelName"), predictorConfig.getString("weightName"), daoConfigs, expanders, injector, new XGBoostMethod(predictorConfig.getConfig("methodConfig").asMap(), round), predictorConfig.getString("modelFile"), predictorConfig.getString("daoConfigKey"), predictorConfig);
}

19 Source : XGBoostGBCentPredictorConfig.java
with MIT License
from grouplens

public static PredictorConfig getPredictorConfig(Configuration predictorConfig, Injector injector) {
    FeaturizerConfigParser parser = injector.instanceOf(FeatureExtractorListConfigParser.clreplaced);
    Configuration daosConfig = predictorConfig.getConfig(ConfigKey.ENreplacedY_DAOS_CONFIG.get());
    List<FeatureExtractorConfig> feaExtConfigs = parser.parse(predictorConfig.getConfig(ConfigKey.PREDICTOR_FEATURIZER_CONFIG.get()));
    List<Configuration> expanders = ExpanderUtilities.getEnreplacedyExpandersConfig(predictorConfig);
    return new XGBoostGBCentPredictorConfig(predictorConfig.getString("modelName"), predictorConfig.getString("svdfeaModelName"), predictorConfig.getString("svdfeaPredictorName"), predictorConfig.getStringList("treeFeatures"), feaExtConfigs, daosConfig, expanders, predictorConfig.getConfig("methodConfig"), injector, predictorConfig.getString("modelFile"), predictorConfig.getString("daoConfigKey"), predictorConfig);
}

19 Source : XGBoostClassifierRetrieverConfig.java
with MIT License
from grouplens

public Retriever getRetriever(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    ModelService modelService = injector.instanceOf(ModelService.clreplaced);
    configService.getPredictor(predictorName, requestContext);
    XGBoostModel model = (XGBoostModel) modelService.getModel(requestContext.getEngineName(), modelName);
    return new XGBoostClreplacedifierRetriever(model, config, requestContext, injector);
}

19 Source : UserSequenceIndexerConfig.java
with MIT License
from grouplens

public Indexer getIndexer(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    GroupedIndexer indexer = (GroupedIndexer) configService.getIndexer(indexerName, requestContext);
    return new UserSequenceIndexer(configService, config, injector, daoConfigs, daoConfigKey, filePathKey, dataFields, separator, daoNameKey, daoName, filesKey, groupKeys, filePath, innerFieldSeparator, separatorKey, indexer, usedGroupsFilePath, 128, requestContext);
}

19 Source : TensorFlowPredictorConfig.java
with MIT License
from grouplens

static public PredictorConfig getPredictorConfig(Configuration predictorConfig, Injector injector) throws ConfigurationException {
    FeaturizerConfigParser parser = injector.instanceOf(FeatureExtractorListConfigParser.clreplaced);
    Configuration daoConfigs = predictorConfig.getConfig(ConfigKey.ENreplacedY_DAOS_CONFIG.get());
    List<FeatureExtractorConfig> feaExtConfigs = parser.parse(predictorConfig.getConfig(ConfigKey.PREDICTOR_FEATURIZER_CONFIG.get()));
    List<Configuration> expanders = ExpanderUtilities.getEnreplacedyExpandersConfig(predictorConfig);
    List<String> evaluatorNames = new ArrayList<>();
    if (predictorConfig.asMap().containsKey("evaluatorNames")) {
        evaluatorNames = predictorConfig.getStringList("evaluatorNames");
    }
    List<Configuration> checkConfigs = predictorConfig.getConfigList("equalSizeChecks");
    List<List<String>> equalSizeChecks = new ArrayList<>();
    if (checkConfigs != null) {
        for (Configuration check : checkConfigs) {
            equalSizeChecks.add(check.getStringList("featuresWithEqualSizes"));
        }
    }
    return new TensorFlowPredictorConfig(predictorConfig.getStringList("groupKeys"), predictorConfig.getStringList("indexKeys"), equalSizeChecks, evaluatorNames, predictorConfig.getString("modelFile"), predictorConfig.getString("modelName"), feaExtConfigs, daoConfigs, predictorConfig.getConfig("methodConfig"), predictorConfig.getConfig("onlineMethodConfig"), injector, expanders, predictorConfig.getString("daoConfigKey"), predictorConfig.getString("predItemFea"), predictorConfig.getString("outputOper"), predictorConfig.getString("updateOper"), predictorConfig.getString("lossOper"), predictorConfig.getString("initOper"), predictorConfig.getString("topKOper"), predictorConfig.getString("topKId"), predictorConfig.getString("topKValue"), predictorConfig.getString("itemIndex"), predictorConfig.getString("graphDefFilePath"), predictorConfig.getString("modelExportDir"), predictorConfig);
}

19 Source : TensorFlowBatchIndexerConfig.java
with MIT License
from grouplens

public Indexer getIndexer(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    ModelService modelService = injector.instanceOf(ModelService.clreplaced);
    Indexer indexer = configService.getIndexer(indexerName, requestContext);
    configService.getPredictor(predictorName, requestContext);
    TensorFlowModel model = (TensorFlowModel) modelService.getModel(requestContext.getEngineName(), modelName);
    JsonNode reqBody = requestContext.getRequestBody();
    int batchSize = JsonHelpers.getOptionalInt(reqBody, batchSizeKey, this.batchSize);
    return new TensorFlowBatchIndexer(configService, config, injector, daoConfigs, daoConfigKey, indexer, model, batchSize, timestampField, requestContext);
}

19 Source : TensorFlowBasedRetrieverConfig.java
with MIT License
from grouplens

public Retriever getRetriever(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    ModelService modelService = injector.instanceOf(ModelService.clreplaced);
    configService.getPredictor(predictorName, requestContext);
    TensorFlowModel model = (TensorFlowModel) modelService.getModel(requestContext.getEngineName(), modelName);
    return new TensorFlowBasedRetriever(model, N, config, requestContext, injector, preplacedOnFields, preplacedOnNewFields);
}

19 Source : QuartzSchedulerConfig.java
with MIT License
from grouplens

public void scheduleJobs() {
    List<String> hosts = config.getStringList("hosts");
    if (hosts != null && !Utilities.isInHosts(hosts)) {
        return;
    }
    String cronExprStr = config.getString("cronExpression");
    CronExpression cronExpr;
    try {
        cronExpr = new CronExpression(cronExprStr);
    } catch (ParseException e) {
        throw new ConfigurationException(e);
    }
    Trigger trigger = newTrigger().withIdenreplacedy(schedulerName).withSchedule(cronSchedule(cronExpr)).build();
    Configuration jobConfig = config.getConfig("jobConfig");
    JobDataMap jobDataMap = new JobDataMap();
    jobDataMap.put("jobConfig", jobConfig);
    jobDataMap.put("injector", injector);
    jobDataMap.put("engineName", engineName);
    String jobClreplaced = config.getString("jobClreplaced");
    try {
        JobDetail jobDetail = newJob(Clreplaced.forName(jobClreplaced).replacedubclreplaced(Job.clreplaced)).withIdenreplacedy(schedulerName).usingJobData(jobDataMap).build();
        QuartzSchedulerService schedulerService = injector.instanceOf(QuartzSchedulerService.clreplaced);
        schedulerService.scheduleJob(trigger, jobDetail);
    } catch (ClreplacedNotFoundException e) {
        throw new ConfigurationException(e);
    }
}

19 Source : QuartzSchedulerConfig.java
with MIT License
from grouplens

public void runJobs() {
    QuartzSchedulerService schedulerService = injector.instanceOf(QuartzSchedulerService.clreplaced);
    schedulerService.triggerJob(new JobKey(schedulerName));
}

19 Source : UserKnnRetrieverConfig.java
with MIT License
from grouplens

public Retriever getRetriever(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    ModelManager knnModelManager = new FeatureKnnModelManager(knnModelName, knnModelFile, injector, svdfeaPredictorName, svdfeaModelName, userAttrs, numMatch, numNeighbors, false, minSupport);
    FeatureKnnModel knnModel = (FeatureKnnModel) knnModelManager.manage(requestContext);
    ModelManager kdnModelManager = new FeatureKnnModelManager(kdnModelName, kdnModelFile, injector, svdfeaPredictorName, svdfeaModelName, userAttrs, numMatch, numNeighbors, true, minSupport);
    FeatureKnnModel kdnModel = (FeatureKnnModel) kdnModelManager.manage(requestContext);
    Retriever retriever = configService.getRetriever(retrieverName, requestContext);
    KnnModelTrigger trigger = new KnnModelTrigger(knnModel, kdnModel, userAttrs, weightAttr, scoreAttr);
    return new UserKnnRetriever(weightAttr, scoreAttr, userAttrs, itemAttrs, retriever, trigger, config, requestContext, injector);
}

19 Source : RedisKeyBasedRetrieverConfig.java
with MIT License
from grouplens

public Retriever getRetriever(RequestContext requestContext) {
    RedisService redisService = injector.instanceOf(RedisService.clreplaced);
    return new RedisKeyBasedRetriever(redisService, retrieveFields, indexPrefix, keyFields, config, requestContext, injector);
}

19 Source : MultipleBlendingRetrieverConfig.java
with MIT License
from grouplens

public Retriever getRetriever(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    List<Retriever> retrievers = new ArrayList<>(retrieverNames.size());
    for (String name : retrieverNames) {
        retrievers.add(configService.getRetriever(name, requestContext));
    }
    return new MultipleBlendingRetriever(retrievers, itemAttrs, maxHits, config, requestContext, injector);
}

19 Source : ItemKnnRetrieverConfig.java
with MIT License
from grouplens

public Retriever getRetriever(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    Retriever retriever = configService.getRetriever(retrieverName, requestContext);
    ModelManager knnModelManager = new FeatureKnnModelManager(knnModelName, knnModelFile, injector, svdfeaPredictorName, svdfeaModelName, itemAttrs, numMatch, numNeighbors, false, minSupport);
    FeatureKnnModel knnModel = (FeatureKnnModel) knnModelManager.manage(requestContext);
    ModelManager kdnModelManager = new FeatureKnnModelManager(kdnModelName, kdnModelFile, injector, svdfeaPredictorName, svdfeaModelName, itemAttrs, numMatch, numNeighbors, true, minSupport);
    FeatureKnnModel kdnModel = (FeatureKnnModel) kdnModelManager.manage(requestContext);
    KnnModelTrigger trigger = new KnnModelTrigger(knnModel, kdnModel, itemAttrs, weightAttr, scoreAttr);
    return new ItemKnnRetriever(retriever, trigger, config, requestContext, injector);
}

19 Source : ESQueryBasedRetrieverConfig.java
with MIT License
from grouplens

public Retriever getRetriever(RequestContext requestContext) {
    ElasticSearchService elasticSearchService = injector.instanceOf(ElasticSearchService.clreplaced);
    return new ESQueryBasedRetriever(elasticSearchService, elasticSearchScoreName, elasticSearchReqKey, defaultMatchAll, setScrollKey, elasticSearchIndex, retrieveType, retrieveFields, config, matchFields, queryKey, requestContext, injector);
}

19 Source : ESQueryBasedRetrieverConfig.java
with MIT License
from grouplens

static public RetrieverConfig getRetrieverConfig(Configuration retrieverConfig, Injector injector) throws ConfigurationException {
    ElasticSearchService elasticSearchService = injector.instanceOf(ElasticSearchService.clreplaced);
    String elasticSearchIndex = retrieverConfig.getString("elasticSearchIndex");
    Configuration settingConfig = retrieverConfig.getConfig("elasticSearchSetting");
    if (!elasticSearchService.existsIndex(elasticSearchIndex).isExists()) {
        elasticSearchService.createIndex(elasticSearchIndex, settingConfig);
    }
    String elasticSearchScoreName = retrieverConfig.getString("elasticSearchScoreName");
    List<String> retrieveFields = retrieverConfig.getStringList("retrieveFields");
    Configuration mappingConfig = retrieverConfig.getConfig("elasticSearchMapping");
    for (String typeName : mappingConfig.subKeys()) {
        if (!elasticSearchService.existsType(elasticSearchIndex, typeName).isExists()) {
            elasticSearchService.putMapping(elasticSearchIndex, typeName, mappingConfig.getConfig(typeName));
        }
    }
    Boolean defaultMatchAll = retrieverConfig.getBoolean("defaultMatchAll", false);
    return new ESQueryBasedRetrieverConfig(retrieverConfig.getString("elasticSearchIndex"), elasticSearchScoreName, retrieverConfig.getString("retrieveType"), retrieveFields, retrieverConfig.getString("elasticSearchReqKey"), retrieverConfig.getString("setScrollKey"), defaultMatchAll, injector, retrieverConfig, retrieverConfig.getString("queryKey"), retrieverConfig.getStringList("matchFields"));
}

19 Source : UserReturnIndexerConfig.java
with MIT License
from grouplens

public Indexer getIndexer(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    GroupedIndexer indexer = (GroupedIndexer) configService.getIndexer(indexerName, requestContext);
    int maxTime = JsonHelpers.getOptionalInt(requestContext.getRequestBody(), "maxTime", (int) (System.currentTimeMillis() / 1000));
    return new UserReturnIndexer(configService, config, injector, daoConfigs, daoConfigKey, filePathKey, timestampField, dataFields, separator, daoNameKey, daoName, filesKey, rewardKey, groupKeys, sessionIdKey, filePath, separatorKey, indexer, maxTime, reinforceThreshold, usedGroupsFilePath, 128, requestContext);
}

19 Source : StandardRecommenderConfig.java
with MIT License
from grouplens

public Recommender getRecommender(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    return new StandardRecommender(config, configService.getRetriever(retrieverName, requestContext), configService.getRanker(rankerName, requestContext));
}

19 Source : PredictorBasedRankerConfig.java
with MIT License
from grouplens

public Ranker getRanker(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    Predictor predictor = configService.getPredictor(predictorName, requestContext);
    JsonNode reqBody = requestContext.getRequestBody();
    int page = JsonHelpers.getOptionalInt(reqBody, ConfigKey.RANKER_PAGE.get(), 1);
    int offset = JsonHelpers.getOptionalInt(reqBody, ConfigKey.RANKER_OFFSET.get(), (page - 1) * pageSize);
    int limit = JsonHelpers.getOptionalInt(reqBody, ConfigKey.RANKER_LIMIT.get(), pageSize);
    return new PredictorBasedRanker(predictor, pageSize, offset, limit, config, requestContext, injector);
}

19 Source : SVDFeaturePredictorConfig.java
with MIT License
from grouplens

static public PredictorConfig getPredictorConfig(Configuration predictorConfig, Injector injector) throws ConfigurationException {
    FeaturizerConfigParser parser = injector.instanceOf(FeatureExtractorListConfigParser.clreplaced);
    Configuration daoConfigs = predictorConfig.getConfig(ConfigKey.ENreplacedY_DAOS_CONFIG.get());
    String dependPredictorName = null, dependPredictorModelName = null;
    if (predictorConfig.asMap().containsKey("dependPredictorName")) {
        dependPredictorName = predictorConfig.getString("dependPredictorName");
        dependPredictorModelName = predictorConfig.getString("dependPredictorModelName");
    }
    List<FeatureExtractorConfig> feaExtConfigs = parser.parse(predictorConfig.getConfig(ConfigKey.PREDICTOR_FEATURIZER_CONFIG.get()));
    List<Configuration> expanders = ExpanderUtilities.getEnreplacedyExpandersConfig(predictorConfig);
    List<String> evaluatorNames = new ArrayList<>();
    if (predictorConfig.asMap().containsKey("evaluatorNames")) {
        evaluatorNames = predictorConfig.getStringList("evaluatorNames");
    }
    return new SVDFeaturePredictorConfig(predictorConfig.getStringList("biasFeas"), predictorConfig.getStringList("ufactFeas"), predictorConfig.getStringList("ifactFeas"), predictorConfig.getStringList("groupKeys"), evaluatorNames, predictorConfig.getString("modelFile"), predictorConfig.getString("modelName"), predictorConfig.getString("labelName"), predictorConfig.getString("weightName"), predictorConfig.getInt("factDim"), predictorConfig.getConfig("onlineOptimizationMethod"), predictorConfig.getConfig("optimizationMethod"), predictorConfig.getConfig("objectiveConfig"), feaExtConfigs, daoConfigs, dependPredictorName, dependPredictorModelName, injector, expanders, predictorConfig.getString("daoConfigKey"), predictorConfig);
}

19 Source : RegressionTreePredictorConfig.java
with MIT License
from grouplens

public static PredictorConfig getPredictorConfig(Configuration predictorConfig, Injector injector) {
    FeaturizerConfigParser parser = injector.instanceOf(FeatureExtractorListConfigParser.clreplaced);
    Configuration daoConfigs = predictorConfig.getConfig(ConfigKey.ENreplacedY_DAOS_CONFIG.get());
    List<Configuration> expanders = ExpanderUtilities.getEnreplacedyExpandersConfig(predictorConfig);
    List<FeatureExtractorConfig> feaExtConfigs = parser.parse(predictorConfig.getConfig(ConfigKey.PREDICTOR_FEATURIZER_CONFIG.get()));
    return new RegressionTreePredictorConfig(predictorConfig.getString("modelName"), feaExtConfigs, predictorConfig.getStringList("features"), predictorConfig.getString("labelName"), predictorConfig.getString("weightName"), daoConfigs, expanders, injector, injector.instanceOf(TreeLearningMethod.clreplaced), predictorConfig.getString("modelFile"), predictorConfig.getString("daoConfigKey"), predictorConfig);
}

19 Source : RegressionTreeGBCentPredictorConfig.java
with MIT License
from grouplens

public static PredictorConfig getPredictorConfig(Configuration predictorConfig, Injector injector) {
    FeaturizerConfigParser parser = injector.instanceOf(FeatureExtractorListConfigParser.clreplaced);
    Configuration daosConfig = predictorConfig.getConfig(ConfigKey.ENreplacedY_DAOS_CONFIG.get());
    List<FeatureExtractorConfig> feaExtConfigs = parser.parse(predictorConfig.getConfig(ConfigKey.PREDICTOR_FEATURIZER_CONFIG.get()));
    List<Configuration> expanders = ExpanderUtilities.getEnreplacedyExpandersConfig(predictorConfig);
    return new RegressionTreeGBCentPredictorConfig(predictorConfig.getString("modelName"), predictorConfig.getString("svdfeaModelName"), predictorConfig.getString("svdfeaPredictorName"), predictorConfig.getStringList("treeFeatures"), predictorConfig.getStringList("groupKeys"), feaExtConfigs, daosConfig, expanders, predictorConfig.getConfig("methodConfig"), injector, predictorConfig.getString("modelFile"), predictorConfig.getString("daoConfigKey"), predictorConfig);
}

19 Source : LinearUCBPredictorConfig.java
with MIT License
from grouplens

public static PredictorConfig getPredictorConfig(Configuration predictorConfig, Injector injector) {
    FeaturizerConfigParser parser = injector.instanceOf(FeatureExtractorListConfigParser.clreplaced);
    Configuration daoConfigs = predictorConfig.getConfig(ConfigKey.ENreplacedY_DAOS_CONFIG.get());
    List<FeatureExtractorConfig> feaExtConfigs = parser.parse(predictorConfig.getConfig(ConfigKey.PREDICTOR_FEATURIZER_CONFIG.get()));
    List<Configuration> expanders = ExpanderUtilities.getEnreplacedyExpandersConfig(predictorConfig);
    double alpha = 0.1;
    if (predictorConfig.asMap().containsKey("alpha")) {
        alpha = predictorConfig.getDouble("alpha");
    }
    double lambda = 1.0;
    if (predictorConfig.asMap().containsKey("lambda")) {
        lambda = predictorConfig.getDouble("lambda");
    }
    return new LinearUCBPredictorConfig(predictorConfig.getString("modelName"), feaExtConfigs, predictorConfig.getStringList("features"), predictorConfig.getInt("numMainFeatures"), predictorConfig.getString("labelName"), predictorConfig.getString("weightName"), daoConfigs, expanders, injector, predictorConfig.getConfig("onlineOptimizationMethod"), predictorConfig.getString("modelFile"), predictorConfig.getString("daoConfigKey"), lambda, alpha, predictorConfig.getStringList("evaluatorNames"), predictorConfig);
}

19 Source : GBDTPredictorConfig.java
with MIT License
from grouplens

public static PredictorConfig getPredictorConfig(Configuration predictorConfig, Injector injector) {
    FeaturizerConfigParser parser = injector.instanceOf(FeatureExtractorListConfigParser.clreplaced);
    Configuration daoConfigs = predictorConfig.getConfig(ConfigKey.ENreplacedY_DAOS_CONFIG.get());
    List<FeatureExtractorConfig> feaExtConfigs = parser.parse(predictorConfig.getConfig(ConfigKey.PREDICTOR_FEATURIZER_CONFIG.get()));
    List<Configuration> expanders = ExpanderUtilities.getEnreplacedyExpandersConfig(predictorConfig);
    int maxIter = predictorConfig.getInt("maxNumTrees");
    StandardBoostingMethod boostingMethod = new StandardBoostingMethod(maxIter);
    return new GBDTPredictorConfig(predictorConfig.getString("modelName"), feaExtConfigs, predictorConfig.getStringList("features"), predictorConfig.getString("labelName"), predictorConfig.getString("weightName"), daoConfigs, expanders, injector, injector.instanceOf(TreeLearningMethod.clreplaced), predictorConfig.getStringList("groupKeys"), predictorConfig.getString("modelFile"), predictorConfig.getConfig("objectiveConfig"), boostingMethod, predictorConfig.getString("daoConfigKey"), predictorConfig);
}

19 Source : SQLBasedIndexerConfig.java
with MIT License
from grouplens

public Indexer getIndexer(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    Settings settings = new Settings().withStatementType(StatementType.STATIC_STATEMENT);
    DSLContext create = DSL.using(DB.getDataSource(db), SQLDialect.DEFAULT, settings);
    return new SQLBasedIndexer(configService, daoConfigs, create, tableKey, table, injector, daoConfigKey, fields, fieldTypes, matchFields, matchFieldTypes, retrieverName, setCursorKey, daoNameKey, daoName, cacheJsonFile, filePathKey, separatorKey, config, 128, requestContext);
}

19 Source : RedisBasedIndexerConfig.java
with MIT License
from grouplens

public Indexer getIndexer(RequestContext requestContext) {
    RedisService redisService = injector.instanceOf(RedisService.clreplaced);
    String indexStructure = JsonHelpers.getOptionalString(requestContext.getRequestBody(), indexStructureKey, this.indexStructure);
    RedisBasedIndexer.IndexStructure structure = RedisBasedIndexer.IndexStructure.HASH_SET;
    if (indexStructure != null) {
        structure = RedisBasedIndexer.IndexStructure.valueOf(indexStructure);
    }
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    return new RedisBasedIndexer(redisService, structure, configService, keyFieldsKey, sortFieldKey, indexPrefixKey, hashFieldsKey, daoConfigs, injector, keyFields, hashFields, sortField, indexPrefix, daoConfigKey, config, 128, requestContext);
}

19 Source : NullIndexerConfig.java
with MIT License
from grouplens

public Indexer getIndexer(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    return new NullIndexer(config, configService, injector, daoConfigKey, daoConfigs, 128, requestContext);
}

19 Source : LoggerBasedIndexerConfig.java
with MIT License
from grouplens

public Indexer getIndexer(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    return new LoggerBasedIndexer(config, configService, daoConfigKey, daoConfigs, injector, 128, requestContext);
}

19 Source : JsonFileIndexerConfig.java
with MIT License
from grouplens

public Indexer getIndexer(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    FileWriterService dataService = injector.instanceOf(FileWriterService.clreplaced);
    return new JsonFileIndexer(configService, dataService, config, injector, daoConfigs, daoConfigKey, timestampField, beginTime, beginTimeKey, endTime, endTimeKey, daoName, daoNameKey, filesKey, indexType, subDaoName, subDaoConfigKey, 128, requestContext);
}

19 Source : GroupedIndexerConfig.java
with MIT License
from grouplens

public Indexer getIndexer(RequestContext requestContext) {
    JsonNode reqBody = requestContext.getRequestBody();
    String datDir = JsonHelpers.getOptionalString(reqBody, dataDirKey, dataDir);
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    Indexer indexer = configService.getIndexer(indexerName, requestContext);
    return new GroupedIndexer(configService, config, injector, daoConfigs, daoConfigKey, indexer, datDir, numBuckets, groupKeys, dataFields, separator, orderFields, descending, filesKey, daoName, daoNameKey, separatorKey, usedBuckets, skip, groupKeysTypes, orderFieldsTypes, 128, requestContext);
}

19 Source : ExpandedDAOIndexerConfig.java
with MIT License
from grouplens

public Indexer getIndexer(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    return new ExpandedDAOIndexer(config, configService, injector, daoConfigKey, daoConfigs, 128, requestContext, beginTime, beginTimeKey, endTime, endTimeKey, filePathKey, cacheJsonFile, daoNameKey, daoName, subDaoName, subDaoConfigKey);
}

19 Source : ESBasedIndexerConfig.java
with MIT License
from grouplens

static public IndexerConfig getIndexerConfig(Configuration indexerConfig, Injector injector) {
    ElasticSearchService elasticSearchService = injector.instanceOf(ElasticSearchService.clreplaced);
    String elasticSearchIndex = indexerConfig.getString("elasticSearchIndex");
    Configuration settingConfig = indexerConfig.getConfig("elasticSearchSetting");
    if (!elasticSearchService.existsIndex(elasticSearchIndex).isExists()) {
        elasticSearchService.createIndex(elasticSearchIndex, settingConfig);
    }
    Configuration mappingConfig = indexerConfig.getConfig("elasticSearchMapping");
    for (String typeName : mappingConfig.subKeys()) {
        if (!elasticSearchService.existsType(elasticSearchIndex, typeName).isExists()) {
            elasticSearchService.putMapping(elasticSearchIndex, typeName, mappingConfig.getConfig(typeName));
        }
    }
    return new ESBasedIndexerConfig(indexerConfig.getConfig(ConfigKey.ENreplacedY_DAOS_CONFIG.get()), elasticSearchIndex, indexerConfig.getString("indexTypeKey"), indexerConfig.getString("indexType"), indexerConfig.getStringList("uniqueFields"), injector, indexerConfig.getString("daoConfigKey"), indexerConfig);
}

19 Source : ESBasedIndexerConfig.java
with MIT License
from grouplens

public Indexer getIndexer(RequestContext requestContext) {
    ElasticSearchService elasticSearchService = injector.instanceOf(ElasticSearchService.clreplaced);
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    return new ESBasedIndexer(elasticSearchService, configService, daoConfigs, elasticSearchIndex, indexTypeKey, indexType, uniqueFields, injector, daoConfigKey, config, 128, requestContext);
}

19 Source : CSVFileIndexerConfig.java
with MIT License
from grouplens

public Indexer getIndexer(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    FileWriterService dataService = injector.instanceOf(FileWriterService.clreplaced);
    return new CSVFileIndexer(configService, dataService, config, injector, daoConfigs, daoConfigKey, timestampField, dataFields, beginTime, beginTimeKey, endTime, endTimeKey, daoName, daoNameKey, filesKey, separatorKey, indexType, subDaoName, subDaoConfigKey, 128, requestContext);
}

19 Source : CatIndexerConfig.java
with MIT License
from grouplens

public Indexer getIndexer(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    return new CatIndexer(configService, config, injector, daoConfigs, daoConfigKey, indexersDaoConfigKey, indexerNames, daoName, daoNameKey, 128, requestContext);
}

19 Source : AggregateIndexerConfig.java
with MIT License
from grouplens

public Indexer getIndexer(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    GroupedIndexer indexer = (GroupedIndexer) configService.getIndexer(indexerName, requestContext);
    return new AggregateIndexer(configService, config, injector, daoConfigs, daoConfigKey, filePathKey, otherFields, separator, daoNameKey, daoName, filesKey, groupKeys, filePath, separatorKey, indexer, aggFields, aggCntName, aggSumAppendix, 128, requestContext);
}

19 Source : SVDFeatureFactorExtractorConfig.java
with MIT License
from grouplens

public FeatureExtractor getFeatureExtractor(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    ModelService modelService = injector.instanceOf(ModelService.clreplaced);
    configService.getPredictor(predictorName, requestContext);
    SVDFeature model = (SVDFeature) modelService.getModel(requestContext.getEngineName(), modelName);
    return new SVDFeatureFactorExtractor(model, fea2svdfeas, sparse, indexName);
}

19 Source : PredictorBasedExtractorConfig.java
with MIT License
from grouplens

public FeatureExtractor getFeatureExtractor(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    Predictor predictor = configService.getPredictor(predictorName, requestContext);
    return new PredictorBasedExtractor(predictor, requestContext, feaName, indexName);
}

19 Source : DecisionTreeLeafExtractorConfig.java
with MIT License
from grouplens

public FeatureExtractor getFeatureExtractor(RequestContext requestContext) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    ModelService modelService = injector.instanceOf(ModelService.clreplaced);
    configService.getPredictor(predictorName, requestContext);
    DecisionTree decisionTree = (DecisionTree) modelService.getModel(requestContext.getEngineName(), modelName);
    return new DecisionTreeLeafExtractor(decisionTree, feaName, indexName, requestContext);
}

19 Source : RetrieverBasedItemFilterExpander.java
with MIT License
from grouplens

public static EnreplacedyExpander getExpander(Configuration expanderConfig, Injector injector, RequestContext requestContext) {
    String retrieverName = expanderConfig.getString("retrieverName");
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    Retriever retriever = configService.getRetriever(retrieverName, requestContext);
    boolean exclude = true;
    if (expanderConfig.asMap().containsKey("exclude")) {
        exclude = expanderConfig.getBoolean("exclude");
    }
    return new RetrieverBasedItemFilterExpander(retriever, expanderConfig.getStringList("itemAttrs"), exclude);
}

19 Source : RetrieverBasedExpander.java
with MIT License
from grouplens

public static EnreplacedyExpander getExpander(Configuration expanderConfig, Injector injector, RequestContext requestContext) {
    String retrieverName = expanderConfig.getString("retrieverName");
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    Retriever retriever = configService.getRetriever(retrieverName, requestContext);
    return new RetrieverBasedExpander(retriever);
}

19 Source : PredictorBasedExpander.java
with MIT License
from grouplens

public static EnreplacedyExpander getExpander(Configuration expanderConfig, Injector injector, RequestContext requestContext) {
    String predictorName = expanderConfig.getString("predictorName");
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    Predictor predictor = configService.getPredictor(predictorName, requestContext);
    String joiner = expanderConfig.getString("joiner");
    if (joiner == null) {
        joiner = ",";
    }
    return new PredictorBasedExpander(predictor, expanderConfig.getString("scoreAttr"), expanderConfig.getString("scoresAttr"), joiner);
}

19 Source : RecommendationEvaluatorConfig.java
with MIT License
from grouplens

public Evaluator getEvaluator(RequestContext requestContext) {
    JsonNode reqBody = requestContext.getRequestBody();
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    String recName = JsonHelpers.getOptionalString(reqBody, recommenderNameKey, recommenderName);
    Recommender recommender = configService.getRecommender(recName, requestContext);
    List<Metric> metrics = new ArrayList<>(metricConfigs.size());
    for (MetricConfig metricConfig : metricConfigs) {
        metrics.add(metricConfig.getMetric(requestContext));
    }
    List<Indexer> indexers = new ArrayList<>(indexerNames.size());
    for (String indexerName : indexerNames) {
        indexers.add(configService.getIndexer(indexerName, requestContext));
    }
    List<Indexer> recIndexers = new ArrayList<>(recIndexerNames.size());
    for (String indexerName : recIndexerNames) {
        recIndexers.add(configService.getIndexer(indexerName, requestContext));
    }
    EnreplacedyDAO enreplacedyDao = EnreplacedyDAOUtilities.getEnreplacedyDAO(daoConfigs, requestContext, reqBody.get(daoConfigKey), injector);
    List<EnreplacedyExpander> enreplacedyExpanders = ExpanderUtilities.getEnreplacedyExpanders(requestContext, expandersConfig, injector);
    return new RecommendationEvaluator(recommender, enreplacedyDao, enreplacedyExpanders, groupKeys, itemKeys, metrics, indexers, recIndexers);
}

19 Source : PredictionEvaluatorConfig.java
with MIT License
from grouplens

public Evaluator getEvaluator(RequestContext requestContext) {
    JsonNode reqBody = requestContext.getRequestBody();
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    String predName = JsonHelpers.getOptionalString(reqBody, predictorNameKey, predictorName);
    Predictor predictor = configService.getPredictor(predName, requestContext);
    List<Metric> metrics = new ArrayList<>(metricConfigs.size());
    for (MetricConfig metricConfig : metricConfigs) {
        metrics.add(metricConfig.getMetric(requestContext));
    }
    List<Indexer> indexers = new ArrayList<>(indexerNames.size());
    for (String indexerName : indexerNames) {
        indexers.add(configService.getIndexer(indexerName, requestContext));
    }
    List<Indexer> predIndexers = new ArrayList<>(predIndexerNames.size());
    for (String indexerName : predIndexerNames) {
        predIndexers.add(configService.getIndexer(indexerName, requestContext));
    }
    EnreplacedyDAO enreplacedyDao = EnreplacedyDAOUtilities.getEnreplacedyDAO(daoConfigs, requestContext, reqBody.get(daoConfigKey), injector);
    List<EnreplacedyExpander> enreplacedyExpanders = ExpanderUtilities.getEnreplacedyExpanders(requestContext, expandersConfig, injector);
    return new PredictionEvaluator(predictor, enreplacedyDao, enreplacedyExpanders, groupKeys, metrics, indexers, predIndexers, labelAttr, separator);
}

19 Source : SQLBasedDAOConfig.java
with MIT License
from grouplens

public EnreplacedyDAO getEnreplacedyDAO(RequestContext requestContext, JsonNode daoConfig) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    ObjectNode req = Json.newObject();
    IOUtilities.parseEnreplacedyFromJsonNode(daoConfig, req);
    String retrieverName = JsonHelpers.getOptionalString(daoConfig, retrieverNameKey, this.retrieverName);
    req.put(setCursorKey, true);
    RequestContext pseudoReq = new RequestContext(req, requestContext.getEngineName());
    Retriever retriever = configService.getRetriever(retrieverName, pseudoReq);
    if (!(retriever instanceof SQLBasedRetriever)) {
        throw new ConfigurationException(retrieverName + " must be of type " + SQLBasedRetriever.clreplaced);
    }
    return new RetrieverBasedDAO(retrieverName, configService, pseudoReq);
}

19 Source : IndexerBasedDAOConfig.java
with MIT License
from grouplens

public EnreplacedyDAO getEnreplacedyDAO(RequestContext requestContext, JsonNode reqDao) {
    String indexer = JsonHelpers.getOptionalString(reqDao, indexerKey, indexerName);
    JsonNode reqBody = JsonHelpers.getRequiredJson(reqDao, indexerReqKey);
    RequestContext pseudoReq = new RequestContext(reqBody, requestContext.getEngineName());
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    return new IndexerBasedDAO(configService.getIndexer(indexer, pseudoReq), pseudoReq);
}

19 Source : ESBasedDAOConfig.java
with MIT License
from grouplens

public EnreplacedyDAO getEnreplacedyDAO(RequestContext requestContext, JsonNode daoConfig) {
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    ObjectNode req = Json.newObject();
    IOUtilities.parseEnreplacedyFromJsonNode(daoConfig, req);
    String retrieverName = JsonHelpers.getOptionalString(daoConfig, retrieverNameKey, this.retrieverName);
    req.put(setScrollKey, true);
    RequestContext pseudoReq = new RequestContext(req, requestContext.getEngineName());
    Retriever retriever = configService.getRetriever(retrieverName, pseudoReq);
    if (!(retriever instanceof ESQueryBasedRetriever)) {
        throw new ConfigurationException(retrieverName + " must be of type " + ESQueryBasedRetriever.clreplaced);
    }
    return new RetrieverBasedDAO(retrieverName, configService, pseudoReq);
}

19 Source : ServerGlobal.java
with MIT License
from grouplens

public void beforeStart(Application application) {
    Injector injector = application.injector();
    Configuration configuration = application.configuration();
    SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.clreplaced);
    List<String> enabledEngines = configuration.getStringList(ConfigKey.ENGINES_ENABLED.get());
    Configuration samanthaConfig = configuration.getConfig(ConfigKey.SAMANTHA_BASE.get());
    for (String engine : enabledEngines) {
        Configuration engineConfig = samanthaConfig.getConfig(engine);
        List<String> schedulerNames = engineConfig.getStringList(ConfigKey.ENGINE_BEFORE_START_SCHEDULERS.get());
        if (schedulerNames != null) {
            for (String scheduler : schedulerNames) {
                RequestContext peudoReq = new RequestContext(Json.newObject(), engine);
                configService.getSchedulerConfig(scheduler, peudoReq).runJobs();
            }
        }
    }
}

19 Source : AbstractModelManager.java
with MIT License
from grouplens

public Object resetModel(RequestContext requestContext) {
    ModelService modelService = injector.instanceOf(ModelService.clreplaced);
    Object model = createModel(requestContext, SpaceMode.DEFAULT);
    modelService.setModel(requestContext.getEngineName(), modelName, model);
    return model;
}

See More Examples