public String toString() {
   return "unevaluated="
       + nameToIdMap.size()
       + ", evaluated="
       + idToEvalMap.size()
       + ", renamed="
       + aliasedColumnMap.size();
 }
  // Task: create collection to translate Polish-English words in two ways
  public static void main(String[] args) {
    ENGLISH_WORD[] englishWords = ENGLISH_WORD.values();
    String[] russianWords = {"jeden", "dwa", "trzy", "kula", "snieg"};

    // Create Multiset
    BiMap<ENGLISH_WORD, String> biMap = EnumHashBiMap.create(ENGLISH_WORD.class);
    // Create English-Polish dictionary
    int i = 0;
    for (ENGLISH_WORD englishWord : englishWords) {
      biMap.put(englishWord, russianWords[i]);
      i++;
    }

    // Print count words
    System.out.println(biMap); // print {ONE=jeden, TWO=dwa, THREE=trzy, BALL=kula, SNOW=snieg}
    // Print all unique words
    System.out.println(biMap.keySet()); // print [ONE, TWO, THREE, BALL, SNOW]
    System.out.println(biMap.values()); // print [jeden, dwa, trzy, kula, snieg]

    // Print translate by words
    System.out.println("one = " + biMap.get(ENGLISH_WORD.ONE)); // print one = jeden
    System.out.println("two = " + biMap.get(ENGLISH_WORD.TWO)); // print two = dwa
    System.out.println("kula = " + biMap.inverse().get("kula")); // print kula = BALL
    System.out.println("snieg = " + biMap.inverse().get("snieg")); // print snieg = SNOW
    System.out.println("empty = " + biMap.get("empty")); // print empty = null

    // Print count word's pair
    System.out.println(biMap.size()); // print 5
  }
Exemple #3
0
  @Override
  protected void runTask() {
    DateTime start = new DateTime(DateTimeZones.UTC);
    log.info("C4 EPG Update initiated");

    DayRange dayRange = rangeGenerator.generate(new LocalDate(DateTimeZones.UTC));

    BiMap<String, Channel> channelMap = c4AtomApi.getChannelMap();
    int total = Iterables.size(dayRange) * channelMap.size();
    int processed = 0;
    UpdateProgress progress = UpdateProgress.START;

    for (Map.Entry<String, Channel> channelEntry : channelMap.entrySet()) {
      for (LocalDate scheduleDay : dayRange) {
        reportStatus(progressReport("Processing", processed++, total, progress));
        progress =
            progress.reduce(
                channelDayUpdater.update(
                    channelEntry.getKey(), channelEntry.getValue(), scheduleDay));
      }
    }

    reportStatus(progressReport("Processed", processed++, total, progress));
    String runTime =
        new Period(start, new DateTime(DateTimeZones.UTC)).toString(PeriodFormat.getDefault());
    log.info("C4 EPG Update finished in " + runTime);

    if (progress.hasFailures()) {
      throw new IllegalStateException(
          String.format("Completed with %s failures", progress.getFailures()));
    }
  }
  public InetAddress getFirstEndpoint() {
    assert tokenToEndPointMap.size() > 0;

    lock.readLock().lock();
    try {
      return tokenToEndPointMap.get(sortedTokens.get(0));
    } finally {
      lock.readLock().unlock();
    }
  }
 public void add(final BiMap<StringWrapper, UUID> toAdd) {
   if (uuidMap.size() == 0) {
     uuidMap = toAdd;
   }
   for (Map.Entry<StringWrapper, UUID> entry : toAdd.entrySet()) {
     UUID uuid = entry.getValue();
     StringWrapper name = entry.getKey();
     if ((uuid == null) || (name == null)) {
       continue;
     }
     BiMap<UUID, StringWrapper> inverse = uuidMap.inverse();
     if (inverse.containsKey(uuid)) {
       if (uuidMap.containsKey(name)) {
         continue;
       }
       rename(uuid, name);
       continue;
     }
     uuidMap.put(name, uuid);
   }
   PS.debug(C.PREFIX.s() + "&6Cached a total of: " + uuidMap.size() + " UUIDs");
 }
Exemple #6
0
 public void setString(int columnIndex, String value) {
   Integer reuseIndex = stringReferences.get(value);
   if (reuseIndex != null) {
     bufferSlice.setInt(getOffset(columnIndex), reuseIndex);
   } else {
     int index = stringReferences.size();
     stringReferences.put(value, index);
     bufferSlice.setInt(getOffset(columnIndex), index);
     stringReferenceSize +=
         value.length() * 2 + 4; // assuming size of char = size of byte * 2 + length
   }
   clearNull(columnIndex);
 }
 private HistoricalTimeSeriesInfoDocument loadTimeSeries(ExternalIdBundle idBundle) {
   ReferenceDataProvider referenceDataProvider =
       ((BloombergToolContext) getToolContext()).getBloombergReferenceDataProvider();
   if (idBundle.getExternalId(ExternalSchemes.BLOOMBERG_BUID) == null
       && idBundle.getExternalId(ExternalSchemes.BLOOMBERG_TICKER) != null) {
     // For some reason loading some series by TICKER fails, but BUID works
     BiMap<String, ExternalIdBundle> map =
         BloombergDataUtils.convertToBloombergBuidKeys(
             Collections.singleton(idBundle), referenceDataProvider);
     if (map.size() != 1) {
       throw new OpenGammaRuntimeException("Failed to get buid");
     }
     for (String key : map.keySet()) {
       ReferenceDataResult buidResult =
           referenceDataProvider.getFields(
               Collections.singleton(key),
               Collections.singleton(BloombergConstants.FIELD_ID_BBG_UNIQUE));
       String buid =
           buidResult
               .getResult(key)
               .getFieldData()
               .getString(BloombergConstants.FIELD_ID_BBG_UNIQUE);
       idBundle = idBundle.withExternalId(ExternalSchemes.bloombergTickerSecurityId(buid));
     }
   }
   ExternalIdBundle searchBundle =
       idBundle.withoutScheme(
           ExternalSchemes
               .ISIN); // For things which move country, e.g. ISIN(VALE5 BZ Equity) == ISIN(RIODF
   // US Equity)
   Map<ExternalId, UniqueId> timeSeries =
       getToolContext()
           .getHistoricalTimeSeriesLoader()
           .addTimeSeries(
               searchBundle.getExternalIds(),
               "CMPL",
               "PX_LAST",
               LocalDate.now().minusYears(1),
               null);
   if (timeSeries.size() != 1) {
     throw new OpenGammaRuntimeException(
         "Failed to load time series " + idBundle + " " + timeSeries);
   }
   for (UniqueId uid : timeSeries.values()) {
     return getToolContext().getHistoricalTimeSeriesMaster().get(uid);
   }
   throw new OpenGammaRuntimeException("Unexpected state");
 }
 @Override
 public void printStatistics(PrintStream out) {
   out.println(
       "Number of named predicates:          " + (regionMap.size() - anonymousPredicateCounter));
   delegate.printStatistics(out);
 }
 public int size() {
   return objectsToCommitFirst.size() + objectsToCommitSecond.size();
 }
Exemple #10
0
 @Override
 public int size() {
   return vocabulary.size();
 }