@Test
 public void testMapRowTo3() throws Exception {
   RowReaderFactory<SampleJavaBean> rrf =
       mapRowTo(SampleJavaBean.class, Pair.of("a", "b"), Pair.of("c", "d"));
   assertThat(rrf, instanceOf(ClassBasedRowReaderFactory.class));
   assertThat(rrf.targetClass().getName(), is(SampleJavaBean.class.getName()));
 }
Пример #2
0
  /**
   * Gets a {@link Pair} of Boolean, String that represents the block comment status and the current
   * string
   *
   * @param blockComment whether there is an active block comment
   * @param string the current string
   * @return the pair of boolean and string
   */
  public Pair<Boolean, String> removeComments(boolean blockComment, String string) {
    if (blockComment) {
      int endBlock = indexOf(string, "*/", true);

      if (endBlock >= 0) {
        return removeComments(false, string.substring(endBlock + 2));
      }
      return Pair.of(true, "");
    } else {
      int startBlock = indexOf(string, "/*", true);
      int inlineBlock = indexOf(string, "//", true);

      if (startBlock < 0 && inlineBlock < 0) {
        return Pair.of(false, string);
      }

      if (startBlock >= 0 && (inlineBlock < 0 || startBlock < inlineBlock)) {
        Pair<Boolean, String> booleanStringPair =
            removeComments(true, string.substring(startBlock + 2));
        return Pair.of(
            booleanStringPair.getLeft(),
            string.substring(0, startBlock) + booleanStringPair.getRight());
      }

      if (inlineBlock >= 0 && (startBlock < 0 || inlineBlock < startBlock)) {
        return Pair.of(false, string.substring(0, inlineBlock));
      }
    }

    return null;
  }
  @SideOnly(Side.CLIENT)
  private static Pair<String, KnowledgeObject<?>> getObject(char type, String identifier) {
    KnowledgeObject<?> obj = null;
    String text = null;

    boolean isHEE = identifier.charAt(0) == '~' && identifier.length() > 1;
    if (isHEE) identifier = identifier.substring(1);

    switch (type) {
      case 'b':
      case 'i':
        int metaIndex = identifier.indexOf('/'), meta = 0;

        if (metaIndex != -1 && metaIndex + 1 < identifier.length()) {
          meta = DragonUtil.tryParse(identifier.substring(metaIndex + 1), 0);
          identifier = identifier.substring(0, metaIndex);
        }

        Item item =
            GameRegistry.findItem(isHEE ? "HardcoreEnderExpansion" : "minecraft", identifier);

        if (item != null) {
          text =
              StatCollector.translateToLocal(
                  item.getUnlocalizedName(new ItemStack(item, 1, meta)) + ".name");
          obj =
              KnowledgeObject.fromObject(
                  type == 'b'
                      ? (item instanceof ItemBlock
                          ? new BlockInfo(((ItemBlock) item).field_150939_a, meta)
                          : null)
                      : item);
        }

        break;

      case 'e':
        if (isHEE)
          text =
              ItemSpawnEggs.getMobName(
                  (Class<?>)
                      EntityList.stringToClassMapping.get(
                          identifier = ("HardcoreEnderExpansion." + identifier)));
        else text = StatCollector.translateToLocal("entity." + identifier + ".name");

        Class<?> cls = (Class<?>) EntityList.stringToClassMapping.get(identifier);
        if (cls != null) obj = KnowledgeObject.fromObject(cls);
        break;

      case 'd':
        obj = KnowledgeObject.fromObject(identifier);
        if (obj != null) text = obj.getTranslatedTooltip();
        break;
    }

    if (text == null || obj == null) {
      Log.warn("Invalid object type or identifier: $0:$1", type, identifier);
      return Pair.<String, KnowledgeObject<?>>of(text == null ? identifier : text, obj);
    } else return Pair.<String, KnowledgeObject<?>>of(text, obj);
  }
Пример #4
0
 @Override
 public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(
     TransformType cameraTransformType) {
   if (transforms.isEmpty()) return Pair.of(this, null);
   Pair<Baked, TRSRTransformation> p = transforms.get(cameraTransformType);
   return Pair.of(p.getLeft(), p.getRight().getMatrix());
 }
  @Override
  public void run(int runs) {
    try {
      Connection connection = dataSource.getConnection();
      connection.setAutoCommit(false);
      long min = Long.MAX_VALUE;
      Pair<Long, Long> total = Pair.of(0l, 0l);
      long max = Long.MIN_VALUE;
      long start, elapsed = 0;
      for (int i = 0; i < runs; i++) {
        Map<String, String> values = ImmutableMap.of("email", RandomEmail.generateEmailAddress());

        PreparedStatement insert = new Insert("emails", values).getStatement(connection);
        start = System.nanoTime();
        insert.execute();
        elapsed = (System.nanoTime() - start) / 1000;
        min = Math.min(elapsed, min);
        max = Math.max(elapsed, max);
        total = Pair.of(total.getLeft() + elapsed, total.getRight() + 1);
      }
      connection.commit();
      connection.close();
      log.info(
          "N. of Insert with deferred commit executed: {} Total Excution Time: {} us, Mean per query: {} us, Max: {} us, Min: {} us",
          total.getRight(),
          total.getLeft(),
          total.getLeft() / total.getRight(),
          max,
          min);
    } catch (Exception e) {
      log.error("An error occured while executing Insert Benchmark using manual commit", e);
    }
  }
  @Override
  public Pair<IBakedModel, Matrix4f> handlePerspective(
      ItemCameraTransforms.TransformType cameraTransformType) {
    // gui renders as 2D sprite; this is apparently also what renders when the item is dropped
    if (cameraTransformType == ItemCameraTransforms.TransformType.GUI) {
      RenderItem.applyVanillaTransform(baseModel.getItemCameraTransforms().gui);
      return Pair.of(baseModel, null);
    }

    GlStateManager.pushMatrix();
    GL11.glScalef(0.1F, 0.1F, 0.1F);
    switch (cameraTransformType) {
      case FIRST_PERSON:
        GlStateManager.translate(0.5F, 0.5F, 0.5F);
        GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(-40.0F, 0.0F, 1.0F, 0.0F);
        GlStateManager.translate(-0.75F, 1.5F, 0.5F);
        break;
      case THIRD_PERSON:
        GlStateManager.rotate(100.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(90.0F, 0F, 1.0F, 0.0F);
        GlStateManager.translate(0.3F, -0.3F, 0.2F);
        GlStateManager.scale(0.5F, 0.5F, 0.5F);
        break;
      default:
        break;
    }
    Minecraft.getMinecraft().getTextureManager().bindTexture(getTexture1());
    // first Entity parameter not used for anything in ModelLegendsSword, so null is safe
    swordModel.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0475F);
    GlStateManager.popMatrix();
    // return empty model to render nothing - bomb model already rendered
    return Pair.of(emptyModel, null);
  }
Пример #7
0
    @Override
    public Pair<? extends IFlexibleBakedModel, Matrix4f> handlePerspective(
        ItemCameraTransforms.TransformType cameraTransformType) {
      if (cameraTransformType == ItemCameraTransforms.TransformType.THIRD_PERSON)
        return Pair.of(IFlexibleBakedModel.class.cast(this), ThirdPerson);

      return Pair.of(IFlexibleBakedModel.class.cast(this), null);
    }
 @Override
 public Pair<? extends IBakedModel, Matrix4f> handlePerspective(
     TransformType cameraTransformType) {
   if (itemModel instanceof IPerspectiveAwareModel)
     return Pair.of(
         this,
         ((IPerspectiveAwareModel) itemModel).handlePerspective(cameraTransformType).getRight());
   return Pair.of(this, TRSRTransformation.identity().getMatrix());
 }
Пример #9
0
 /**
  * Validate certain tel
  *
  * @param tel tel to validate
  * @return a pair, key represents if tel is valid, value represents invalid information if invalid
  */
 public Pair<Boolean, String> validate(String tel) {
   if (StringUtils.isBlank(tel)) {
     return Pair.of(false, "电话号码不能为空");
   } else if (!tel.matches("^\\d{11}$")) {
     return Pair.of(false, "电话号码必须为11位数字");
   } else {
     return Pair.of(true, null);
   }
 }
  @Test
  public void testConvertToMap() throws Exception {
    Map<String, String> map1 = convertToMap(new Pair[0]);
    assertThat(map1.size(), is(0));

    Map<String, String> map2 = convertToMap(new Pair[] {Pair.of("one", "1"), Pair.of("two", "2")});
    assertThat(map2.size(), is(2));
    assertThat(map2.get("one"), is("1"));
    assertThat(map2.get("two"), is("2"));
  }
  public static ItemStack identifyQuality(ItemStack stack) {
    if (stack == null) return null;

    Item item = stack.getItem();
    if (item instanceof ItemGemstone) {
      if (((ItemGemstone) item).getQuality(stack) != null) return stack;
    }

    @SuppressWarnings("unchecked")
    List<Pair<ItemStack, String>> gems =
        Lists.newArrayList(
            Pair.of(ElementsOfPower.gemRuby, "gemRuby"),
            Pair.of(ElementsOfPower.gemSapphire, "gemSapphire"),
            Pair.of(ElementsOfPower.gemCitrine, "gemCitrine"),
            Pair.of(ElementsOfPower.gemAgate, "gemAgate"),
            Pair.of(ElementsOfPower.gemQuartz, "gemQuartz"),
            Pair.of(ElementsOfPower.gemSerendibite, "gemSerendibite"),
            Pair.of(ElementsOfPower.gemEmerald, "gemEmerald"),
            Pair.of(ElementsOfPower.gemAmethyst, "gemAmethyst"),
            Pair.of(ElementsOfPower.gemDiamond, "gemDiamond"));

    int[] ids = OreDictionary.getOreIDs(stack);
    Set<String> names = Sets.newHashSet();
    for (int i : ids) {
      names.add(OreDictionary.getOreName(i));
    }

    for (Pair<ItemStack, String> target : gems) {
      if (names.contains(target.getRight())) {
        return setRandomQualityVariant(target.getLeft().copy());
      }
    }

    return stack;
  }
Пример #12
0
 private SealedProduct.Template getBoosterTemplate() {
   return new SealedProduct.Template(
       ImmutableList.of(
           Pair.of(
               BoosterSlots.COMMON,
               FModel.getQuestPreferences().getPrefInt(QPref.BOOSTER_COMMONS)),
           Pair.of(
               BoosterSlots.UNCOMMON,
               FModel.getQuestPreferences().getPrefInt(QPref.BOOSTER_UNCOMMONS)),
           Pair.of(
               BoosterSlots.RARE_MYTHIC,
               FModel.getQuestPreferences().getPrefInt(QPref.BOOSTER_RARES))));
 }
Пример #13
0
    public WeightedRandomModel(ModelResourceLocation parent, Variants variants) {
      this.variants = variants.getVariants();
      ImmutableList.Builder<Pair<IModel, IModelState>> builder = ImmutableList.builder();
      for (Variant v : (List<Variant>) variants.getVariants()) {
        ResourceLocation loc = v.getModelLocation();
        locations.add(loc);

        IModel model = null;
        try {
          model = getModel(loc);
        } catch (Exception e) {
          /*
           * Vanilla eats this, which makes it only show variants that have models.
           * But that doesn't help debugging, so we maintain the missing model
           * so that resource pack makers have a hint that their states are broken.
           */
          FMLLog.warning(
              "Unable to load block model: \'"
                  + loc
                  + "\' for variant: \'"
                  + parent
                  + "\': "
                  + e.toString());
          model = getMissingModel();
        }

        if (v instanceof ISmartVariant) {
          model = ((ISmartVariant) v).process(model, ModelLoader.this);
          try {
            resolveDependencies(model);
          } catch (IOException e) {
            FMLLog.getLogger()
                .error("Exception resolving indirect dependencies for model" + loc, e);
          }
          textures.addAll(model.getTextures()); // Kick this, just in case.
        }

        models.add(model);
        builder.add(Pair.of(model, v.getState()));
      }

      if (models.size()
          == 0) // If all variants are missing, add one with the missing model and default rotation.
      {
        IModel missing = getMissingModel();
        models.add(missing);
        builder.add(Pair.<IModel, IModelState>of(missing, TRSRTransformation.identity()));
      }

      defaultState = new MultiModelState(builder.build());
    }
Пример #14
0
  /** Tests converting names from names with spaces, etc. into column names. */
  @Test
  public void testGetQueryName() {

    List<Pair<String, String>> testNames =
        Lists.newArrayList(
            Pair.of("hello", "hello"),
            Pair.of("HelLo", "hello"),
            Pair.of("Hello Kitty", "hello_kitty"),
            Pair.of(" Hello  Kitty ", "_hello__kitty_"),
            Pair.of("", ""));

    for (Pair<String, String> testCase : testNames) {
      TestCase.assertEquals(testCase.getRight(), ColumnUtil.getQueryName(testCase.getLeft()));
    }
  }
Пример #15
0
 /** Records a blob update. */
 public void recordBlob(T state, Blob blob, BaseDocument<T> doc) {
   List<Pair<T, Blob>> list = blobWriteInfosPerDoc.get(doc);
   if (list == null) {
     blobWriteInfosPerDoc.put(doc, list = new ArrayList<>());
   }
   list.add(Pair.of(state, blob));
 }
Пример #16
0
  private Pair<String, String> findChangedColNames(
      List<FieldSchema> oldColList, List<FieldSchema> newColList) {
    HashMap<FieldSchema, Integer> oldColHashMap = new HashMap<>();
    HashMap<FieldSchema, Integer> newColHashMap = new HashMap<>();
    for (int i = 0; i < oldColList.size(); i++) {
      oldColHashMap.put(oldColList.get(i), i);
      newColHashMap.put(newColList.get(i), i);
    }

    String changedColStringOldName = oldColList.get(0).getName();
    String changedColStringNewName = changedColStringOldName;

    for (int i = 0; i < oldColList.size(); i++) {
      if (!newColHashMap.containsKey(oldColList.get(i))) {
        changedColStringOldName = oldColList.get(i).getName();
        break;
      }
    }

    for (int i = 0; i < newColList.size(); i++) {
      if (!oldColHashMap.containsKey(newColList.get(i))) {
        changedColStringNewName = newColList.get(i).getName();
        break;
      }
    }

    return Pair.of(changedColStringOldName, changedColStringNewName);
  }
Пример #17
0
  /**
   * Extract the text from a HTML based string. This is similar to what HTML.fromHtml(...) does, but
   * this method also removes the embedded images instead of replacing them by a small rectangular
   * representation character.
   *
   * @param html
   * @return
   */
  public static String extractText(CharSequence html) {
    String result = html.toString();

    // recognize images in textview HTML contents
    if (html instanceof Spanned) {
      Spanned text = (Spanned) html;
      Object[] styles = text.getSpans(0, text.length(), Object.class);
      ArrayList<Pair<Integer, Integer>> removals = new ArrayList<Pair<Integer, Integer>>();
      for (Object style : styles) {
        if (style instanceof ImageSpan) {
          int start = text.getSpanStart(style);
          int end = text.getSpanEnd(style);
          removals.add(Pair.of(start, end));
        }
      }

      // sort reversed and delete image spans
      Collections.sort(
          removals,
          new Comparator<Pair<Integer, Integer>>() {

            @Override
            public int compare(Pair<Integer, Integer> lhs, Pair<Integer, Integer> rhs) {
              return rhs.getRight().compareTo(lhs.getRight());
            }
          });
      result = text.toString();
      for (Pair<Integer, Integer> removal : removals) {
        result = result.substring(0, removal.getLeft()) + result.substring(removal.getRight());
      }
    }

    // some line breaks are still in the text, source is unknown
    return StringUtils.replace(result, "<br />", "\n").trim();
  }
  @Override
  public Iterable<Entry<VocabWord, INDArray>> call(
      Iterator<Tuple2<List<VocabWord>, Long>> pairIter) {
    while (pairIter.hasNext()) {
      List<Pair<List<VocabWord>, Long>> batch = new ArrayList<>();
      while (pairIter.hasNext() && batch.size() < batchSize) {
        Tuple2<List<VocabWord>, Long> pair = pairIter.next();
        List<VocabWord> vocabWordsList = pair._1();
        Long sentenceCumSumCount = pair._2();
        batch.add(Pair.of(vocabWordsList, sentenceCumSumCount));
      }

      for (int i = 0; i < iterations; i++) {
        // System.out.println("Training sentence: " + vocabWordsList);
        for (Pair<List<VocabWord>, Long> pair : batch) {
          List<VocabWord> vocabWordsList = pair.getKey();
          Long sentenceCumSumCount = pair.getValue();
          double currentSentenceAlpha =
              Math.max(
                  minAlpha,
                  alpha - (alpha - minAlpha) * (sentenceCumSumCount / (double) totalWordCount));
          trainSentence(vocabWordsList, currentSentenceAlpha);
        }
      }
    }
    return indexSyn0VecMap.entrySet();
  }
Пример #19
0
  @Override
  public ListenableFuture<Pair<byte[], String>> signAsync(
      final byte[] digest, final String algorithm) throws NoSuchAlgorithmException {

    if (digest == null) {
      throw new IllegalArgumentException("encryptedKey ");
    }

    // Interpret the requested algorithm
    if (Strings.isNullOrWhiteSpace(algorithm)) {
      throw new IllegalArgumentException("algorithm");
    }

    // Interpret the requested algorithm
    Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithm);

    if (baseAlgorithm == null || !(baseAlgorithm instanceof AsymmetricSignatureAlgorithm)) {
      throw new NoSuchAlgorithmException(algorithm);
    }

    Rs256 algo = (Rs256) baseAlgorithm;

    ISignatureTransform signer = algo.createSignatureTransform(_keyPair);

    try {
      return Futures.immediateFuture(Pair.of(signer.sign(digest), Rs256.ALGORITHM_NAME));
    } catch (Exception e) {
      return Futures.immediateFailedFuture(e);
    }
  }
Пример #20
0
 public Pair<Integer, JsonNode> getErrorResponse() {
   Map<String, List<String>> errors =
       Collections.singletonMap(
           "errors", Collections.singletonList(getMessage() == null ? toString() : getMessage()));
   JsonNode responseBody = OBJECT_MAPPER.convertValue(errors, JsonNode.class);
   return Pair.of(getStatus(), responseBody);
 }
Пример #21
0
  public static Pair<Integer, Integer> getAnnotationProjection(
      ComponentAnnotation sourceAnno,
      ArrayListMultimap<StanfordCorenlpToken, StanfordCorenlpToken> tokenAlignment) {
    // compute aligned start and end
    int earliestStart = -1;
    int latestEnd = -1;
    boolean isFirstToken = true;
    for (StanfordCorenlpToken token :
        JCasUtil.selectCovered(StanfordCorenlpToken.class, sourceAnno)) {
      for (StanfordCorenlpToken projectedToken : tokenAlignment.get(token)) {
        if (isFirstToken) {
          earliestStart = projectedToken.getBegin();
          latestEnd = projectedToken.getEnd();
        } else {
          if (earliestStart > projectedToken.getBegin()) {
            earliestStart = projectedToken.getBegin();
          }
          if (latestEnd < projectedToken.getEnd()) {
            latestEnd = projectedToken.getEnd();
          }
        }
        isFirstToken = false;
      }
    }

    return Pair.of(earliestStart, latestEnd);
  }
Пример #22
0
  private Pair<Integer, Integer> walk(
      final Set<Coordinate> visited,
      final Coordinate[] shape1Coords,
      final Coordinate[] shape2Coords,
      final int start1,
      final int start2,
      final DirectionFactory factory) {

    final int upPos =
        takeBiggestStep(
            visited,
            shape2Coords[start2],
            shape1Coords,
            factory.createLeftFootDirection(start1, shape1Coords.length));

    // even if the left foot was stationary, try to move the right foot
    final int downPos =
        takeBiggestStep(
            visited,
            shape1Coords[upPos],
            shape2Coords,
            factory.createRightFootDirection(start2, shape2Coords.length));

    // if the right step moved, then see if another l/r step can be taken
    if (downPos != start2) {
      return walk(visited, shape1Coords, shape2Coords, upPos, downPos, factory);
    }
    return Pair.of(upPos, start2);
  }
Пример #23
0
  public static <Solution_> PartitionChangeMove<Solution_> createMove(
      InnerScoreDirector<Solution_> scoreDirector) {
    SolutionDescriptor<Solution_> solutionDescriptor = scoreDirector.getSolutionDescriptor();
    Solution_ workingSolution = scoreDirector.getWorkingSolution();

    int entityCount = solutionDescriptor.getEntityCount(workingSolution);
    Map<GenuineVariableDescriptor<Solution_>, List<Pair<Object, Object>>> changeMap =
        new LinkedHashMap<>(solutionDescriptor.getEntityDescriptors().size() * 3);
    for (EntityDescriptor<Solution_> entityDescriptor : solutionDescriptor.getEntityDescriptors()) {
      for (GenuineVariableDescriptor<Solution_> variableDescriptor :
          entityDescriptor.getDeclaredGenuineVariableDescriptors()) {
        changeMap.put(variableDescriptor, new ArrayList<>(entityCount));
      }
    }
    for (Iterator<Object> it = solutionDescriptor.extractAllEntitiesIterator(workingSolution);
        it.hasNext(); ) {
      Object entity = it.next();
      EntityDescriptor<Solution_> entityDescriptor =
          solutionDescriptor.findEntityDescriptorOrFail(entity.getClass());
      if (entityDescriptor.isMovable(scoreDirector, entity)) {
        for (GenuineVariableDescriptor<Solution_> variableDescriptor :
            entityDescriptor.getGenuineVariableDescriptors()) {
          Object value = variableDescriptor.getValue(entity);
          changeMap.get(variableDescriptor).add(Pair.of(entity, value));
        }
      }
    }
    return new PartitionChangeMove<>(changeMap);
  }
Пример #24
0
  @Override
  public int getCADStatValue(ItemStack stack, EnumCADStat stat) {
    Pair p = Pair.of(stat, stack.getItemDamage());
    if (stats.containsKey(p)) return stats.get(p);

    return 0;
  }
Пример #25
0
  @Override
  public ListenableFuture<Pair<byte[], String>> wrapKeyAsync(
      final byte[] key, final String algorithm) throws NoSuchAlgorithmException {

    if (key == null) {
      throw new IllegalArgumentException("key");
    }

    // Interpret the requested algorithm
    String algorithmName =
        (Strings.isNullOrWhiteSpace(algorithm) ? getDefaultKeyWrapAlgorithm() : algorithm);
    Algorithm baseAlgorithm = AlgorithmResolver.Default.get(algorithmName);

    if (baseAlgorithm == null || !(baseAlgorithm instanceof AsymmetricEncryptionAlgorithm)) {
      throw new NoSuchAlgorithmException(algorithmName);
    }

    AsymmetricEncryptionAlgorithm algo = (AsymmetricEncryptionAlgorithm) baseAlgorithm;

    ICryptoTransform transform;
    ListenableFuture<Pair<byte[], String>> result;

    try {
      transform = algo.CreateEncryptor(_keyPair, _provider);
      result = Futures.immediateFuture(Pair.of(transform.doFinal(key), algorithmName));
    } catch (Exception e) {
      result = Futures.immediateFailedFuture(e);
    }

    return result;
  }
 private Map<TaskId, List<Pair<TaskId, ConnectorDescriptorId>>> computeTaskConnectivity(
     JobRun jobRun, Map<ActivityId, ActivityPlan> activityPlanMap, Set<ActivityId> activities) {
   Map<TaskId, List<Pair<TaskId, ConnectorDescriptorId>>> taskConnectivity =
       new HashMap<TaskId, List<Pair<TaskId, ConnectorDescriptorId>>>();
   ActivityClusterGraph acg = jobRun.getActivityClusterGraph();
   BitSet targetBitmap = new BitSet();
   for (ActivityId ac1 : activities) {
     ActivityCluster ac = acg.getActivityMap().get(ac1);
     Task[] ac1TaskStates = activityPlanMap.get(ac1).getTasks();
     int nProducers = ac1TaskStates.length;
     List<IConnectorDescriptor> outputConns = ac.getActivityOutputMap().get(ac1);
     if (outputConns != null) {
       for (IConnectorDescriptor c : outputConns) {
         ConnectorDescriptorId cdId = c.getConnectorId();
         ActivityId ac2 = ac.getConsumerActivity(cdId);
         Task[] ac2TaskStates = activityPlanMap.get(ac2).getTasks();
         int nConsumers = ac2TaskStates.length;
         if (c.allProducersToAllConsumers()) {
           List<Pair<TaskId, ConnectorDescriptorId>> cInfoList =
               new ArrayList<Pair<TaskId, ConnectorDescriptorId>>();
           for (int j = 0; j < nConsumers; j++) {
             TaskId targetTID = ac2TaskStates[j].getTaskId();
             cInfoList.add(Pair.<TaskId, ConnectorDescriptorId>of(targetTID, cdId));
           }
           for (int i = 0; i < nProducers; ++i) {
             taskConnectivity.put(ac1TaskStates[i].getTaskId(), cInfoList);
           }
         } else {
           for (int i = 0; i < nProducers; ++i) {
             c.indicateTargetPartitions(nProducers, nConsumers, i, targetBitmap);
             List<Pair<TaskId, ConnectorDescriptorId>> cInfoList =
                 taskConnectivity.get(ac1TaskStates[i].getTaskId());
             if (cInfoList == null) {
               cInfoList = new ArrayList<Pair<TaskId, ConnectorDescriptorId>>();
               taskConnectivity.put(ac1TaskStates[i].getTaskId(), cInfoList);
             }
             for (int j = targetBitmap.nextSetBit(0); j >= 0; j = targetBitmap.nextSetBit(j + 1)) {
               TaskId targetTID = ac2TaskStates[j].getTaskId();
               cInfoList.add(Pair.<TaskId, ConnectorDescriptorId>of(targetTID, cdId));
             }
           }
         }
       }
     }
   }
   return taskConnectivity;
 }
 private Map.Entry<K, Versioned<V>> fromRawEntry(Map.Entry<String, Versioned<byte[]>> e) {
   return Pair.of(
       dK(e.getKey()),
       new Versioned<>(
           serializer.decode(e.getValue().value()),
           e.getValue().version(),
           e.getValue().creationTime()));
 }
 @Override
 public Pair<IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) {
   TRSRTransformation tr = transforms.get(cameraTransformType);
   Matrix4f mat = null;
   if (tr != null && tr != TRSRTransformation.identity())
     mat = TRSRTransformation.blockCornerToCenter(tr).getMatrix();
   return Pair.of((IBakedModel) this, mat);
 }
Пример #29
0
 public BarChartTrader getBarchartTrader(String experimentAccession, String accessKey) {
   try {
     return barchartTraders.get(Pair.of(experimentAccession, accessKey));
   } catch (ExecutionException e) {
     LOGGER.error(e.getMessage(), e);
     throw new IllegalStateException(
         "Exception while loading histogram data from file: " + e.getMessage(), e.getCause());
   }
 }
Пример #30
0
 private Supplier<Pair<Integer, JsonNode>> handleRequest(
     StateContext state, BiFunction<Data<Resource>, RequestScope, Boolean> handler) {
   Data<Resource> data = state.getJsonApiDocument().getData();
   if (data == null) {
     throw new InvalidEntityBodyException("Expected data but received null");
   }
   handler.apply(data, state.getRequestScope());
   return () -> Pair.of(HttpStatus.SC_NO_CONTENT, null);
 }