public void addDependencyForRelocation(ModuleVersionSelector selector) { // Some POMs depend on themselves through their parent POM, don't add this dependency // since Ivy doesn't allow this! // Example: http://repo2.maven.org/maven2/com/atomikos/atomikos-util/3.6.4/atomikos-util-3.6.4.pom if (selector.getGroup().equals(descriptor.getComponentIdentifier().getGroup()) && selector.getName().equals(descriptor.getComponentIdentifier().getModule())) { return; } // TODO - this is a constant ListMultimap<String, String> confMappings = ArrayListMultimap.create(); // Map dependency on all public configurations for (Configuration m2Conf : GradlePomModuleDescriptorBuilder.MAVEN2_CONFIGURATIONS.values()) { if (m2Conf.isVisible()) { confMappings.put(m2Conf.getName(), m2Conf.getName()); } } dependencies.add(new IvyDependencyMetadata(selector, confMappings)); }
private List<ConsumerProvidedTaskSelector> buildRecursively(GradleProject project) { Multimap<String, String> aggregatedTasks = ArrayListMultimap.create(); collectTasks(project, aggregatedTasks); List<ConsumerProvidedTaskSelector> selectors = Lists.newArrayList(); for (String selectorName : aggregatedTasks.keySet()) { SortedSet<String> selectorTasks = Sets.newTreeSet(new TaskNameComparator()); selectorTasks.addAll(aggregatedTasks.get(selectorName)); selectors.add(new ConsumerProvidedTaskSelector(). setName(selectorName). setTaskNames(selectorTasks). setDescription(project.getParent() != null ? String.format("%s:%s task selector", project.getPath(), selectorName) : String.format("%s task selector", selectorName)). setDisplayName(String.format("%s in %s and subprojects.", selectorName, project.getName()))); } return selectors; }
private ListMultimap<Class, Task> groupTasksByType(List<Task> tasks) { final Set<Class> taskTypes = new TreeSet<Class>(new Comparator<Class>() { public int compare(Class o1, Class o2) { return o1.getSimpleName().compareTo(o2.getSimpleName()); } }); taskTypes.addAll(collect(tasks, new Transformer<Class, Task>() { public Class transform(Task original) { return getDeclaredTaskType(original); } })); ListMultimap<Class, Task> tasksGroupedByType = ArrayListMultimap.create(); for (final Class taskType : taskTypes) { tasksGroupedByType.putAll(taskType, filter(tasks, new Spec<Task>() { public boolean isSatisfiedBy(Task element) { return getDeclaredTaskType(element).equals(taskType); } })); } return tasksGroupedByType; }
private static ListMultimap<String, TablePermission> parsePermissions( byte[] entryName, Result result) { ListMultimap<String, TablePermission> perms = ArrayListMultimap.create(); if (result != null && result.size() > 0) { for (Cell kv : result.rawCells()) { Pair<String,TablePermission> permissionsOfUserOnTable = parsePermissionRecord(entryName, kv); if (permissionsOfUserOnTable != null) { String username = permissionsOfUserOnTable.getFirst(); TablePermission permissions = permissionsOfUserOnTable.getSecond(); perms.put(username, permissions); } } } return perms; }
/** * Adds a instance handle to the mapping, triggers creation of sessions and routes if needed. * * @param instanceHandle instance handle for identification * @param session session * @param topicRoute topic route */ private void addInstanceHandleToMap( final InstanceHandle_t instanceHandle, final Session session, final TopicRoute topicRoute ) { // create topic session if first item discovered if (!mapping.containsKey(session)) { mapping.put(session, ArrayListMultimap.create()); mappingReverse.put(instanceHandle, session); createSession(session); } // check if topic route is about to be created if (!mapping.get(session).containsKey(topicRoute)) { createTopicRoute(session, topicRoute); } // add instance handle to topic route if (!mapping.get(session).get(topicRoute).contains(instanceHandle)) { mapping.get(session).put(topicRoute, instanceHandle); } }
@Override public ListMultimap<String, ForgeChunkManager.Ticket> playerTicketsLoaded(ListMultimap<String, ForgeChunkManager.Ticket> tickets, World world) { // We don't care what order the tickets are in, but filter out the invalid ones ListMultimap<String, ForgeChunkManager.Ticket> validTickets = ArrayListMultimap.create(); for (String playerName : tickets.keySet()) { List<ForgeChunkManager.Ticket> playerTickets = new ArrayList<>(); for (ForgeChunkManager.Ticket tkt : tickets.get(playerName)) { BlockPos ticketPosition = NBTUtil.getPosFromTag(tkt.getModData().getCompoundTag("position")); TileEntity te = world.getTileEntity(ticketPosition); if (te instanceof TileEntityChunkLoader) { playerTickets.add(tkt); } } validTickets.putAll(playerName, playerTickets); } return validTickets; }
private Map<String,HostFragments> createHostFragmentsMap(List<NodeEndpoint> incomingEndpoints) { Multimap<String,Integer> endpointMap = ArrayListMultimap.create(); for (int i = 0; i < incomingEndpoints.size(); i++) { String host = incomingEndpoints.get(i).getAddress(); endpointMap.put(host, i); } List<HostFragments> hostFragments = new ArrayList<>(); for (Entry<String,Collection<Integer>> entry : endpointMap.asMap().entrySet()) { hostFragments.add(new HostFragments(entry.getKey(), entry.getValue())); } return FluentIterable.from(hostFragments) .uniqueIndex(new Function<HostFragments, String>() { @Override public String apply(HostFragments hostFragment) { return hostFragment.host; } }); }
@Override protected SectionRenderable getRenderableContents(RenderContext context) { Model model = getModel(context); List<TaskModerator> moderatorList = workflowService.getModeratorList(model.getTaskId(), true); Multimap<Boolean, ModRow> rows = ArrayListMultimap.create(); for( TaskModerator taskModerator : moderatorList ) { HtmlLinkState link = createLinkForModerator(context, taskModerator); if( link != null ) { rows.put(taskModerator.isAccepted(), new ModRow(link, false)); } } model.setModerators(rows.get(false)); model.setModeratorsAccepted(rows.get(true)); return viewFactory.createResult("moddialog.ftl", this); }
private Multimap<String, TargetListEntry> getTargetListPrivReindexingMap(Set<String> reindexPrivs, TargetList tl) { Multimap<String, TargetListEntry> rv = ArrayListMultimap.create(); if( tl.getEntries() != null ) { for( TargetListEntry entry : tl.getEntries() ) { final String priv = entry.getPrivilege(); if( reindexPrivs.contains(priv) ) { rv.get(priv).add(entry); } } } return rv; }
@Override @Transactional(propagation = Propagation.MANDATORY) public ListMultimap<Item, Attachment> getAttachmentsForItems(Collection<Item> items) { if( items.isEmpty() ) { return ImmutableListMultimap.of(); } List<Attachment> attachments = getHibernateTemplate().findByNamedParam( "select a from Item i join i.attachments a where i in (:items) order by index(a) ASC", "items", items); ListMultimap<Item, Attachment> multiMap = ArrayListMultimap.create(); for( Attachment attachment : attachments ) { multiMap.put(attachment.getItem(), attachment); } return multiMap; }
@Override @Transactional(propagation = Propagation.MANDATORY) public ListMultimap<Long, Attachment> getAttachmentsForItemIds(Collection<Long> ids) { if( ids.isEmpty() ) { return ImmutableListMultimap.of(); } List<Object[]> attachments = getHibernateTemplate().findByNamedParam( "select a, i.id from Item i join i.attachments a where i.id in (:items) order by index(a) ASC", "items", ids); ListMultimap<Long, Attachment> multiMap = ArrayListMultimap.create(); for( Object[] attachmentRow : attachments ) { multiMap.put((Long) attachmentRow[1], (Attachment) attachmentRow[0]); } return multiMap; }
@Override @Transactional(propagation = Propagation.MANDATORY) public ListMultimap<Long, HistoryEvent> getHistoryForItemIds(Collection<Long> ids) { if( ids.isEmpty() ) { return ImmutableListMultimap.of(); } List<Object[]> history = getHibernateTemplate().findByNamedParam( "select h, i.id from Item i join i.history h where i.id in (:items) order by index(h)", "items", ids); ListMultimap<Long, HistoryEvent> multiMap = ArrayListMultimap.create(); for( Object[] historyRow : history ) { multiMap.put((Long) historyRow[1], (HistoryEvent) historyRow[0]); } return multiMap; }
@Override @Transactional(propagation = Propagation.MANDATORY) public ListMultimap<Long, ItemNavigationNode> getNavigationNodesForItemIds(Collection<Long> ids) { if( ids.isEmpty() ) { return ImmutableListMultimap.of(); } List<Object[]> node = getHibernateTemplate().findByNamedParam( "select n, i.id from ItemNavigationNode n join n.item i where i.id in (:items) order by n.index ASC", "items", ids); ListMultimap<Long, ItemNavigationNode> multiMap = ArrayListMultimap.create(); for( Object[] nodeRow : node ) { multiMap.put((Long) nodeRow[1], (ItemNavigationNode) nodeRow[0]); } return multiMap; }
@Override @Transactional(propagation = Propagation.MANDATORY) public Multimap<Long, String> getCollaboratorsForItemIds(Collection<Long> itemIds) { if( itemIds.isEmpty() ) { return ImmutableMultimap.of(); } List<Object[]> attachments = getHibernateTemplate().findByNamedParam( "select c, i.id from Item i join i.collaborators c where i.id in (:items)", "items", itemIds); ListMultimap<Long, String> multiMap = ArrayListMultimap.create(); for( Object[] attachmentRow : attachments ) { multiMap.put((Long) attachmentRow[1], (String) attachmentRow[0]); } return multiMap; }
@Override public ListMultimap<Long, DrmAcceptance> getDrmAcceptancesForItemIds(Collection<Long> itemIds) { if( itemIds.isEmpty() ) { return ImmutableListMultimap.of(); } final List<Object[]> drmAcceptances = getHibernateTemplate().findByNamedParam( "select d, item.id from DrmAcceptance d where item.id in (:items) order by d.date DESC", "items", itemIds); final ListMultimap<Long, DrmAcceptance> multiMap = ArrayListMultimap.create(); for( Object[] asseptRow : drmAcceptances ) { multiMap.put((Long) asseptRow[1], (DrmAcceptance) asseptRow[0]); } return multiMap; }
/** Helper method to verify the number of PartitionSenders in a given fragment endpoint assignments */ private static void verifyAssignment(List<Integer> fragmentList, ArrayListMultimap<Integer, NodeEndpoint> partitionSenderMap) { // We expect at least one entry the list assertTrue(fragmentList.size() > 0); for(Integer majorFragmentId : fragmentList) { // we expect the fragment that has DeMux/HashToRandom as sending exchange to have parallelization with not more // than the number of nodes in the cluster and each node in the cluster can have at most one assignment List<NodeEndpoint> assignments = partitionSenderMap.get(majorFragmentId); assertNotNull(assignments); assertTrue(assignments.size() > 0); assertTrue(String.format("Number of partition senders in major fragment [%d] is more than expected", majorFragmentId), CLUSTER_SIZE >= assignments.size()); // Make sure there are no duplicates in assigned endpoints (i.e at most one partition sender per endpoint) assertTrue("Some endpoints have more than one fragment that has ParitionSender", ImmutableSet.copyOf(assignments).size() == assignments.size()); } }
public FMLModContainer(String className, ModCandidate container, Map<String, Object> modDescriptor) { this.className = className; this.source = container.getModContainer(); this.candidate = container; this.descriptor = modDescriptor; this.eventMethods = ArrayListMultimap.create(); this.modLanguage = (String)modDescriptor.get("modLanguage"); String languageAdapterType = (String)modDescriptor.get("modLanguageAdapter"); if (Strings.isNullOrEmpty(languageAdapterType)) { this.languageAdapter = "scala".equals(modLanguage) ? new ILanguageAdapter.ScalaAdapter() : new ILanguageAdapter.JavaAdapter(); } else { // Delay loading of the adapter until the mod is on the classpath, in case the mod itself contains it. this.languageAdapter = null; FMLLog.finer("Using custom language adapter %s for %s (modid: %s)", languageAdapterType, this.className, getModId()); } sanityCheckModId(); }
/** * Returns a map of the data items. * @return a map of items. * * @see DataMap */ @NonNull @Override public ListMultimap<String, I> getDataMap() { // put all the sets in a multimap. The result is that for each key, // there is a sorted list of items from all the layers, including removed ones. ListMultimap<String, I> fullItemMultimap = ArrayListMultimap.create(); for (S resourceSet : mDataSets) { ListMultimap<String, I> map = resourceSet.getDataMap(); for (Map.Entry<String, Collection<I>> entry : map.asMap().entrySet()) { fullItemMultimap.putAll(entry.getKey(), entry.getValue()); } } return fullItemMultimap; }
/** * Sets the post blob load state to WRITTEN. * * After a load from the blob file, all items have their state set to nothing. * If the load mode is set to incrementalState then we want the items that are in the current * merge result to have their state be WRITTEN. * * This will allow further updates with {@link #mergeData(MergeConsumer, boolean)} to ignore the * state at load time and only apply the new changes. * * @see #loadFromBlob(File, boolean) * @see DataItem#isWritten() */ private void setPostBlobLoadStateToWritten() { ListMultimap<String, I> itemMap = ArrayListMultimap.create(); // put all the sets into list per keys. The order is important as the lower sets are // overridden by the higher sets. for (S dataSet : mDataSets) { ListMultimap<String, I> map = dataSet.getDataMap(); for (Map.Entry<String, Collection<I>> entry : map.asMap().entrySet()) { itemMap.putAll(entry.getKey(), entry.getValue()); } } // the items that represent the current state is the last item in the list for each key. for (String key : itemMap.keySet()) { List<I> itemList = itemMap.get(key); itemList.get(itemList.size() - 1).resetStatusToWritten(); } }
OldAssignmentCreator(List<DrillbitEndpoint> incomingEndpoints, List<T> units) { logger.debug("Assigning {} units to {} endpoints", units.size(), incomingEndpoints.size()); Stopwatch watch = new Stopwatch(); Preconditions.checkArgument(incomingEndpoints.size() <= units.size(), String.format("Incoming endpoints %d " + "is greater than number of row groups %d", incomingEndpoints.size(), units.size())); this.mappings = ArrayListMultimap.create(); this.endpoints = Lists.newLinkedList(incomingEndpoints); ArrayList<T> rowGroupList = new ArrayList<>(units); for (double cutoff : ASSIGNMENT_CUTOFFS) { scanAndAssign(rowGroupList, cutoff, false, false); } scanAndAssign(rowGroupList, 0.0, true, false); scanAndAssign(rowGroupList, 0.0, true, true); logger.debug("Took {} ms to apply assignments", watch.elapsed(TimeUnit.MILLISECONDS)); Preconditions.checkState(rowGroupList.isEmpty(), "All readEntries should be assigned by now, but some are still unassigned"); Preconditions.checkState(!units.isEmpty()); }
private ParquetGroupScan(ParquetGroupScan that) { super(that); this.columns = that.columns == null ? null : Lists.newArrayList(that.columns); this.endpointAffinities = that.endpointAffinities == null ? null : Lists.newArrayList(that.endpointAffinities); this.entries = that.entries == null ? null : Lists.newArrayList(that.entries); this.formatConfig = that.formatConfig; this.formatPlugin = that.formatPlugin; this.fs = that.fs; this.mappings = that.mappings == null ? null : ArrayListMultimap.create(that.mappings); this.rowCount = that.rowCount; this.rowGroupInfos = that.rowGroupInfos == null ? null : Lists.newArrayList(that.rowGroupInfos); this.selectionRoot = that.selectionRoot; this.columnValueCounts = that.columnValueCounts == null ? null : new HashMap(that.columnValueCounts); this.columnTypeMap = that.columnTypeMap == null ? null : new HashMap(that.columnTypeMap); this.partitionValueMap = that.partitionValueMap == null ? null : new HashMap(that.partitionValueMap); this.fileSet = that.fileSet == null ? null : new HashSet(that.fileSet); this.usedMetadataCache = that.usedMetadataCache; this.parquetTableMetadata = that.parquetTableMetadata; }
/** Helper method to verify the number of PartitionSenders in a given fragment endpoint assignments */ private static void verifyAssignment(List<Integer> fragmentList, ArrayListMultimap<Integer, DrillbitEndpoint> partitionSenderMap) { // We expect at least one entry the list assertTrue(fragmentList.size() > 0); for(Integer majorFragmentId : fragmentList) { // we expect the fragment that has DeMux/HashToRandom as sending exchange to have parallelization with not more // than the number of nodes in the cluster and each node in the cluster can have at most one assignment List<DrillbitEndpoint> assignments = partitionSenderMap.get(majorFragmentId); assertNotNull(assignments); assertTrue(assignments.size() > 0); assertTrue(String.format("Number of partition senders in major fragment [%d] is more than expected", majorFragmentId), CLUSTER_SIZE >= assignments.size()); // Make sure there are no duplicates in assigned endpoints (i.e at most one partition sender per endpoint) assertTrue("Some endpoints have more than one fragment that has ParitionSender", ImmutableSet.copyOf(assignments).size() == assignments.size()); } }
private <C,I> void register(Class<? extends I> clazz, ArrayListMultimap<String,Class<? extends I>> methods) { Description desc = clazz.getAnnotation(Description.class); String[] names; if (desc != null) { names = desc.name().split(","); for (int i=0; i<names.length; i++) { names[i] = names[i].trim(); } }else{ names = new String[]{clazz.getName().replace('.', '_')}; } UDFType type = clazz.getAnnotation(UDFType.class); if (type != null && type.deterministic()) { nonDeterministicUDFs.add(clazz); } for(int i=0; i<names.length;i++) { methods.put(names[i].toLowerCase(), clazz); } }
private static ListMultimap<Long, SignPost> siFile(TomtomFolder folder) { ListMultimap<Long, SignPost> signs = ArrayListMultimap.create(); File file = new File(folder.getFile("si.dbf")); if (!file.exists()) { return signs; } log.info("Reading SI {}", file); try (DbfReader reader = new DbfReader(file)) { DbfRow row; while ((row = reader.nextRow()) != null) { if (row.getInt("AMBIG") != 1) { SignPost sign = SignPost.fromRow(row); signs.put(sign.getId(), sign); } } } log.info("Loaded {} si", signs.size()); return signs; }
private static ArrayListMultimap<Long, Speed> loadHsnp(String filename) { File file = new File(filename); ArrayListMultimap<Long, Speed> speeds = ArrayListMultimap.create(); if (!file.exists()) { log.info("File not found : {}", file.getAbsolutePath()); return speeds; } log.info("Reading HSNP {}", file); try (DbfReader reader = new DbfReader(file)) { DbfRow row; while ((row = reader.nextRow()) != null) { Speed speed = parse(row); speeds.put(speed.getId(), speed); } } log.info("Loaded {} speed profile", speeds.size()); return speeds; }
private static Map<Long, List<String>> ldFile(TomtomFolder folder) { File file = new File(folder.getFile("ld.dbf")); if (!file.exists()) { return newHashMap(); } ArrayListMultimap<Long, LaneDirection> directions = ArrayListMultimap.create(); log.info("Reading LD {}", file); try (DbfReader reader = new DbfReader(file)) { DbfRow row; while ((row = reader.nextRow()) != null) { directions.put(row.getLong("ID"), LaneDirection.parse(row.getInt("DIRECTION"), row.getString("VALIDITY"))); } } Map<Long, List<String>> tags = newHashMap(); for (Long id : directions.keySet()) { tags.put(id, asText(directions.get(id))); } log.info("Loaded {} lane directions", directions.size()); return tags; }
private static ArrayListMultimap<Long, SpeedRestriction> loadSpeedRestrictions(String filename) { ArrayListMultimap<Long, SpeedRestriction> restrictions = ArrayListMultimap.create(); File file = new File(filename); if (!file.exists()) { log.info("File not found : {}", file.getAbsolutePath()); return restrictions; } log.info("Reading SR {}", file); try (DbfReader reader = new DbfReader(file)) { DbfRow row; while ((row = reader.nextRow()) != null) { SpeedRestriction restriction = new SpeedRestriction(row.getLong("ID"), row.getInt("SPEED"), Validity.values()[row.getInt("VALDIR") - 1]); restrictions.put(restriction.getId(), restriction); } } log.info("Loaded {} speed restrictions", restrictions.size()); return restrictions; }
public LoadController(Loader loader) { this.loader = loader; this.masterChannel = new EventBus(new SubscriberExceptionHandler() { @Override public void handleException(Throwable exception, SubscriberExceptionContext context) { FMLLog.log("FMLMainChannel", Level.ERROR, exception, "Could not dispatch event: %s to %s", context.getEvent(), context.getSubscriberMethod()); } }); this.masterChannel.register(this); state = LoaderState.NOINIT; packageOwners = ArrayListMultimap.create(); }
/** * Asserts that the given diagnostics contain errors with a message containing "[CheckerName]" * on the given lines of the given file. If there should be multiple errors on a line, the line * number must appear multiple times. There may not be any errors in any other file. */ public void assertErrorsOnLines(String file, List<Diagnostic<? extends JavaFileObject>> diagnostics, long... lines) { ListMultimap<String, Long> actualErrors = ArrayListMultimap.create(); for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics) { String message = diagnostic.getMessage(Locale.US); // The source may be null, e.g. for diagnostics about command-line flags assertNotNull(message, diagnostic.getSource()); String sourceName = diagnostic.getSource().getName(); assertEquals( "unexpected error in source file " + sourceName + ": " + message, file, sourceName); actualErrors.put(diagnostic.getSource().getName(), diagnostic.getLineNumber()); // any errors from the compiler that are not related to this checker should fail assertThat(message).contains("[" + checker.getAnnotation(BugPattern.class).name() + "]"); } assertEquals( ImmutableMultiset.copyOf(Longs.asList(lines)), ImmutableMultiset.copyOf(actualErrors.get(file))); }
@Override public MultimapResource<K> get() { ListMultimap<String, String> multimap = ArrayListMultimap.create(); MultimapResource<K> resource = new MultimapResource<>(key); try (BufferedReader reader = new BufferedReader(new InputStreamReader(path.openStream()))) { String line; while ((line = reader.readLine()) != null) { line = line.trim(); if (line.trim().isEmpty()) { continue; } List<String> fields = Arrays.asList(line.split("\t")); apply(fields, multimap); } } catch (Exception e) { throw new RuntimeException("Error initializing TSV resource.", e); } resource.multimap(ImmutableListMultimap.copyOf(multimap)); resource.mappingFunction(mappingFunction); return resource; }
public static void loadData(ASMDataTable data) { FMLLog.fine("Loading @Config anotation data"); for (ASMData target : data.getAll(Config.class.getName())) { String modid = (String)target.getAnnotationInfo().get("modid"); Multimap<Config.Type, ASMData> map = asm_data.get(modid); if (map == null) { map = ArrayListMultimap.create(); asm_data.put(modid, map); } EnumHolder tholder = (EnumHolder)target.getAnnotationInfo().get("type"); Config.Type type = tholder == null ? Config.Type.INSTANCE : Config.Type.valueOf(tholder.getValue()); map.put(type, target); } }
@Override public int publiceerSchrijfTaken(final SelectieVerwerkTaakBericht selectieTaak, final Collection<VerwerkPersoonResultaat> resultaten) { final ArrayListMultimap<Integer, VerwerkPersoonResultaat> berichtenPerSelectietaak = ArrayListMultimap.create(); for (VerwerkPersoonResultaat resultaat : resultaten) { berichtenPerSelectietaak.put(resultaat.getSelectieTaakId(), resultaat); } final List<SelectieFragmentSchrijfBericht> schrijfTaken = new ArrayList<>(); for (SelectieAutorisatieBericht selectieAutorisatie : selectieTaak.getSelectieAutorisaties()) { final List<VerwerkPersoonResultaat> berichtenVoorAutorisatie = berichtenPerSelectietaak.get(selectieAutorisatie.getSelectietaakId()); if (!berichtenVoorAutorisatie.isEmpty()) { final SelectieFragmentSchrijfBericht bericht = maakSelectieFragmentSchrijfBericht(selectieTaak, selectieAutorisatie, berichtenVoorAutorisatie); schrijfTaken.add(bericht); } } //publiceer xml berichten naar schrijf node if (!schrijfTaken.isEmpty()) { selectieSchrijfTaakPublicatieService.publiceerSchrijfTaken(schrijfTaken); } return schrijfTaken.size(); }
/** * Convert a protobuf UserTablePermissions to a * ListMultimap<String, TablePermission> where key is username. * * @param proto the protobuf UserPermission * @return the converted UserPermission */ public static ListMultimap<String, TablePermission> toUserTablePermissions( AccessControlProtos.UsersAndPermissions proto) { ListMultimap<String, TablePermission> perms = ArrayListMultimap.create(); AccessControlProtos.UsersAndPermissions.UserPermissions userPerm; for (int i = 0; i < proto.getUserPermissionsCount(); i++) { userPerm = proto.getUserPermissions(i); for (int j = 0; j < userPerm.getPermissionsCount(); j++) { TablePermission tablePerm = toTablePermission(userPerm.getPermissions(j)); perms.put(userPerm.getUser().toStringUtf8(), tablePerm); } } return perms; }
private <C,I> void register(Class<? extends I> clazz, ArrayListMultimap<String,Class<? extends I>> methods) { Description desc = clazz.getAnnotation(Description.class); String[] names; if (desc != null) { names = desc.name().split(","); for (int i=0; i<names.length; i++) { names[i] = names[i].trim(); } }else{ names = new String[]{clazz.getName().replace('.', '_')}; } UDFType type = clazz.getAnnotation(UDFType.class); if (type != null && !type.deterministic()) { nonDeterministicUDFs.add(clazz); } for(int i=0; i<names.length;i++) { methods.put(names[i].toLowerCase(), clazz); } }
/** * Reads user permission assignments stored in the <code>l:</code> column * family of the first table row in <code>_acl_</code>. * * <p> * See {@link AccessControlLists class documentation} for the key structure * used for storage. * </p> */ static ListMultimap<String, TablePermission> getPermissions(Configuration conf, byte[] entryName) throws IOException { if (entryName == null) entryName = ACL_GLOBAL_NAME; // for normal user tables, we just read the table row from _acl_ ListMultimap<String, TablePermission> perms = ArrayListMultimap.create(); // TODO: Pass in a Connection rather than create one each time. try (Connection connection = ConnectionFactory.createConnection(conf)) { try (Table table = connection.getTable(ACL_TABLE_NAME)) { Get get = new Get(entryName); get.addFamily(ACL_LIST_FAMILY); Result row = table.get(get); if (!row.isEmpty()) { perms = parsePermissions(entryName, row); } else { LOG.info("No permissions found in " + ACL_TABLE_NAME + " for acl entry " + Bytes.toString(entryName)); } } } return perms; }
public RoundRobinOperator(TunnelProvider tunnelProvider, OperatorContext context, RoundRobinSender config) throws OutOfMemoryException { super(config); this.config = config; this.allocator = context.getAllocator(); this.handle = context.getFragmentHandle(); this.stats = context.getStats(); List<MinorFragmentEndpoint> destinations = config.getDestinations(); final ArrayListMultimap<NodeEndpoint, Integer> dests = ArrayListMultimap.create(); for(MinorFragmentEndpoint destination : destinations) { dests.put(destination.getEndpoint(), destination.getId()); } this.tunnels = new ArrayList<>(); this.minorFragments = new ArrayList<>(); for(final NodeEndpoint ep : dests.keySet()){ List<Integer> minorsList= dests.get(ep); minorFragments.add(minorsList); tunnels.add(tunnelProvider.getExecTunnel(ep)); } int destCount = dests.keySet().size(); this.currentTunnelsIndex = ThreadLocalRandom.current().nextInt(destCount); this.currentMinorFragmentsIndex = ThreadLocalRandom.current().nextInt(minorFragments.get(currentTunnelsIndex).size()); }
private static ListMultimap<String, LocalJava> indexByPath(ModelMap<LocalJava> localJavaInstalls) { final ListMultimap<String, LocalJava> index = ArrayListMultimap.create(); for (LocalJava localJava : localJavaInstalls) { try { index.put(localJava.getPath().getCanonicalPath(), localJava); } catch (IOException e) { // ignore this installation for validation, it will be caught later } } return index; }
private static void addDependency(List<IvyDependencyMetadata> result, DependencyDescriptor dependencyDescriptor) { ModuleRevisionId revisionId = dependencyDescriptor.getDependencyRevisionId(); ModuleVersionSelector requested = DefaultModuleVersionSelector.newSelector(revisionId.getOrganisation(), revisionId.getName(), revisionId.getRevision()); ListMultimap<String, String> configMappings = ArrayListMultimap.create(); for (Map.Entry<String, List<String>> entry : readConfigMappings(dependencyDescriptor).entrySet()) { configMappings.putAll(entry.getKey(), entry.getValue()); } List<Artifact> artifacts = Lists.newArrayList(); for (DependencyArtifactDescriptor ivyArtifact : dependencyDescriptor.getAllDependencyArtifacts()) { IvyArtifactName ivyArtifactName = new DefaultIvyArtifactName(ivyArtifact.getName(), ivyArtifact.getType(), ivyArtifact.getExt(), (String) ivyArtifact.getExtraAttributes().get(CLASSIFIER)); artifacts.add(new Artifact(ivyArtifactName, Sets.newHashSet(ivyArtifact.getConfigurations()))); } List<Exclude> excludes = Lists.newArrayList(); for (ExcludeRule excludeRule : dependencyDescriptor.getAllExcludeRules()) { excludes.add(forIvyExclude(excludeRule)); } result.add(new IvyDependencyMetadata( requested, dependencyDescriptor.getDynamicConstraintDependencyRevisionId().getRevision(), false, dependencyDescriptor.isChanging(), dependencyDescriptor.isTransitive(), configMappings, artifacts, excludes)); }
private List<HasAttributes> selectClosestMatches(List<HasAttributes> fullMatches) { Set<Attribute<?>> requestedAttributes = consumerAttributesContainer.keySet(); // if there's more than one compatible match, prefer the closest. However there's a catch. // We need to look at all candidates globally, and select the closest match for each attribute // then see if there's a non-empty intersection. List<HasAttributes> remainingMatches = Lists.newArrayList(fullMatches); List<HasAttributes> best = Lists.newArrayListWithCapacity(fullMatches.size()); final ListMultimap<AttributeValue<Object>, HasAttributes> candidatesByValue = ArrayListMultimap.create(); for (Attribute<?> attribute : requestedAttributes) { Object requestedValue = consumerAttributesContainer.getAttribute(attribute); for (HasAttributes match : fullMatches) { Map<Attribute<Object>, AttributeValue<Object>> matchedAttributes = matchDetails.get(match).matchesByAttribute; candidatesByValue.put(matchedAttributes.get(attribute), match); } final AttributeValue<Object> requested = AttributeValue.of(requestedValue); disambiguate(remainingMatches, candidatesByValue, requested, consumerAttributeSchema.getMatchingStrategy(attribute), best); if (remainingMatches.isEmpty()) { // the intersection is empty, so we cannot choose return fullMatches; } candidatesByValue.clear(); best.clear(); } if (!remainingMatches.isEmpty()) { // there's a subset (or not) of best matches return remainingMatches; } return null; }