public void setupLoadOnly(String deobfFileName, boolean loadAll) {
   try {
     File mapData = new File(deobfFileName);
     LZMAInputSupplier zis = new LZMAInputSupplier(new FileInputStream(mapData));
     InputSupplier<InputStreamReader> srgSupplier =
         CharStreams.newReaderSupplier(zis, Charsets.UTF_8);
     List<String> srgList = CharStreams.readLines(srgSupplier);
     rawMethodMaps = Maps.newHashMap();
     rawFieldMaps = Maps.newHashMap();
     Builder<String, String> builder = ImmutableBiMap.<String, String>builder();
     Builder<String, String> mcpBuilder = ImmutableBiMap.<String, String>builder();
     Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults();
     for (String line : srgList) {
       String[] parts = Iterables.toArray(splitter.split(line), String.class);
       String typ = parts[0];
       if ("CL".equals(typ)) {
         parseClass(builder, parts);
         parseMCPClass(mcpBuilder, parts);
       } else if ("MD".equals(typ) && loadAll) {
         parseMethod(parts);
       } else if ("FD".equals(typ) && loadAll) {
         parseField(parts);
       }
     }
     classNameBiMap = builder.build();
     mcpNameBiMap = mcpBuilder.build();
   } catch (IOException ioe) {
     FMLRelaunchLog.log(Level.ERROR, "An error occurred loading the deobfuscation map data", ioe);
   }
   methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
   fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());
 }
示例#2
0
  public static Map<String, Properties> loadDBConfig(Properties p) {
    Map<String, Properties> dbConfigs = Maps.newHashMapWithExpectedSize(1);
    for (Object o : p.keySet()) {
      String _key = String.valueOf(o);
      String value = p.getProperty(_key);

      if (StringUtils.startsWithIgnoreCase(_key, "db")) {
        int last_idx = _key.lastIndexOf(StringPool.DOT);
        if (last_idx > 2) {
          // like db.second.url
          String config_name = _key.substring(_key.indexOf(StringPool.DOT) + 1, last_idx);
          if (logger.isDebugEnabled()) {
            logger.debug("the db config is {}", config_name);
          }
          Properties db_config_props = dbConfigs.get(config_name);
          if (db_config_props == null) {
            db_config_props = new Properties();
            dbConfigs.put(config_name, db_config_props);
          }
          _key = _key.replace(StringPool.DOT + config_name, StringPool.EMPTY);
          db_config_props.put(_key, value);
        } else {
          Properties db_main_props = dbConfigs.get("main");
          if (db_main_props == null) {
            db_main_props = new Properties();
            dbConfigs.put("main", db_main_props);
          }
          db_main_props.put(_key, value);
        }
      }
    }
    return dbConfigs;
  }
示例#3
0
 @BeforeClass
 @Shadower(classBeingShadowed = BaseHBaseManagedTimeIT.class)
 public static void doSetup() throws Exception {
   Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
   props.put(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(true));
   setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
 }
示例#4
0
  private static class UnificationResultImpl implements UnificationResult {
    private boolean success = true;
    private final Map<TypeConstructor, TypeProjection> substitution =
        Maps.newHashMapWithExpectedSize(1);
    private final Set<TypeConstructor> failedVariables = Sets.newHashSetWithExpectedSize(0);

    @Override
    public boolean isSuccess() {
      return success;
    }

    public void fail() {
      success = false;
    }

    @Override
    @NotNull
    public Map<TypeConstructor, TypeProjection> getSubstitution() {
      return substitution;
    }

    public void put(TypeConstructor key, TypeProjection value) {
      if (failedVariables.contains(key)) return;

      TypeProjection oldValue = substitution.put(key, value);
      if (oldValue != null && !oldValue.equals(value)) {
        substitution.remove(key);
        failedVariables.add(key);
        fail();
      }
    }
  }
  public SingleInputGate(
      String owningTaskName,
      JobID jobId,
      ExecutionAttemptID executionId,
      IntermediateDataSetID consumedResultId,
      int consumedSubpartitionIndex,
      int numberOfInputChannels,
      PartitionStateChecker partitionStateChecker) {

    this.owningTaskName = checkNotNull(owningTaskName);
    this.jobId = checkNotNull(jobId);
    this.executionId = checkNotNull(executionId);

    this.consumedResultId = checkNotNull(consumedResultId);

    checkArgument(consumedSubpartitionIndex >= 0);
    this.consumedSubpartitionIndex = consumedSubpartitionIndex;

    checkArgument(numberOfInputChannels > 0);
    this.numberOfInputChannels = numberOfInputChannels;

    this.inputChannels = Maps.newHashMapWithExpectedSize(numberOfInputChannels);
    this.channelsWithEndOfPartitionEvents = new BitSet(numberOfInputChannels);

    this.partitionStateChecker = checkNotNull(partitionStateChecker);
  }
    @Override
    public NumericColumnSelector makeMathExpressionSelector(String expression) {
      final Expr parsed = Parser.parse(expression);

      final List<String> required = Parser.findRequiredBindings(parsed);
      final Map<String, Supplier<Number>> values = Maps.newHashMapWithExpectedSize(required.size());

      for (final String columnName : required) {
        values.put(
            columnName,
            new Supplier<Number>() {
              @Override
              public Number get() {
                return Evals.toNumber(row.get().getRaw(columnName));
              }
            });
      }
      final Expr.ObjectBinding binding = Parser.withSuppliers(values);

      return new NumericColumnSelector() {
        @Override
        public Number get() {
          return parsed.eval(binding);
        }
      };
    }
 private static void setValues(
     byte[][] values,
     int[] pkSlotIndex,
     int[] columnIndexes,
     PTable table,
     Map<ImmutableBytesPtr, Map<PColumn, byte[]>> mutation) {
   Map<PColumn, byte[]> columnValues = Maps.newHashMapWithExpectedSize(columnIndexes.length);
   byte[][] pkValues = new byte[table.getPKColumns().size()][];
   // If the table uses salting, the first byte is the salting byte, set to an empty array
   // here and we will fill in the byte later in PRowImpl.
   if (table.getBucketNum() != null) {
     pkValues[0] = new byte[] {0};
   }
   for (int i = 0; i < values.length; i++) {
     byte[] value = values[i];
     PColumn column = table.getColumns().get(columnIndexes[i]);
     if (SchemaUtil.isPKColumn(column)) {
       pkValues[pkSlotIndex[i]] = value;
     } else {
       columnValues.put(column, value);
     }
   }
   ImmutableBytesPtr ptr = new ImmutableBytesPtr();
   table.newKey(ptr, pkValues);
   mutation.put(ptr, columnValues);
 }
  @Override
  public YieldCurveBundle buildObject(
      final FudgeDeserializer deserializer, final FudgeMsg message) {
    // note name in curve & name in bundle may be different!
    final List<FudgeField> curveFields = message.getAllByName(CURVES_FIELD_NAME);
    final List<FudgeField> curveNameFields = message.getAllByName(CURVES_NAME_FIELD_NAME);
    final List<FudgeField> ccyFields = message.getAllByName(CURRENCY_FIELD_NAME);
    final List<FudgeField> ccyCurveFields = message.getAllByName(CURRENCY_CURVE_FIELD_NAME);
    final Map<String, YieldAndDiscountCurve> curves = new LinkedHashMap<>(curveFields.size());
    final Map<String, Currency> curveCurrencys = Maps.newHashMapWithExpectedSize(ccyFields.size());
    final FXMatrix fxMatrix =
        deserializer.fieldValueToObject(FXMatrix.class, message.getByName(FX_MATRIX_FIELD_NAME));
    for (int i = 0; i < curveFields.size(); i++) {
      final YieldAndDiscountCurve curve =
          deserializer.fieldValueToObject(YieldAndDiscountCurve.class, curveFields.get(i));
      final String name = deserializer.fieldValueToObject(String.class, curveNameFields.get(i));
      curves.put(name, curve);
    }
    for (int i = 0; i < ccyFields.size(); i++) {
      final String name = deserializer.fieldValueToObject(String.class, ccyCurveFields.get(i));
      final Currency ccy = deserializer.fieldValueToObject(Currency.class, ccyFields.get(i));
      curveCurrencys.put(name, ccy);
    }

    return new YieldCurveBundle(fxMatrix, curveCurrencys, curves);
  }
 private static Map<String, AutomatonVariable> deepCloneVars(Map<String, AutomatonVariable> pOld) {
   Map<String, AutomatonVariable> result = Maps.newHashMapWithExpectedSize(pOld.size());
   for (Entry<String, AutomatonVariable> e : pOld.entrySet()) {
     result.put(e.getKey(), e.getValue().clone());
   }
   return result;
 }
示例#10
0
 private Map<String, Object> prepareQueryConfigFilters() {
   final Map<String, Object> queryConfig = Maps.newHashMapWithExpectedSize(1);
   filterManagementUIState
       .getCustomFilterSearchText()
       .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value));
   return queryConfig;
 }
示例#11
0
  /**
   * Remember that we are trying to cast something of type {@code supertype} to {@code subtype}.
   *
   * <p>Since at runtime we can only check the class (type constructor), the rest of the subtype
   * should be known statically, from supertype. This method reconstructs all static information
   * that can be obtained from supertype.
   *
   * <p>Example 1: supertype = Collection<String> subtype = List<...> result = List<String>, all
   * arguments are inferred
   *
   * <p>Example 2: supertype = Any subtype = List<...> result = List<*>, some arguments were not
   * inferred, replaced with '*'
   */
  public static TypeReconstructionResult findStaticallyKnownSubtype(
      @NotNull KotlinType supertype, @NotNull TypeConstructor subtypeConstructor) {
    assert !supertype.isMarkedNullable() : "This method only makes sense for non-nullable types";

    // Assume we are casting an expression of type Collection<Foo> to List<Bar>
    // First, let's make List<T>, where T is a type variable
    ClassifierDescriptor descriptor = subtypeConstructor.getDeclarationDescriptor();
    assert descriptor != null : "Can't create default type for " + subtypeConstructor;
    KotlinType subtypeWithVariables = descriptor.getDefaultType();

    // Now, let's find a supertype of List<T> that is a Collection of something,
    // in this case it will be Collection<T>
    KotlinType supertypeWithVariables =
        TypeCheckingProcedure.findCorrespondingSupertype(subtypeWithVariables, supertype);

    final List<TypeParameterDescriptor> variables =
        subtypeWithVariables.getConstructor().getParameters();

    Map<TypeConstructor, TypeProjection> substitution;
    if (supertypeWithVariables != null) {
      // Now, let's try to unify Collection<T> and Collection<Foo> solution is a map from T to Foo
      TypeUnifier.UnificationResult solution =
          TypeUnifier.unify(
              new TypeProjectionImpl(supertype),
              new TypeProjectionImpl(supertypeWithVariables),
              new Predicate<TypeConstructor>() {
                @Override
                public boolean apply(TypeConstructor typeConstructor) {
                  ClassifierDescriptor descriptor = typeConstructor.getDeclarationDescriptor();
                  return descriptor instanceof TypeParameterDescriptor
                      && variables.contains(descriptor);
                }
              });
      substitution = Maps.newHashMap(solution.getSubstitution());
    } else {
      // If there's no corresponding supertype, no variables are determined
      // This may be OK, e.g. in case 'Any as List<*>'
      substitution = Maps.newHashMapWithExpectedSize(variables.size());
    }

    // If some of the parameters are not determined by unification, it means that these parameters
    // are lost,
    // let's put stars instead, so that we can only cast to something like List<*>, e.g. (a: Any) as
    // List<*>
    boolean allArgumentsInferred = true;
    for (TypeParameterDescriptor variable : variables) {
      TypeProjection value = substitution.get(variable.getTypeConstructor());
      if (value == null) {
        substitution.put(variable.getTypeConstructor(), TypeUtils.makeStarProjection(variable));
        allArgumentsInferred = false;
      }
    }

    // At this point we have values for all type parameters of List
    // Let's make a type by substituting them: List<T> -> List<Foo>
    KotlinType substituted =
        TypeSubstitutor.create(substitution).substitute(subtypeWithVariables, Variance.INVARIANT);

    return new TypeReconstructionResult(substituted, allArgumentsInferred);
  }
示例#12
0
  private static Map<String, HRegionInfo> getRegionsByEncodedName(Set<HRegionInfo> regions) {
    Map<String, HRegionInfo> regionsByEncodedName = Maps.newHashMapWithExpectedSize(regions.size());
    for (HRegionInfo region : regions) {
      regionsByEncodedName.put(region.getEncodedName(), region);
    }

    return regionsByEncodedName;
  }
示例#13
0
  /**
   * 生成二维码参数,首先尝试使用 sceneId,再使用sceneStr
   *
   * @param sceneId 场景值ID,临时二维码时为32位非0整型,永久二维码时最大值为100000(目前参数只支持1--100000)
   * @param sceneStr 场景值ID(字符串形式的ID),字符串类型,长度限制为1到64,仅永久二维码支持此字段
   * @param type 二维码类型,QR_SCENE为临时,QR_LIMIT_SCENE为永久,QR_LIMIT_STR_SCENE为永久的字符串参数值
   * @return 二维码参数
   */
  private Map<String, Object> buildQrcodeParams(String sceneId, String sceneStr, QrcodeType type) {
    Map<String, Object> params = Maps.newHashMapWithExpectedSize(2);
    params.put("action_name", type.value());

    Map<String, Object> sceneMap = Maps.newHashMapWithExpectedSize(1);
    if (!Strings.isNullOrEmpty(sceneId)) {
      sceneMap.put("scene_id", sceneId);
    } else if (!Strings.isNullOrEmpty(sceneStr)) {
      sceneMap.put("scene_str", sceneStr);
    }

    Map<String, Object> scene = Maps.newHashMapWithExpectedSize(1);
    scene.put("scene", sceneMap);

    params.put("action_info", scene);
    return params;
  }
示例#14
0
 @BeforeClass
 public static void doSetup() throws Exception {
   Map<String, String> props = Maps.newHashMapWithExpectedSize(3);
   // Must update config before starting server
   props.put(QueryServices.STATS_GUIDEPOST_WIDTH_BYTES_ATTRIB, Long.toString(50));
   props.put(QueryServices.QUEUE_SIZE_ATTRIB, Integer.toString(100));
   setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
 }
 private <T extends SingularityMachineAbstraction<T>> Map<T, MachineState> getDefaultMap(
     List<T> objects) {
   Map<T, MachineState> map = Maps.newHashMapWithExpectedSize(objects.size());
   for (T object : objects) {
     map.put(object, MachineState.DECOMMISSIONING);
   }
   return map;
 }
示例#16
0
  public IncrementalIndexAdapter(
      Interval dataInterval, IncrementalIndex<?> index, BitmapFactory bitmapFactory) {
    this.dataInterval = dataInterval;
    this.index = index;

    /* Sometimes it's hard to tell whether one dimension contains a null value or not.
     * If one dimension had show a null or empty value explicitly, then yes, it contains
     * null value. But if one dimension's values are all non-null, it still early to say
     * this dimension does not contain null value. Consider a two row case, first row had
     * "dimA=1" and "dimB=2", the second row only had "dimA=3". To dimB, its value are "2" and
     * never showed a null or empty value. But when we combines these two rows, dimB is null
     * in row 2. So we should iterate all rows to determine whether one dimension contains
     * a null value.
     */
    this.hasNullValueDimensions = Sets.newHashSet();

    final List<IncrementalIndex.DimensionDesc> dimensions = index.getDimensions();

    indexers = Maps.newHashMapWithExpectedSize(dimensions.size());
    for (IncrementalIndex.DimensionDesc dimension : dimensions) {
      indexers.put(dimension.getName(), new DimensionIndexer(dimension));
    }

    int rowNum = 0;
    for (IncrementalIndex.TimeAndDims timeAndDims : index.getFacts().keySet()) {
      final int[][] dims = timeAndDims.getDims();

      for (IncrementalIndex.DimensionDesc dimension : dimensions) {
        final int dimIndex = dimension.getIndex();
        DimensionIndexer indexer = indexers.get(dimension.getName());
        if (dimIndex >= dims.length || dims[dimIndex] == null) {
          hasNullValueDimensions.add(dimension.getName());
          continue;
        }
        final IncrementalIndex.DimDim values = dimension.getValues();
        if (hasNullValue(values, dims[dimIndex])) {
          hasNullValueDimensions.add(dimension.getName());
        }

        final MutableBitmap[] bitmapIndexes = indexer.invertedIndexes;

        for (Comparable dimIdxComparable : dims[dimIndex]) {
          Integer dimIdx = (Integer) dimIdxComparable;
          if (bitmapIndexes[dimIdx] == null) {
            bitmapIndexes[dimIdx] = bitmapFactory.makeEmptyMutableBitmap();
          }
          try {
            bitmapIndexes[dimIdx].add(rowNum);
          } catch (Exception e) {
            log.info(e.toString());
          }
        }
      }

      ++rowNum;
    }
  }
 @Override
 public SignificantTerms.Bucket getBucketByKey(String term) {
   if (bucketMap == null) {
     bucketMap = Maps.newHashMapWithExpectedSize(buckets.size());
     for (Bucket bucket : buckets) {
       bucketMap.put(bucket.getKeyAsString(), bucket);
     }
   }
   return bucketMap.get(term);
 }
 @Override
 public Map<Integer, String> getTokenDefMap() {
   String[] names = getTokenNames();
   Map<Integer, String> result =
       Maps.newHashMapWithExpectedSize(names.length - Token.MIN_TOKEN_TYPE);
   for (int i = Token.MIN_TOKEN_TYPE; i < names.length; i++) {
     result.put(i, getValueForTokenName(names[i]));
   }
   return result;
 }
 /** @return a {@link Map} with the external {@link OID}s indexed by {@link AppCode} */
 public Map<AppCode, String> getExtOidsByAppCode() {
   Map<AppCode, String> outMap = null;
   if (CollectionUtils.hasData(_extOIDs)) {
     outMap = Maps.newHashMapWithExpectedSize(_extOIDs.size());
     for (R01MStructureLabelOidInApp extOid : _extOIDs) {
       outMap.put(extOid.getAppCode(), extOid.getOid());
     }
   }
   return outMap;
 }
示例#20
0
  /**
   * Does not mutate the TestMatrix.
   *
   * <p>Verifies that the test matrix contains all the required tests and that each required test is
   * valid.
   *
   * @param testMatrix
   * @param matrixSource
   * @param requiredTests
   * @return
   */
  public static ProctorLoadResult verify(
      @Nonnull final TestMatrixArtifact testMatrix,
      final String matrixSource,
      @Nonnull final Map<String, TestSpecification> requiredTests,
      @Nonnull final FunctionMapper functionMapper) {
    final ProctorLoadResult.Builder resultBuilder = ProctorLoadResult.newBuilder();

    final Map<String, Map<Integer, String>> allTestsKnownBuckets =
        Maps.newHashMapWithExpectedSize(requiredTests.size());
    for (final Entry<String, TestSpecification> entry : requiredTests.entrySet()) {
      final Map<Integer, String> bucketValueToName = Maps.newHashMap();
      for (final Entry<String, Integer> bucket : entry.getValue().getBuckets().entrySet()) {
        bucketValueToName.put(bucket.getValue(), bucket.getKey());
      }
      allTestsKnownBuckets.put(entry.getKey(), bucketValueToName);
    }

    final Map<String, ConsumableTestDefinition> definedTests = testMatrix.getTests();
    final SetView<String> missingTests =
        Sets.difference(requiredTests.keySet(), definedTests.keySet());
    resultBuilder.recordAllMissing(missingTests);

    for (final Entry<String, ConsumableTestDefinition> entry : definedTests.entrySet()) {
      final String testName = entry.getKey();
      final Map<Integer, String> knownBuckets = allTestsKnownBuckets.remove(testName);
      if (knownBuckets == null) { //  we don't care about this test
        // iterator.remove(); DO NOT CONSOLIDATE
        continue;
      }

      final ConsumableTestDefinition testDefinition = entry.getValue();

      try {
        verifyTest(
            testName,
            testDefinition,
            requiredTests.get(testName),
            knownBuckets,
            matrixSource,
            functionMapper);

      } catch (IncompatibleTestMatrixException e) {
        LOGGER.error(String.format("Unable to load test matrix for %s", testName), e);
        resultBuilder.recordError(testName);
      }
    }

    // TODO mjs - is this check additive?
    resultBuilder.recordAllMissing(allTestsKnownBuckets.keySet());

    final ProctorLoadResult loadResult = resultBuilder.build();

    return loadResult;
  }
  @BeforeClass
  public static void doSetup() throws Exception {
    Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
    // Set a very small cache size to force plenty of spilling
    props.put(QueryServices.GROUPBY_MAX_CACHE_SIZE_ATTRIB, Integer.toString(1));
    props.put(QueryServices.GROUPBY_SPILLABLE_ATTRIB, String.valueOf(true));
    props.put(QueryServices.GROUPBY_SPILL_FILES_ATTRIB, Integer.toString(1));

    // Must update config before starting server
    startServer(getUrl(), new ReadOnlyProps(props.entrySet().iterator()));
  }
示例#22
0
 @Override
 public Map<String, Short> getBlockIdMap() {
   Map<String, Short> result =
       Maps.newHashMapWithExpectedSize(registeredBlockInfo.get().idByUri.size());
   TObjectShortIterator<BlockUri> iterator = registeredBlockInfo.get().idByUri.iterator();
   while (iterator.hasNext()) {
     iterator.advance();
     result.put(iterator.key().toString(), iterator.value());
   }
   return result;
 }
示例#23
0
    OpenRepo(Repository repo, ProjectState project) {
      this.repo = repo;
      this.project = project;
      rw = CodeReviewCommit.newRevWalk(repo);
      rw.sort(RevSort.TOPO);
      rw.sort(RevSort.COMMIT_TIME_DESC, true);
      rw.setRetainBody(false);
      canMergeFlag = rw.newFlag("CAN_MERGE");

      ins = repo.newObjectInserter();
      branches = Maps.newHashMapWithExpectedSize(1);
    }
示例#24
0
  /**
   * 将二维码长链接转换为端链接,生成二维码将大大提升扫码速度和成功率
   *
   * @param accessToken accessToken
   * @param longUrl 长链接
   * @return 短链接,或抛WechatException
   */
  public String shortUrl(String accessToken, String longUrl) {
    checkNotNullAndEmpty(accessToken, "accessToken");
    checkNotNullAndEmpty(longUrl, "longUrl");

    String url = LONG_TO_SHORT + accessToken;
    Map<String, Object> params = Maps.newHashMapWithExpectedSize(2);
    params.put("action", "long2short");
    params.put("long_url", longUrl);

    Map<String, Object> resp = doPost(url, params);
    return (String) resp.get("short_url");
  }
示例#25
0
  @Override
  public Map<K, Versioned<V>> getAll(Iterable<K> keys, Map<K, Object> transforms) {
    Map<K, List<Versioned<V>>> items = null;
    items = this.clientStore.getAll(keys, null);
    Map<K, Versioned<V>> result = Maps.newHashMapWithExpectedSize(items.size());

    for (Entry<K, List<Versioned<V>>> mapEntry : items.entrySet()) {
      Versioned<V> value = getItemOrThrow(mapEntry.getKey(), null, mapEntry.getValue());
      result.put(mapEntry.getKey(), value);
    }
    return result;
  }
 public void setup(File mcDir, LaunchClassLoader classLoader, String deobfFileName) {
   this.classLoader = classLoader;
   try {
     InputStream classData = getClass().getResourceAsStream(deobfFileName);
     LZMAInputSupplier zis = new LZMAInputSupplier(classData);
     InputSupplier<InputStreamReader> srgSupplier =
         CharStreams.newReaderSupplier(zis, Charsets.UTF_8);
     List<String> srgList = CharStreams.readLines(srgSupplier);
     rawMethodMaps = Maps.newHashMap();
     rawFieldMaps = Maps.newHashMap();
     Builder<String, String> builder = ImmutableBiMap.<String, String>builder();
     Builder<String, String> mcpBuilder = ImmutableBiMap.<String, String>builder();
     Splitter splitter = Splitter.on(CharMatcher.anyOf(": ")).omitEmptyStrings().trimResults();
     for (String line : srgList) {
       String[] parts = Iterables.toArray(splitter.split(line), String.class);
       String typ = parts[0];
       if ("CL".equals(typ)) {
         parseClass(builder, parts);
         parseMCPClass(mcpBuilder, parts);
       } else if ("MD".equals(typ)) {
         parseMethod(parts);
       } else if ("FD".equals(typ)) {
         parseField(parts);
       }
     }
     classNameBiMap = builder.build();
     // Special case some mappings for modloader mods
     mcpBuilder.put("BaseMod", "net/minecraft/src/BaseMod");
     mcpBuilder.put("ModLoader", "net/minecraft/src/ModLoader");
     mcpBuilder.put("EntityRendererProxy", "net/minecraft/src/EntityRendererProxy");
     mcpBuilder.put("MLProp", "net/minecraft/src/MLProp");
     mcpBuilder.put("TradeEntry", "net/minecraft/src/TradeEntry");
     mcpNameBiMap = mcpBuilder.build();
   } catch (IOException ioe) {
     FMLRelaunchLog.log(Level.ERROR, ioe, "An error occurred loading the deobfuscation map data");
   }
   methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
   fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());
 }
  private Map<SingularityDeployKey, SingularityPendingTaskId> getDeployKeyToPendingTaskId() {
    final List<SingularityPendingTaskId> pendingTaskIds = taskManager.getPendingTaskIds();
    final Map<SingularityDeployKey, SingularityPendingTaskId> deployKeyToPendingTaskId =
        Maps.newHashMapWithExpectedSize(pendingTaskIds.size());

    for (SingularityPendingTaskId taskId : pendingTaskIds) {
      SingularityDeployKey deployKey =
          new SingularityDeployKey(taskId.getRequestId(), taskId.getDeployId());
      deployKeyToPendingTaskId.put(deployKey, taskId);
    }

    return deployKeyToPendingTaskId;
  }
示例#28
0
  @Override
  protected void setUp() throws Exception {
    HashMap<String, String> elementMap = Maps.newHashMapWithExpectedSize(nrOfElements);

    for (int i = 1; i <= nrOfElements; i++) {
      String s = "" + i;
      elementMap.put(s, s);
    }

    elements = type.createMap(elementMap);
    first = "1";
    last = "" + nrOfElements;
    middle = "" + (nrOfElements / 2);
  }
  private void init(Collection<ColumnValueRange> andDimensionRanges) {
    int size = andDimensionRanges.size();
    Map<TblColRef, String> startValues = Maps.newHashMapWithExpectedSize(size);
    Map<TblColRef, String> stopValues = Maps.newHashMapWithExpectedSize(size);
    Map<TblColRef, Set<String>> fuzzyValues = Maps.newHashMapWithExpectedSize(size);
    for (ColumnValueRange dimRange : andDimensionRanges) {
      TblColRef column = dimRange.getColumn();
      startValues.put(column, dimRange.getBeginValue());
      stopValues.put(column, dimRange.getEndValue());
      fuzzyValues.put(column, dimRange.getEqualValues());

      TblColRef partitionDateColumnRef =
          cubeSeg.getCubeDesc().getModel().getPartitionDesc().getPartitionDateColumnRef();
      if (column.equals(partitionDateColumnRef)) {
        initPartitionRange(dimRange);
      }
    }

    AbstractRowKeyEncoder encoder = AbstractRowKeyEncoder.createInstance(cubeSeg, cuboid);

    encoder.setBlankByte(RowConstants.ROWKEY_LOWER_BYTE);

    this.startKey = encoder.encode(startValues);

    encoder.setBlankByte(RowConstants.ROWKEY_UPPER_BYTE);

    // In order to make stopRow inclusive add a trailing 0 byte. #See
    // Scan.setStopRow(byte [] stopRow)
    this.stopKey = Bytes.add(encoder.encode(stopValues), ZERO_TAIL_BYTES);

    // restore encoder defaults for later reuse (note
    // AbstractRowKeyEncoder.createInstance() caches instances)
    encoder.setBlankByte(AbstractRowKeyEncoder.DEFAULT_BLANK_BYTE);

    // always fuzzy match cuboid ID to lock on the selected cuboid
    this.fuzzyKeys = buildFuzzyKeys(fuzzyValues);
  }
示例#30
0
  @Override
  public void load(final List<Identifiable> proxy, final List<RpslObject> result) {
    final Map<Integer, RpslObject> loadedObjects = Maps.newHashMapWithExpectedSize(proxy.size());

    Set<Integer> differences = loadObjects(proxy, loadedObjects);
    if (!differences.isEmpty()) {
      final Source originalSource = sourceContext.getCurrentSource();
      LOGGER.info("Objects in source {} not found for ids: {}", originalSource, differences);

      if (originalSource.getType().equals(Source.Type.SLAVE)) {
        final Source masterSource = Source.master(originalSource.getName());
        try {
          sourceContext.setCurrent(masterSource);
          differences = loadObjects(proxy, loadedObjects);
          if (!differences.isEmpty()) {
            LOGGER.info("Objects in source {} not found for ids: {}", masterSource, differences);
          }
        } catch (IllegalSourceException e) {
          LOGGER.debug("Source not configured: {}", masterSource, e);
        } finally {
          sourceContext.setCurrent(originalSource);
        }
      }
    }

    final List<RpslObject> rpslObjects = Lists.newArrayList(loadedObjects.values());
    Collections.sort(
        rpslObjects,
        new Comparator<RpslObject>() {
          final List<Integer> requestedIds =
              Lists.newArrayList(
                  Iterables.transform(
                      proxy,
                      new Function<Identifiable, Integer>() {
                        @Override
                        public Integer apply(final Identifiable input) {
                          return input.getObjectId();
                        }
                      }));

          @Override
          public int compare(final RpslObject o1, final RpslObject o2) {
            return requestedIds.indexOf(o1.getObjectId()) - requestedIds.indexOf(o2.getObjectId());
          }
        });

    // TODO [AK] Return result rather than adding all to the collection
    result.addAll(rpslObjects);
  }