コード例 #1
1
ファイル: Scrubber.java プロジェクト: sh4nth/atlasdb-1
 private void scrubCells(
     TransactionManager txManager,
     Multimap<String, Cell> tableNameToCells,
     long scrubTimestamp,
     Transaction.TransactionType transactionType) {
   for (Entry<String, Collection<Cell>> entry : tableNameToCells.asMap().entrySet()) {
     String tableName = entry.getKey();
     if (log.isInfoEnabled()) {
       log.info(
           "Attempting to immediately scrub "
               + entry.getValue().size()
               + " cells from table "
               + tableName);
     }
     for (List<Cell> cells : Iterables.partition(entry.getValue(), batchSizeSupplier.get())) {
       Multimap<Cell, Long> timestampsToDelete =
           HashMultimap.create(
               keyValueService.getAllTimestamps(
                   tableName, ImmutableSet.copyOf(cells), scrubTimestamp));
       for (Cell cell : ImmutableList.copyOf(timestampsToDelete.keySet())) {
         // Don't scrub garbage collection sentinels
         timestampsToDelete.remove(cell, Value.INVALID_VALUE_TIMESTAMP);
       }
       // If transactionType == TransactionType.AGGRESSIVE_HARD_DELETE this might
       // force other transactions to abort or retry
       deleteCellsAtTimestamps(txManager, tableName, timestampsToDelete, transactionType);
     }
     if (log.isInfoEnabled()) {
       log.info(
           "Immediately scrubbed " + entry.getValue().size() + " cells from table " + tableName);
     }
   }
 }
コード例 #2
0
  /**
   * Remove the targets and rules defined by {@code path} from the cache and recursively remove the
   * targets and rules defined by files that transitively include {@code path} from the cache.
   *
   * @param path The File that has changed.
   */
  private synchronized void invalidatePath(Cell cell, Path path) {
    // Paths from Watchman are not absolute.
    path = cell.getFilesystem().resolve(path);

    // If the path is a build file for the cell, nuke the targets that it owns first. We don't need
    // to check whether or not the path ends in the build file name, since we know that these are
    // the only things that get added. Which makes for an easy life.
    List<Map<String, Object>> rawNodes = allRawNodes.getIfPresent(path);
    if (rawNodes != null) {
      // Invalidate the target nodes first
      for (Map<String, Object> rawNode : rawNodes) {
        UnflavoredBuildTarget target = parseBuildTargetFromRawRule(cell.getRoot(), rawNode);
        allTargetNodes.invalidateAll(targetsCornucopia.get(target));
        targetsCornucopia.removeAll(target);
      }

      // And then the raw node itself.
      allRawNodes.invalidate(path);
    }

    // We may have been given a file that other build files depend on. Iteratively remove those.
    Iterable<Path> dependents = buildFileDependents.get(path);
    for (Path dependent : dependents) {
      if (dependent.equals(path)) {
        continue;
      }
      invalidatePath(cell, dependent);
    }
    buildFileDependents.removeAll(path);
  }
コード例 #3
0
 /** construct deep-copy of other */
 protected Topology(Topology other) {
   dcEndpoints = HashMultimap.create(other.dcEndpoints);
   dcRacks = new HashMap<String, Multimap<String, InetAddress>>();
   for (String dc : other.dcRacks.keySet())
     dcRacks.put(dc, HashMultimap.create(other.dcRacks.get(dc)));
   currentLocations = new HashMap<InetAddress, Pair<String, String>>(other.currentLocations);
 }
コード例 #4
0
ファイル: DaemonicParserState.java プロジェクト: davido/buck
  public DaemonicParserState(
      TypeCoercerFactory typeCoercerFactory,
      ConstructorArgMarshaller marshaller,
      int parsingThreads) {
    this.typeCoercerFactory = typeCoercerFactory;
    this.marshaller = marshaller;
    this.allRawNodes = new OptimisticLoadingCache<>(parsingThreads);
    this.targetsCornucopia = HashMultimap.create();
    this.allTargetNodes = new OptimisticLoadingCache<>(parsingThreads);
    this.hasCachedTargetNodeForBuildTargetPredicate =
        new Predicate<BuildTarget>() {
          @Override
          public boolean apply(BuildTarget buildTarget) {
            return hasCachedTargetNodeForBuildTarget(buildTarget);
          }
        };
    this.buildFileTrees =
        CacheBuilder.newBuilder()
            .build(
                new CacheLoader<Cell, BuildFileTree>() {
                  @Override
                  public BuildFileTree load(Cell cell) throws Exception {
                    return new FilesystemBackedBuildFileTree(
                        cell.getFilesystem(), cell.getBuildFileName());
                  }
                });
    this.buildFileDependents = HashMultimap.create();
    this.cachedEnvironment = ImmutableMap.of();
    this.cachedIncludes = new ConcurrentHashMap<>();
    this.knownCells = Collections.synchronizedSet(new HashSet<Cell>());

    this.cachedStateLock = new AutoCloseableReadWriteUpdateLock();
  }
コード例 #5
0
 /**
  * Returns a multimap of propertyKey -> values
  *
  * @param results The AQL properties search result
  */
 public static HashMultimap<String, String> propsToMap(AqlEagerResult<AqlProperty> results) {
   HashMultimap<String, String> map = HashMultimap.create();
   for (AqlProperty property : results.getResults()) {
     map.put(property.getKey(), property.getValue());
   }
   return map;
 }
コード例 #6
0
    @Override
    public void registerPermissionLevel(String permission, RegGroup group, boolean alone) {
      Permission deny = new Permission(permission, false);
      Permission allow = new Permission(permission, true);

      if (!deny.isAll) {
        registerred.add(permission);
      }

      if (group == null) {
        perms.put(RegGroup.ZONE, deny);
      } else if (group == RegGroup.ZONE) {
        perms.put(RegGroup.ZONE, allow);
      } else {
        perms.put(group, allow);

        if (alone) return;

        for (RegGroup g : getHigherGroups(group)) {
          perms.put(g, allow);
        }

        for (RegGroup g : getLowerGroups(group)) {
          perms.put(g, deny);
        }
      }
    }
コード例 #7
0
  protected static class Index {
    // This mutable state is only modified under inside the computable
    private final List<JetDeclaration> allDeclarations = Lists.newArrayList();
    private final Multimap<Name, JetNamedFunction> functions = HashMultimap.create();
    private final Multimap<Name, JetProperty> properties = HashMultimap.create();
    private final Multimap<Name, JetClassOrObject> classesAndObjects =
        ArrayListMultimap.create(); // order matters here

    public void putToIndex(@NotNull JetDeclaration declaration) {
      if (declaration instanceof JetClassInitializer) {
        return;
      }
      allDeclarations.add(declaration);
      if (declaration instanceof JetNamedFunction) {
        JetNamedFunction namedFunction = (JetNamedFunction) declaration;
        functions.put(safeNameForLazyResolve(namedFunction), namedFunction);
      } else if (declaration instanceof JetProperty) {
        JetProperty property = (JetProperty) declaration;
        properties.put(safeNameForLazyResolve(property), property);
      } else if (declaration instanceof JetClassOrObject) {
        JetClassOrObject classOrObject = (JetClassOrObject) declaration;
        classesAndObjects.put(safeNameForLazyResolve(classOrObject.getNameAsName()), classOrObject);
      } else if (declaration instanceof JetParameter
          || declaration instanceof JetTypedef
          || declaration instanceof JetMultiDeclaration) {
        // Do nothing, just put it into allDeclarations is enough
      } else {
        throw new IllegalArgumentException("Unknown declaration: " + declaration);
      }
    }
  }
  @Override
  public IDecorator[] getDecorators(final PictogramElement pe) {
    IFeatureProvider featureProvider = getFeatureProvider();
    Object bo = featureProvider.getBusinessObjectForPictogramElement(pe);
    Integer objectId;
    if (bo instanceof Method) {
      System.out.println("CHECKING METHOD");
      objectId = System.identityHashCode(bo.getClass());
      try { // generate decorator and markers
        if (!XcoreValidator.INSTANCE.validateMethod((Method) bo, diagnosticChain, null)) {
          Diagnostic lastDiagnostic =
              diagnosticChain.getChildren().get(diagnosticChain.getChildren().size() - 1);
          markers.put(
              objectId,
              AtomicDesignUtils.createMarker(
                  lastDiagnostic.getMessage(),
                  IMarker.SEVERITY_ERROR,
                  ((Method) bo).getClass().getName()));
          return new ImageDecorator[] {
            AtomicDesignUtils.createImageDecorator(
                lastDiagnostic, lastDiagnostic.getMessage(), 20, 0)
          };

        } else {
          AtomicDesignUtils.destroyMarker(markers.get(objectId));
        }

      } catch (CoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    if (bo instanceof ComputationUnit) {
      System.out.println("CHECKING CU");
      if (!XcoreValidator.INSTANCE.validateComputationUnit(
          (ComputationUnit) bo, diagnosticChain, null)) {
        System.out.println("CHECKING METHOD");
      }
    }
    if (bo instanceof DataElement) {
      System.out.println("CHECKING DATAELEMENT");
      if (!XcoreValidator.INSTANCE.validateDataElement((DataElement) bo, diagnosticChain, null)) {}
    }

    if (bo instanceof Service) {
      System.out.println("CHECKING SERVICE");
      if (!XcoreValidator.INSTANCE.validateService((Service) bo, diagnosticChain, null)) {}
    }

    if (bo instanceof Parameter) {
      System.out.println("CHECKING PARAMETER");
      if (!XcoreValidator.INSTANCE.validateParameter((Parameter) bo, diagnosticChain, null)) {}
    }

    return super.getDecorators(pe);
  }
コード例 #9
0
ファイル: Collections.java プロジェクト: csophys/java-study
  @Test
  public void testMultiMap() {
    HashMultimap<Object, Object> hashMultimap = HashMultimap.create();
    hashMultimap.put(1, 2);
    hashMultimap.put(2, 4);
    hashMultimap.put(1, 3);

    assert hashMultimap.get(1).contains(2);
    assert hashMultimap.get(1).contains(3);
  }
コード例 #10
0
 DaemonicCellState(Cell cell, int parsingThreads) {
   this.cell = cell;
   this.parsingThreads = parsingThreads;
   this.cellRoot = cell.getRoot();
   this.buildFileDependents = HashMultimap.create();
   this.targetsCornucopia = HashMultimap.create();
   this.buildFileConfigs = new HashMap<>();
   this.allRawNodes = new ConcurrentMapCache<>(parsingThreads);
   this.typedNodeCaches = Maps.newConcurrentMap();
   this.rawAndComputedNodesLock = new AutoCloseableReadWriteUpdateLock();
 }
コード例 #11
0
  @Override
  public Collection<Job> getJobs(String... tags) {
    if (tags.length == 0) return Collections.emptySet();

    HashSet<Job> jobs = new HashSet<>();
    Iterator<String> it = Arrays.asList(tags).iterator();
    String tag = it.next();
    jobs.addAll(tagToJobs.get(tag));

    while (it.hasNext()) {
      tag = it.next();
      jobs.removeAll(Sets.difference(jobs, tagToJobs.get(tag)));
    }

    return jobs;
  }
コード例 #12
0
ファイル: EdgeContentPart.java プロジェクト: psuzzi/gef4
 @Override
 public SetMultimap<Object, String> getContentAnchorages() {
   SetMultimap<Object, String> anchorages = HashMultimap.create();
   anchorages.put(getContent().getSource(), "START");
   anchorages.put(getContent().getTarget(), "END");
   return anchorages;
 }
コード例 #13
0
public class ClassDependencies {

  private final SetMultimap<ClassName, ClassName> _classToReferencedClassesMap =
      HashMultimap.create();

  public Set<ClassName> getAllClasses() {
    return Collections.unmodifiableSet(_classToReferencedClassesMap.keySet());
  }

  public Set<ClassName> getReferencedClasses(ClassName className) {
    return Collections.unmodifiableSet(_classToReferencedClassesMap.get(className));
  }

  public void add(ClassName className, Collection<ClassName> referencedClasses) {
    _classToReferencedClassesMap.putAll(className, referencedClasses);
    _classToReferencedClassesMap.remove(className, className);
  }

  public Set<ClassName> getTransitiveClosure(Collection<ClassName> classNames) {
    Set<ClassName> transitiveClosure = Sets.newHashSet();
    for (ClassName className : classNames) {
      collectTransitiveClosure(className, transitiveClosure);
    }
    return transitiveClosure;
  }

  private void collectTransitiveClosure(ClassName className, Set<ClassName> transitiveClosure) {
    if (transitiveClosure.add(className)) {
      for (ClassName referencedClass : _classToReferencedClassesMap.get(className)) {
        collectTransitiveClosure(referencedClass, transitiveClosure);
      }
    }
  }
}
  public void testAllOptions() throws IOException {

    String expected =
        Strings2.toStringAndClose(
            getClass().getResourceAsStream("/InstantiateVAppTemplateParams-options-test.xml"));
    Multimap<String, String> headers =
        Multimaps.synchronizedMultimap(HashMultimap.<String, String>create());
    GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
    expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
    expect(request.getArgs())
        .andReturn(
            ImmutableList.<Object>of(
                InstantiateVAppTemplateOptions.Builder.processorCount(2)
                    .memory(512)
                    .inGroup("group")
                    .withPassword("password")
                    .inRow("row")
                    .addNetworkConfig(new NetworkConfig(URI.create("http://network")))))
        .atLeastOnce();
    expect(request.getFirstHeaderOrNull("Content-Type"))
        .andReturn("application/unknown")
        .atLeastOnce();
    expect(request.getHeaders()).andReturn(headers).atLeastOnce();
    request.setPayload(expected);
    replay(request);

    BindInstantiateVAppTemplateParamsToXmlPayload binder =
        injector.getInstance(BindInstantiateVAppTemplateParamsToXmlPayload.class);

    Map<String, String> map = Maps.newHashMap();
    map.put("name", "name");
    map.put("template", "https://vcloud/vAppTemplate/3");
    binder.bindToRequest(request, map);
  }
コード例 #15
0
ファイル: Option.java プロジェクト: okleine/nCoAP
  static {
    MUTUAL_EXCLUSIONS.put(URI_HOST, PROXY_URI);
    MUTUAL_EXCLUSIONS.put(PROXY_URI, URI_HOST);

    MUTUAL_EXCLUSIONS.put(URI_PORT, PROXY_URI);
    MUTUAL_EXCLUSIONS.put(PROXY_URI, URI_PORT);

    MUTUAL_EXCLUSIONS.put(URI_PATH, PROXY_URI);
    MUTUAL_EXCLUSIONS.put(PROXY_URI, URI_PATH);

    MUTUAL_EXCLUSIONS.put(URI_QUERY, PROXY_URI);
    MUTUAL_EXCLUSIONS.put(PROXY_URI, URI_QUERY);

    MUTUAL_EXCLUSIONS.put(PROXY_SCHEME, PROXY_URI);
    MUTUAL_EXCLUSIONS.put(PROXY_URI, PROXY_SCHEME);
  }
コード例 #16
0
  boolean areAbstractSuccessors(
      AbstractState pElement,
      CFAEdge pCfaEdge,
      Collection<? extends AbstractState> pSuccessors,
      ProofChecker wrappedProofChecker)
      throws CPATransferException, InterruptedException {
    ARGState element = (ARGState) pElement;

    assert Iterables.elementsEqual(element.getChildren(), pSuccessors);

    AbstractState wrappedState = element.getWrappedState();
    Multimap<CFAEdge, AbstractState> wrappedSuccessors = HashMultimap.create();
    for (AbstractState absElement : pSuccessors) {
      ARGState successorElem = (ARGState) absElement;
      wrappedSuccessors.put(element.getEdgeToChild(successorElem), successorElem.getWrappedState());
    }

    if (pCfaEdge != null) {
      return wrappedProofChecker.areAbstractSuccessors(
          wrappedState, pCfaEdge, wrappedSuccessors.get(pCfaEdge));
    }

    CFANode loc = AbstractStates.extractLocation(element);
    for (CFAEdge edge : leavingEdges(loc)) {
      if (!wrappedProofChecker.areAbstractSuccessors(
          wrappedState, edge, wrappedSuccessors.get(edge))) {
        return false;
      }
    }
    return true;
  }
コード例 #17
0
ファイル: QueryParser.java プロジェクト: rdettai/kairosdb
 public SetMultimap<String, String> getTags() {
   if (tags != null) {
     return tags;
   } else {
     return HashMultimap.create();
   }
 }
コード例 #18
0
ファイル: NodeScheduler.java プロジェクト: posix4e/presto
    public Multimap<Node, Split> computeAssignments(Set<Split> splits) {
      Multimap<Node, Split> assignment = HashMultimap.create();

      for (Split split : splits) {
        List<Node> candidateNodes;
        if (locationAwareScheduling) {
          candidateNodes = selectCandidateNodes(nodeMap.get().get(), split);
        } else {
          candidateNodes = selectRandomNodes(minCandidates);
        }
        checkCondition(
            !candidateNodes.isEmpty(), NO_NODES_AVAILABLE, "No nodes available to run query");

        Node chosen = null;
        int min = Integer.MAX_VALUE;
        for (Node node : candidateNodes) {
          RemoteTask task = taskMap.get(node);
          int currentSplits = (task == null) ? 0 : task.getQueuedSplits();
          int assignedSplits = currentSplits + assignment.get(node).size();
          if (assignedSplits < min && assignedSplits < maxPendingSplitsPerTask) {
            chosen = node;
            min = assignedSplits;
          }
        }
        if (chosen != null) {
          assignment.put(chosen, split);
        }
      }
      return assignment;
    }
コード例 #19
0
  static Set<String> sanityCheckDatacenters(
      Cassandra.Client client, int desiredRf, boolean safetyDisabled)
      throws InvalidRequestException, TException {
    ensureTestKeyspaceExists(client);
    Multimap<String, String> dataCenterToRack = HashMultimap.create();
    List<TokenRange> ring = client.describe_ring(CassandraConstants.SIMPLE_RF_TEST_KEYSPACE);
    for (TokenRange tokenRange : ring) {
      for (EndpointDetails details : tokenRange.getEndpoint_details()) {
        dataCenterToRack.put(details.datacenter, details.rack);
      }
    }

    if (dataCenterToRack.size() == 1) {
      String dc = dataCenterToRack.keySet().iterator().next();
      String rack = dataCenterToRack.values().iterator().next();
      if (dc.equals(CassandraConstants.DEFAULT_DC)
          && rack.equals(CassandraConstants.DEFAULT_RACK)
          && desiredRf > 1) {
        // We don't allow greater than RF=1 because they didn't set up their network.
        logErrorOrThrow(
            "The cassandra cluster is not set up to be datacenter and rack aware.  "
                + "Please set this up before running with a replication factor higher than 1.",
            safetyDisabled);
      }
    }

    return dataCenterToRack.keySet();
  }
コード例 #20
0
  /** Return the triggers that have all the provided tags */
  @Override
  public Collection<Trigger> getTriggers(String... tags) {
    if (tags.length == 0) return Collections.emptySet();

    HashSet<Trigger> triggers = new HashSet<>();
    Iterator<String> it = Arrays.asList(tags).iterator();
    String tag = it.next();
    triggers.addAll(tagToTriggers.get(tag));

    while (it.hasNext()) {
      tag = it.next();
      triggers.removeAll(Sets.difference(triggers, tagToTriggers.get(tag)));
    }

    return triggers;
  }
コード例 #21
0
  public ReverseCFATransformerFactory(Set<CFAEdge> cfa) {
    reverseCFA = HashMultimap.create();
    Set<Location> nonSinks = new HashSet<Location>();
    for (CFAEdge e : cfa) {
      reverseCFA.put(e.getTarget(), e);
      nonSinks.add(e.getSource());
    }

    FastSet<Location> sinks = new FastSet<Location>();
    for (Location l : reverseCFA.keySet()) {
      if (!nonSinks.contains(l)) {
        sinks.add(l);
      }
    }

    if (sinks.size() == 1) {
      sink = sinks.pick();
    } else if (sinks.size() == 0) {
      throw new RuntimeException("CFA has no sink!");
    } else {
      // Generate artificial exit node
      sink = new Location(new AbsoluteAddress(0xFFFFFF01L));
      for (Location l : sinks) {
        reverseCFA.put(sink, new CFAEdge(l, sink, new RTLSkip()));
      }
    }
  }
コード例 #22
0
 @Override
 public synchronized void addJob(Job job) {
   nameToJob.put(job.getName(), job);
   for (String tag : job.getTags()) {
     tagToJobs.put(tag, job);
   }
 }
コード例 #23
0
ファイル: SubmoduleOp.java プロジェクト: hdost/gerrit
  protected void updateSuperProjects(ReviewDb db, Set<Branch.NameKey> updatedBranches)
      throws SubmoduleException {
    try {
      // These (repo/branch) will be updated later with all the given
      // individual submodule subscriptions
      Multimap<Branch.NameKey, SubmoduleSubscription> targets = HashMultimap.create();

      for (Branch.NameKey updatedBranch : updatedBranches) {
        for (SubmoduleSubscription sub : db.submoduleSubscriptions().bySubmodule(updatedBranch)) {
          targets.put(sub.getSuperProject(), sub);
        }
      }
      updatedSubscribers.addAll(updatedBranches);
      // Update subscribers.
      for (Branch.NameKey dest : targets.keySet()) {
        try {
          if (!updatedSubscribers.add(dest)) {
            log.error("Possible circular subscription involving " + dest);
          } else {
            updateGitlinks(db, dest, targets.get(dest));
          }
        } catch (SubmoduleException e) {
          log.warn("Cannot update gitlinks for " + dest, e);
        }
      }
    } catch (OrmException e) {
      logAndThrowSubmoduleException("Cannot read subscription records", e);
    }
  }
コード例 #24
0
ファイル: Main.java プロジェクト: ruminski/looksok
public class Main {

  private static Map<String, List<Integer>> playerScoresMap = new HashMap<String, List<Integer>>();
  private static Multimap<String, Integer> playerScoresMultimap = HashMultimap.create();

  public static void main(String[] args) {
    System.out.println("Multimap demo!");

    addToOldStyleMultimap("Bob", 10);
    addToOldStyleMultimap("Bob", 20);
    addToOldStyleMultimap("Bob", 30);
    addToOldStyleMultimap("Kate", 130);
    System.out.println("Old style multimap result: " + playerScoresMap);

    addToGuavaMultimap("Alan", 2);
    addToGuavaMultimap("Alan", 4);
    addToGuavaMultimap("Alan", 6);
    addToGuavaMultimap("Paul", 87);
    System.out.println("Guava multimap result: " + playerScoresMultimap);
  }

  private static void addToOldStyleMultimap(String playerName, int scoreToAdd) {
    List<Integer> scoresList = new ArrayList<Integer>();
    if (playerScoresMap.containsKey(playerName)) {
      scoresList = playerScoresMap.get(playerName);
    }

    scoresList.add(scoreToAdd);
    playerScoresMap.put(playerName, scoresList);
  }

  private static void addToGuavaMultimap(String playerName, Integer scoreToAdd) {
    playerScoresMultimap.put(playerName, scoreToAdd);
  }
}
コード例 #25
0
 @Override
 public synchronized void addTrigger(Trigger trigger) {
   nameToTrigger.put(trigger.getName(), trigger);
   for (String tag : trigger.getTags()) {
     tagToTriggers.put(tag, trigger);
   }
 }
コード例 #26
0
ファイル: DeclarationResolver.java プロジェクト: kuity/kotlin
  public void checkRedeclarationsInInnerClassNames(@NotNull TopDownAnalysisContext c) {
    for (ClassDescriptorWithResolutionScopes classDescriptor : c.getDeclaredClasses().values()) {
      if (classDescriptor.getKind() == ClassKind.CLASS_OBJECT) {
        // Class objects should be considered during analysing redeclarations in classes
        continue;
      }

      Collection<DeclarationDescriptor> allDescriptors =
          classDescriptor.getScopeForMemberLookup().getOwnDeclaredDescriptors();

      ClassDescriptorWithResolutionScopes classObj = classDescriptor.getClassObjectDescriptor();
      if (classObj != null) {
        Collection<DeclarationDescriptor> classObjDescriptors =
            classObj.getScopeForMemberLookup().getOwnDeclaredDescriptors();
        if (!classObjDescriptors.isEmpty()) {
          allDescriptors = Lists.newArrayList(allDescriptors);
          allDescriptors.addAll(classObjDescriptors);
        }
      }

      Multimap<Name, DeclarationDescriptor> descriptorMap = HashMultimap.create();
      for (DeclarationDescriptor desc : allDescriptors) {
        if (desc instanceof ClassDescriptor || desc instanceof PropertyDescriptor) {
          descriptorMap.put(desc.getName(), desc);
        }
      }

      reportRedeclarations(descriptorMap);
    }
  }
  /**
   * Gets the feed mapping for a feed.
   *
   * @return a multimap from feed attribute ID to the set of field IDs mapped to the attribute
   */
  private static Multimap<Long, Integer> getFeedMapping(
      AdWordsServices adWordsServices, AdWordsSession session, Feed feed, long placeholderType)
      throws Exception {
    // Get the FeedMappingService.
    FeedMappingServiceInterface feedMappingService =
        adWordsServices.get(session, FeedMappingServiceInterface.class);
    String query =
        String.format(
            "SELECT FeedMappingId, AttributeFieldMappings WHERE FeedId = %d and PlaceholderType = %d "
                + "AND Status = 'ENABLED'",
            feed.getId(), placeholderType);

    Multimap<Long, Integer> attributeMappings = HashMultimap.create();
    int offset = 0;
    FeedMappingPage feedMappingPage;

    do {
      String pageQuery = String.format(query + " LIMIT %d, %d", offset, PAGE_SIZE);
      feedMappingPage = feedMappingService.query(pageQuery);
      if (feedMappingPage.getEntries() != null) {
        // Normally, a feed attribute is mapped only to one field. However, you may map it to more
        // than one field if needed.
        for (FeedMapping feedMapping : feedMappingPage.getEntries()) {
          for (AttributeFieldMapping attributeMapping : feedMapping.getAttributeFieldMappings()) {
            attributeMappings.put(
                attributeMapping.getFeedAttributeId(), attributeMapping.getFieldId());
          }
        }
      }
      offset += PAGE_SIZE;
    } while (offset < feedMappingPage.getTotalNumEntries());

    return attributeMappings;
  }
コード例 #28
0
 public static String paramsListToString(Map<String, String> params) {
   Multimap<String, String> multimap = HashMultimap.create(params.size(), 1);
   for (String key : params.keySet()) {
     multimap.put(key, params.get(key));
   }
   return paramsListToString(multimap);
 }
コード例 #29
0
  @NotNull
  private static Multimap<FqName, Pair<FunctionDescriptor, PsiMethod>>
      getSuperclassToFunctionsMultimap(
          @NotNull PsiMethodWrapper method,
          @NotNull BindingContext bindingContext,
          @NotNull ClassDescriptor containingClass) {
    Multimap<FqName, Pair<FunctionDescriptor, PsiMethod>> result = HashMultimap.create();

    Name functionName = Name.identifier(method.getName());
    int parameterCount = method.getParameters().size();

    for (JetType supertype : TypeUtils.getAllSupertypes(containingClass.getDefaultType())) {
      ClassifierDescriptor klass = supertype.getConstructor().getDeclarationDescriptor();
      assert klass != null;
      FqName fqName = DescriptorUtils.getFQName(klass).toSafe();

      for (FunctionDescriptor fun :
          klass.getDefaultType().getMemberScope().getFunctions(functionName)) {
        if (fun.getKind().isReal() && fun.getValueParameters().size() == parameterCount) {
          PsiElement declaration = BindingContextUtils.descriptorToDeclaration(bindingContext, fun);
          if (declaration instanceof PsiMethod) {
            result.put(fqName, Pair.create(fun, (PsiMethod) declaration));
          } // else declaration is null or JetNamedFunction: both cases are processed later
        }
      }
    }
    return result;
  }
コード例 #30
0
  private Multimap<Cell, Long> getCellTsPairsToSweep(
      Multimap<Cell, Long> cellTsMappings,
      PeekingIterator<RowResult<Value>> values,
      long sweepTimestamp,
      SweepStrategy sweepStrategy,
      @Output Set<Cell> sentinelsToAdd) {
    Multimap<Cell, Long> cellTsMappingsToSweep = HashMultimap.create();

    Map<Long, Long> startTsToCommitTs = transactionService.get(cellTsMappings.values());
    for (Map.Entry<Cell, Collection<Long>> entry : cellTsMappings.asMap().entrySet()) {
      Cell cell = entry.getKey();
      Collection<Long> timestamps = entry.getValue();
      boolean sweepLastCommitted = isLatestValueEmpty(cell, values);
      Iterable<? extends Long> timestampsToSweep =
          getTimestampsToSweep(
              cell,
              timestamps,
              startTsToCommitTs,
              sentinelsToAdd,
              sweepTimestamp,
              sweepLastCommitted,
              sweepStrategy);
      cellTsMappingsToSweep.putAll(entry.getKey(), timestampsToSweep);
    }
    return cellTsMappingsToSweep;
  }