org.jooq.lambda.tuple.Tuple2 Java Examples
The following examples show how to use
org.jooq.lambda.tuple.Tuple2.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BinomialNonRedundancyReranker.java From RankSys with Mozilla Public License 2.0 | 6 votes |
@Override protected double nov(Tuple2od<I> itemValue) { Set<F> itemFeatures = featureData.getItemFeatures(itemValue.v1) .map(Tuple2::v1) .collect(Collectors.toCollection(HashSet::new)); double iNonRed = featureCount.keySet().stream() .mapToDouble(f -> { if (itemFeatures.contains(f)) { return patienceLater.getDouble(f); } else { return patienceNow.getDouble(f); } }).reduce((x, y) -> x * y).orElse(1.0); int m = featureCount.size() + (int) itemFeatures.stream() .filter(f -> !featureCount.containsKey(f)) .count(); iNonRed = Math.pow(iNonRed, 1 / (double) m); return iNonRed; }
Example #2
Source File: SRecall.java From RankSys with Mozilla Public License 2.0 | 6 votes |
/** * Returns a score for the recommendation list. * * @param recommendation recommendation list * @return score of the metric to the recommendation */ @Override public double evaluate(Recommendation<U, I> recommendation) { RelevanceModel.UserRelevanceModel<U, I> userRelModel = relModel.getModel(recommendation.getUser()); Set<F> subtopics = new HashSet<>(); int rank = 0; for (Tuple2od<I> iv : recommendation.getItems()) { if (userRelModel.isRelevant(iv.v1)) { subtopics.addAll(featureData.getItemFeatures(iv.v1) .map(Tuple2::v1) .collect(toList())); } rank++; if (rank >= cutoff) { break; } } return subtopics.size() / (double) featureData.numFeatures(); }
Example #3
Source File: PM.java From RankSys with Mozilla Public License 2.0 | 6 votes |
@Override protected void update(Tuple2od<I> biv) { double norm = featureData.getItemFeatures(biv.v1) .map(Tuple2::v1) .mapToDouble(f -> biv.v2 / probNorm.getDouble(f)) .sum(); featureData.getItemFeatures(biv.v1).sequential() .map(Tuple2::v1) .forEach(f -> { double v = biv.v2 / (probNorm.getDouble(f) * norm); featureCount.addTo(f, v); }); lcf = getLcf(); }
Example #4
Source File: AssetCostDao.java From waltz with Apache License 2.0 | 6 votes |
public List<Tuple2<Long, BigDecimal>> calculateCombinedAmountsForSelector(int year, Select<Record1<Long>> appIdSelector) { checkNotNull(appIdSelector, "appIdSelector cannot be null"); Field<BigDecimal> totalAmount = DSL.sum(ASSET_COST.AMOUNT).as("total_amount"); Condition condition = ASSET_COST.YEAR.eq(year) .and(APPLICATION.ID.in(appIdSelector)); return dsl.select(APPLICATION.ID, totalAmount) .from(ASSET_COST) .innerJoin(APPLICATION) .on(APPLICATION.ASSET_CODE.eq(ASSET_COST.ASSET_CODE)) .where(dsl.renderInlined(condition)) .groupBy(APPLICATION.ID) .fetch(r -> Tuple.tuple(r.value1(), r.value2())); }
Example #5
Source File: MeasurableRatingPlannedDecommissionDao.java From waltz with Apache License 2.0 | 6 votes |
public Tuple2<Operation, Boolean> save(EntityReference entityReference, long measurableId, DateFieldChange dateChange, String userName) { MeasurableRatingPlannedDecommissionRecord existingRecord = dsl .selectFrom(MEASURABLE_RATING_PLANNED_DECOMMISSION) .where(mkRefCondition(entityReference) .and(MEASURABLE_RATING_PLANNED_DECOMMISSION.MEASURABLE_ID.eq(measurableId))) .fetchOne(); if (existingRecord != null) { updateDecommDateOnRecord(existingRecord, dateChange, userName); boolean updatedRecord = existingRecord.update() == 1; return Tuple.tuple(Operation.UPDATE, updatedRecord); } else { MeasurableRatingPlannedDecommissionRecord record = dsl.newRecord(MEASURABLE_RATING_PLANNED_DECOMMISSION); updateDecommDateOnRecord(record, dateChange, userName); record.setCreatedAt(DateTimeUtilities.nowUtcTimestamp()); record.setCreatedBy(userName); record.setEntityId(entityReference.id()); record.setEntityKind(entityReference.kind().name()); record.setMeasurableId(measurableId); boolean recordsInserted = record.insert() == 1; return Tuple.tuple(Operation.ADD, recordsInserted); } }
Example #6
Source File: DatabaseInformationDao.java From waltz with Apache License 2.0 | 6 votes |
public Map<Long, List<DatabaseInformation>> findByAppSelector(Select<Record1<Long>> appIdSelector) { return dsl .select(ENTITY_RELATIONSHIP.ID_A, ENTITY_RELATIONSHIP.KIND_A) .select(DATABASE_INFORMATION.fields()) .from(DATABASE_INFORMATION) .innerJoin(APPLICATION) .on(APPLICATION.ASSET_CODE.eq(DATABASE_INFORMATION.ASSET_CODE)) .where(APPLICATION.ID.in(appIdSelector)) .fetch() .stream() .map(r -> tuple( r.getValue(ENTITY_RELATIONSHIP.ID_A), DATABASE_RECORD_MAPPER.map(r))) .collect(groupingBy( Tuple2::v1, mapping(Tuple2::v2, Collectors.toList()) )); }
Example #7
Source File: ChangeLogService.java From waltz with Apache License 2.0 | 6 votes |
private Tuple2<String, Set<EntityReference>> preparePreambleAndEntitiesForChangeLogs(MeasurableRatingPlannedDecommission measurableRatingPlannedDecommission) { Set<MeasurableRatingReplacement> replacements = measurableRatingReplacementdao.fetchByDecommissionId(measurableRatingPlannedDecommission.id()); String measurableName = resolveName(measurableRatingPlannedDecommission.measurableId(), MEASURABLE); EntityReference entityReference = measurableRatingPlannedDecommission.entityReference(); String entityName = resolveName(entityReference.id(), entityReference.kind()); String messagePreamble = format( "Measurable Rating: %s [%d] on: %s [%s]", measurableName, measurableRatingPlannedDecommission.measurableId(), entityName, getExternalId(entityReference).orElse(String.valueOf(entityReference.id()))); return tuple( messagePreamble, union(map(replacements, MeasurableRatingReplacement::entityReference), asSet(entityReference))); }
Example #8
Source File: ChangeLogService.java From waltz with Apache License 2.0 | 6 votes |
private Tuple2<String, Set<EntityReference>> preparePreambleAndEntitiesForChangeLogs(MeasurableRatingReplacement measurableRatingReplacement) { MeasurableRatingPlannedDecommission plannedDecommission = measurableRatingPlannedDecommissionDao.getById(measurableRatingReplacement.decommissionId()); String measurableName = resolveName(plannedDecommission.measurableId(), MEASURABLE); String originalEntityName = resolveName(plannedDecommission.entityReference().id(), plannedDecommission.entityReference().kind()); String newEntityName = resolveName(measurableRatingReplacement.entityReference().id(), measurableRatingReplacement.entityReference().kind()); String messagePreamble = format( "Replacement %s: %s [%d], for measurable: %s [%d] on: %s [%d]", measurableRatingReplacement.entityReference().kind().name().toLowerCase(), newEntityName, measurableRatingReplacement.entityReference().id(), measurableName, plannedDecommission.measurableId(), originalEntityName, plannedDecommission.entityReference().id()); return tuple( messagePreamble, asSet(measurableRatingReplacement.entityReference(), plannedDecommission.entityReference())); }
Example #9
Source File: ChangeLogService.java From waltz with Apache License 2.0 | 6 votes |
private Tuple2<String, Set<EntityReference>> preparePreambleAndEntitiesForChangeLogs(PhysicalFlow physicalFlow) { LogicalFlow logicalFlow = logicalFlowDao.getByFlowId(physicalFlow.logicalFlowId()); PhysicalSpecification specification = physicalSpecificationDao.getById(physicalFlow.specificationId()); String messagePreamble = format( "Physical flow: %s, from: %s, to: %s", specification.name(), safeName(logicalFlow.source()), safeName(logicalFlow.target())); return tuple( messagePreamble, asSet( physicalFlow.entityReference(), logicalFlow.entityReference(), logicalFlow.source(), logicalFlow.target())); }
Example #10
Source File: LogicalFlowStressGenerator.java From waltz with Apache License 2.0 | 6 votes |
private void generateFlows() { List<Long> appIds = getActiveAppIds(dsl); Set<Tuple2<Long, Long>> existingFlows = lfDao .findByEntityReference(EntityReference.mkRef(EntityKind.APPLICATION, appId)) .stream() .map(lf -> tuple(lf.source().id(), lf.target().id())) .collect(toSet()); Set<LogicalFlowRecord> flows = randomPick(appIds, HOW_MANY_FLOWS) .stream() .filter(cId -> cId != appId) // don't create self flows .map(cId -> cId % 2 == 0 ? tuple(appId, cId) : tuple(cId, appId)) .filter(t -> ! existingFlows.contains(t)) .map(t -> mkLogicalFlowRecord(t.v1, t.v2, PROVENANCE)) .collect(toSet()); dsl.batchInsert(flows).execute(); }
Example #11
Source File: MeasurableRatingPlannedDecommissionService.java From waltz with Apache License 2.0 | 5 votes |
public MeasurableRatingPlannedDecommission save(EntityReference entityReference, long measurableId, DateFieldChange dateChange, String userName) { Tuple2<Operation, Boolean> operation = measurableRatingPlannedDecommissionDao.save( entityReference, measurableId, dateChange, userName); if (!operation.v2) { throw new UpdateFailedException( "DECOM_DATE_SAVE_FAILED", format("Failed to store date change for entity %s:%d and measurable %d", entityReference.kind(), entityReference.id(), measurableId)); } else { MeasurableRatingPlannedDecommission plannedDecommission = measurableRatingPlannedDecommissionDao.getByEntityAndMeasurable(entityReference, measurableId); changeLogService.writeChangeLogEntries( plannedDecommission, userName, format("%s planned decommission date: %s", operation.v1.equals(Operation.ADD) ? "Added" : "Updated", plannedDecommission.plannedDecommissionDate()), operation.v1); return plannedDecommission; } }
Example #12
Source File: LogicalFlowDao.java From waltz with Apache License 2.0 | 5 votes |
public List<LogicalFlow> addFlows(List<LogicalFlow> flows, String user) { Condition condition = flows .stream() .map(t -> isSourceCondition(t.source()) .and(isTargetCondition(t.target())) .and(LOGICAL_FLOW.ENTITY_LIFECYCLE_STATUS.eq(REMOVED.name()) .or(LOGICAL_FLOW.IS_REMOVED))) .reduce((a, b) -> a.or(b)) .get(); List<LogicalFlow> removedFlows = baseQuery() .where(condition) .fetch(TO_DOMAIN_MAPPER); if(removedFlows.size() > 0) { restoreFlows(removedFlows, user); } Map<Tuple2<EntityReference, EntityReference>, LogicalFlow> existing = removedFlows .stream() .collect(Collectors.toMap(f -> Tuple.tuple(f.source(), f.target()), f -> f)); List<LogicalFlow> addedFlows = flows .stream() .filter(f -> !existing.containsKey(Tuple.tuple(f.source(), f.target()))) .map(f -> { LogicalFlowRecord record = TO_RECORD_MAPPER.apply(f, dsl); record.store(); return ImmutableLogicalFlow .copyOf(f) .withId(record.getId()); }) .collect(toList()); addedFlows.addAll(removedFlows); return addedFlows; }
Example #13
Source File: SimpleFeatureData.java From RankSys with Mozilla Public License 2.0 | 5 votes |
/** * Loads an instance of the class from a stream of triples. * * @param <I> type of item * @param <F> type of feat * @param <V> type of value * @param tuples stream of item-feat-value triples * @return a feature data object */ public static <I, F, V> SimpleFeatureData<I, F, V> load(Stream<Tuple3<I, F, V>> tuples) { Map<I, List<Tuple2<F, V>>> itemMap = new HashMap<>(); Map<F, List<Tuple2<I, V>>> featMap = new HashMap<>(); tuples.forEach(t -> { itemMap.computeIfAbsent(t.v1, v1 -> new ArrayList<>()).add(tuple(t.v2, t.v3)); featMap.computeIfAbsent(t.v2, v2 -> new ArrayList<>()).add(tuple(t.v1, t.v3)); }); return new SimpleFeatureData<>(itemMap, featMap); }
Example #14
Source File: MeasurableRatingReplacementDao.java From waltz with Apache License 2.0 | 5 votes |
public Tuple2<Operation, Boolean> save(long decommId, EntityReference entityReference, LocalDate commissionDate, String username) { Condition condition = MEASURABLE_RATING_REPLACEMENT.DECOMMISSION_ID.eq(decommId) .and(MEASURABLE_RATING_REPLACEMENT.ENTITY_ID.eq(entityReference.id()) .and(MEASURABLE_RATING_REPLACEMENT.ENTITY_KIND.eq(entityReference.kind().name()))); boolean isUpdate = dsl.fetchExists(DSL .selectFrom(MEASURABLE_RATING_REPLACEMENT) .where(condition)); if (isUpdate) { boolean recordsUpdated = dsl .update(MEASURABLE_RATING_REPLACEMENT) .set(MEASURABLE_RATING_REPLACEMENT.PLANNED_COMMISSION_DATE, toSqlDate(commissionDate)) .set(MEASURABLE_RATING_REPLACEMENT.UPDATED_BY, username) .set(MEASURABLE_RATING_REPLACEMENT.UPDATED_AT, DateTimeUtilities.nowUtcTimestamp()) .execute() == 1; return tuple(Operation.UPDATE, recordsUpdated); } else { MeasurableRatingReplacementRecord replacementRecord = dsl.newRecord(MEASURABLE_RATING_REPLACEMENT); replacementRecord.setDecommissionId(decommId); replacementRecord.setEntityId(entityReference.id()); replacementRecord.setEntityKind(entityReference.kind().name()); replacementRecord.setCreatedAt(DateTimeUtilities.nowUtcTimestamp()); replacementRecord.setCreatedBy(username); replacementRecord.setUpdatedAt(DateTimeUtilities.nowUtcTimestamp()); replacementRecord.setUpdatedBy(username); replacementRecord.setPlannedCommissionDate(toSqlDate(commissionDate)); boolean recordsInserted = replacementRecord.insert() == 1; return tuple(Operation.ADD, recordsInserted); } }
Example #15
Source File: AlphaNDCG.java From RankSys with Mozilla Public License 2.0 | 5 votes |
private double idcg(UserIdealRelevanceModel<U, I> urm) { double ideal = 0; Object2IntOpenHashMap<F> redundancy = new Object2IntOpenHashMap<>(); redundancy.defaultReturnValue(0); Set<I> candidates = new HashSet<>(urm.getRelevantItems()); int rank = 0; while (rank <= cutoff && !candidates.isEmpty()) { I bi = null; double bg = Double.NEGATIVE_INFINITY; for (I i : candidates) { double gain = featureData.getItemFeatures(i) .map(Tuple2::v1) .mapToDouble(f -> Math.pow(1 - alpha, redundancy.getInt(f))) .sum(); if (gain > bg) { bg = gain; bi = i; } } candidates.remove(bi); featureData.getItemFeatures(bi).sequential() .map(Tuple2::v1) .forEach(f -> redundancy.addTo(f, 1)); ideal += bg * disc.disc(rank); rank++; } return ideal; }
Example #16
Source File: RandomUtilities.java From waltz with Apache License 2.0 | 5 votes |
public static <T> Tuple2<T, List<T>> pickAndRemove(List<T> xs) { checkNotEmpty(xs, "xs cannot be empty"); int idx = rnd.nextInt(xs.size()); T pick = xs.get(idx); List<T> remainder = new ArrayList<>(); for (int i = 0; i < xs.size(); i++) { if (i == idx) continue; else remainder.add(xs.get(i)); } return tuple(pick, remainder); }
Example #17
Source File: RandomUtilities_pickAndRemove.java From waltz with Apache License 2.0 | 5 votes |
@Test public void pickFromMultiValuedListReturnsElementAndListWithoutThatElement() { Tuple2<String, List<String>> r = pickAndRemove(asList("a", "b")); String picked = r.v1; Collection<String> remainder = r.v2; assertTrue(picked.equals("a") || picked.equals("b")); assertFalse(remainder.isEmpty()); assertEquals(remainder.size(), 1); assertFalse(remainder.contains(picked)); }
Example #18
Source File: PM.java From RankSys with Mozilla Public License 2.0 | 5 votes |
@Override protected double value(Tuple2od<I> iv) { return featureData.getItemFeatures(iv.v1) .map(Tuple2::v1) .mapToDouble(f -> (f.equals(lcf) ? lambda : (1 - lambda)) * quotient(f) * iv.v2 / probNorm.getDouble(f)) .sum(); }
Example #19
Source File: FeatureIntentModel.java From RankSys with Mozilla Public License 2.0 | 5 votes |
private void init() { featureNorms = new Object2DoubleOpenHashMap<>(); featureData.getAllFeatures().forEach(f -> { int count = featureData.getFeatureItems(f) .map(Tuple2::v1) .mapToInt(totalData::numUsers) .sum(); featureNorms.put(f, count); }); }
Example #20
Source File: BinomialCoverageReranker.java From RankSys with Mozilla Public License 2.0 | 5 votes |
@Override protected double nov(Tuple2od<I> itemValue) { double iCoverage = featureData.getItemFeatures(itemValue.v1) .map(Tuple2::v1) .filter(uncoveredFeatures::contains) .mapToDouble(f -> ubm.longing(f, cutoff)) .reduce((x, y) -> x * y).orElse(1.0); iCoverage = Math.pow(iCoverage, 1 / (double) ubm.getFeatures().size()); iCoverage = coverage / iCoverage; return iCoverage; }
Example #21
Source File: ChangeLogService.java From waltz with Apache License 2.0 | 5 votes |
private Tuple2<String, Set<EntityReference>> preparePreambleAndEntitiesForChangeLogs(LogicalFlow logicalFlow) { String messagePreamble = format( "Logical flow from: %s, to: %s", safeName(logicalFlow.source()), safeName(logicalFlow.target())); return tuple( messagePreamble, asSet( logicalFlow.entityReference(), logicalFlow.source(), logicalFlow.target())); }
Example #22
Source File: BinomialCoverageReranker.java From RankSys with Mozilla Public License 2.0 | 5 votes |
@Override protected void update(Tuple2od<I> bestItemValue) { double iCoverage = featureData.getItemFeatures(bestItemValue.v1).sequential() .map(Tuple2::v1) .filter(uncoveredFeatures::remove) .mapToDouble(f -> ubm.longing(f, cutoff)) .reduce((x, y) -> x * y).orElse(1.0); iCoverage = Math.pow(iCoverage, 1 / (double) ubm.getFeatures().size()); coverage /= iCoverage; }
Example #23
Source File: ChangeLogService.java From waltz with Apache License 2.0 | 5 votes |
public void writeChangeLogEntries(MeasurableRatingReplacement measurableRatingReplacement, String userId, String postamble, Operation operation){ Tuple2<String, Set<EntityReference>> t = preparePreambleAndEntitiesForChangeLogs(measurableRatingReplacement); String message = format("%s: %s", t.v1, postamble); writeChangeLogEntries(t.v2, message, operation, MEASURABLE_RATING_REPLACEMENT, userId); }
Example #24
Source File: ChangeLogService.java From waltz with Apache License 2.0 | 5 votes |
public void writeChangeLogEntries(PhysicalFlow physicalFlow, String userId, String postamble, Operation operation) { Tuple2<String, Set<EntityReference>> t = preparePreambleAndEntitiesForChangeLogs(physicalFlow); String message = format("%s: %s", t.v1, postamble); writeChangeLogEntries(t.v2, message, operation, PHYSICAL_FLOW, userId); }
Example #25
Source File: MeasurableRatingReplacementService.java From waltz with Apache License 2.0 | 5 votes |
public Set<MeasurableRatingReplacement> save(long decommId, EntityReference entityReference, LocalDate commissionDate, String username) { Tuple2<Operation, Boolean> operation = measurableRatingReplacementDao.save(decommId, entityReference, commissionDate, username); MeasurableRatingReplacement measurableRatingReplacement = measurableRatingReplacementDao.fetchByDecommissionIdAndEntityRef(decommId, entityReference); MeasurableRatingPlannedDecommission plannedDecomm = measurableRatingPlannedDecommissionDao.getById(decommId); if(!operation.v2){ throw new UpdateFailedException( "REPLACEMENT_SAVE_FAILED", format("Failed to store measurable rating replacement %s:%d for entity %s:%d and measurable %d", measurableRatingReplacement.entityReference().kind(), measurableRatingReplacement.entityReference().id(), plannedDecomm.entityReference().kind(), plannedDecomm.entityReference().id(), plannedDecomm.measurableId())); } else { changeLogService.writeChangeLogEntries( measurableRatingReplacement, username, format("%s with planned commission date: %s", (operation.v1.equals(Operation.ADD) ? "Added" : "Updated"), commissionDate), operation.v1); return measurableRatingReplacementDao.fetchByDecommissionId(decommId); } }
Example #26
Source File: ArbitraryValidationTask.java From metanome-algorithms with Apache License 2.0 | 5 votes |
@Override public ValidationResult validate() { //does order have an impact on runtime? Iterable<Tuple2<Selector, Collection<int[]>>> selectors = grouper.buildSelectors(); for (Tuple2<Selector, Collection<int[]>> group : selectors) { Selector selector = group.v1(); Collection<int[]> records = group.v2(); support += validate(selector, records); if (isSupported() && allRejected()) { break; } } return collectResults(); }
Example #27
Source File: MeasurableStressGenerator.java From waltz with Apache License 2.0 | 5 votes |
private static List<Tuple2<String, String>> mkNodes(int level, String path) { List<Tuple2<String, String>> ts = new ArrayList<>(); int siblingCount = rnd.nextInt(2) + 4; for (int i = 1; i <= level; i++) { String id = path + (level > 1 ? "." : "") + i; ts.add(tuple(id,path)); if (level < 8) { // 7 == ~5K, 8 = 46K ts.addAll(mkNodes(level + 1, id)); } } return ts; }
Example #28
Source File: ChangeInitiativeGenerator.java From waltz with Apache License 2.0 | 5 votes |
private static Stream<TableRecord<?>> buildEntityRelationships(EntityKind kind, String relKind, List<Long> ciIds, List<Long> targetIds, double ratioWithCi, int maxLinks) { List<Tuple2<Long, Long>> targetAndCiIds = targetIds .stream() .flatMap(targetId -> RND.nextDouble() <= ratioWithCi ? randomPick(ciIds, RND.nextInt(maxLinks)) .stream() .map(ciId -> tuple(targetId, ciId)) : Stream.empty()) .distinct() .collect(toList()); LOG.info("Creating {} records for relationship kind: {}", targetAndCiIds.size(), kind); return targetAndCiIds .stream() .map(t -> { EntityRelationshipRecord record = new EntityRelationshipRecord(); record.setKindA(kind.name()); record.setIdA(t.v1); record.setKindB(EntityKind.CHANGE_INITIATIVE.name()); record.setIdB(t.v2); record.setRelationship(relKind); record.setProvenance(SampleDataGenerator.SAMPLE_DATA_PROVENANCE); return record; }); }
Example #29
Source File: BulkRoleAssign.java From waltz with Apache License 2.0 | 5 votes |
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class); DSLContext dsl = ctx.getBean(DSLContext.class); UserRoleService userRoleService = ctx.getBean(UserRoleService.class); Set<String> defaultRoles = SetUtilities.asSet( SystemRole.BOOKMARK_EDITOR.name(), SystemRole.LOGICAL_DATA_FLOW_EDITOR.name(), SystemRole.LINEAGE_EDITOR.name()); Set<String> mustHaveRoles = SetUtilities.asSet( SystemRole.TAXONOMY_EDITOR.name(), SystemRole.CAPABILITY_EDITOR.name(), SystemRole.RATING_EDITOR.name()); InputStream inputStream = BulkRoleAssign.class.getClassLoader().getResourceAsStream("bulk-role-assign-example.txt"); Set<Tuple2<String, Set<String>>> updates = IOUtilities .streamLines(inputStream) .map(d -> d.toLowerCase().trim()) .map(d -> Tuple.tuple(d, userRoleService.getUserRoles(d))) .map(t -> t.map2(existingRoles -> union(existingRoles, defaultRoles, mustHaveRoles))) .collect(Collectors.toSet()); System.out.printf("About to update: %d user-role mappings\n", updates.size()); updates.forEach(t -> userRoleService.updateRoles("admin", t.v1, t.v2)); System.out.println("Finished updating mappings"); }
Example #30
Source File: BinomialModel.java From RankSys with Mozilla Public License 2.0 | 5 votes |
private Object2DoubleMap<F> getGlobalFeatureProbs() { Object2DoubleMap<F> probs = new Object2DoubleOpenHashMap<>(); probs.defaultReturnValue(0.0); int n = recommenderData.numPreferences(); featureData.getAllFeatures().sequential().forEach(f -> { int numPrefs = featureData.getFeatureItems(f) .map(Tuple2::v1) .mapToInt(recommenderData::numUsers) .sum(); probs.put(f, numPrefs / (double) n); }); return probs; }