@Override public Label deserialize(JsonParser parser, DeserializationContext context) throws IOException { return Label.valueOf(parser.getText()); } }
/** * Get the bucket based on experiment id and bucket label * * @param experimentID * @param bucketLabel * @return */ protected String getBucketPayload(Experiment.ID experimentID, String bucketLabel) { if (isNull(bucketLabel) || bucketLabel.trim().isEmpty()) { return null; } Optional<Bucket> rBucket = getBucketByLabel(experimentID, Bucket.Label.valueOf(bucketLabel)); String payload = null; if (rBucket.isPresent()) { payload = rBucket.get().getPayload(); } return payload; }
@Override public Label deserialize(JsonParser parser, DeserializationContext context) throws IOException { return Label.valueOf(parser.getText()); } }
Bucket.Label bucketLabel = Bucket.Label.valueOf((String) rollupRow.get("bid"));
bucketLabelString = auditLog.getBucketLabel(); if (!StringUtils.isBlank(bucketLabelString)) bucketLabel = Bucket.Label.valueOf(bucketLabelString); } catch (Exception e) { LOGGER.warn("Exception while creating audit log bucket label: "
submittedLabel = submittedAssignment != null ? Label.valueOf(submittedAssignment) : null; } else { throw new IllegalArgumentException("Request entity JSON must contain an \"assignment\" property");
.withBucketLabel("null".equals(bucketLabel) ? null : Bucket.Label.valueOf(bucketLabel)) .withBucketEmpty(isBucketEmpty) .withPayload(getBucketPayload(experimentID, bucketLabel))
BucketCounts bucket = buckets.get(Bucket.Label.valueOf((String) rollupRow.get("bid")));
for (com.intuit.wasabi.repository.cassandra.pojo.count.BucketAssignmentCount bucketAssignmentCount : result) { final Bucket.Label label = isNull(bucketAssignmentCount.getBucketLabel()) ? NULL_LABEL : Bucket.Label.valueOf(bucketAssignmentCount.getBucketLabel()); totalAssignments += bucketAssignmentCount.getCount(); final BucketAssignmentCount.Builder builder = new BucketAssignmentCount.Builder()
Map bucketMap = (Map) bucket; Bucket.Label label = Bucket.Label.valueOf( (String) bucketMap.get("label")); Bucket returnBuck = Bucket.newInstance(experimentID, label)
BucketCounts bucket = buckets.get(Bucket.Label.valueOf((String) actionRow.get("bid"))); Event.Name actionName = Event.Name.valueOf((String) actionRow.get(ACTION)); bucket.addActionCounts(actionName, new ActionCounts.Builder() BucketCounts bucket = buckets.get(Bucket.Label.valueOf((String) impressionRow.get("bid"))); BucketCounts bucket = buckets.get(Bucket.Label.valueOf((String) jointActionsRow.get("bid")));
@Override public Map<Bucket.Label, BucketCounts> getEmptyBuckets(Experiment.ID experimentID) throws RepositoryException { try { List<Map> bucketRows = transaction.select("select label from bucket where experiment_id=?", experimentID); Counts impressions = new Counts.Builder().withEventCount(0).withUniqueUserCount(0).build(); Counts jointActions = new Counts.Builder().withEventCount(0).withUniqueUserCount(0).build(); Map<Event.Name, ActionCounts> perDayBucketActions = new HashMap<>(); BucketCounts blankBucket = new BucketCounts.Builder().withImpressionCounts(impressions) .withJointActionCounts(jointActions) .withActionCounts(perDayBucketActions).build(); Map<Bucket.Label, BucketCounts> buckets = new HashMap<>(); for (Map bucketRow : bucketRows) { Bucket.Label externalLabel = Bucket.Label.valueOf((String) bucketRow.get("label")); BucketCounts bucket = blankBucket.clone(); bucket.setLabel(externalLabel); buckets.put(externalLabel, bucket); } return buckets; } catch (Exception e) { throw new RepositoryException("error reading actions rows from MySQL", e); } }
@Override @Timed public Assignment getAssignment(User.ID userID, Application.Name appName, Experiment.ID experimentID, Context context) { ListenableFuture<Result<ExperimentUserByUserIdContextAppNameExperimentId>> resultFuture = experimentUserIndexAccessor.asyncSelectBy(userID.toString(), appName.toString(), experimentID.getRawID(), context.toString()); Result<ExperimentUserByUserIdContextAppNameExperimentId> assignmentResult = UninterruptibleUtil.getUninterruptibly(resultFuture); Stream<ExperimentUserByUserIdContextAppNameExperimentId> assignmentResultStream = StreamSupport.stream(Spliterators.spliteratorUnknownSize(assignmentResult.iterator(), Spliterator.ORDERED), false); final Stream<Assignment.Builder> assignmentBuilderStream = assignmentResultStream.map(t -> { Assignment.Builder builder = Assignment.newInstance(Experiment.ID.valueOf(t.getExperimentId())) .withUserID(User.ID.valueOf(t.getUserId())) .withContext(Context.valueOf(t.getContext())); if (nonNull(t.getBucket()) && !t.getBucket().trim().isEmpty()) { builder.withBucketLabel(Bucket.Label.valueOf(t.getBucket())); } return builder; }); Optional<Assignment> assignmentOptional = getAssignmentFromStream(experimentID, userID, context, assignmentBuilderStream); return assignmentOptional.isPresent() ? assignmentOptional.get() : null; }
public static Bucket makeBucket( com.intuit.wasabi.repository.cassandra.pojo.Bucket bucketPojo) { Bucket bucket = Bucket.newInstance(Experiment.ID.valueOf(bucketPojo.getExperimentId()), Bucket.Label.valueOf(bucketPojo.getLabel())) .withAllocationPercent(bucketPojo.getAllocation()) .withControl(bucketPojo.isControl()) .withDescription(bucketPojo.getDescription()) .withPayload(bucketPojo.getPayload()) .withState(Bucket.State.valueOf(bucketPojo.getState())) .build(); return bucket; }