Refine search
/** * Registers the given type with the serialization stack. If the type is eventually * serialized as a POJO, then the type is registered with the POJO serializer. If the * type ends up being serialized with Kryo, then it will be registered at Kryo to make * sure that only tags are written. * * @param type The class of the type to register. */ public void registerPojoType(Class<?> type) { if (type == null) { throw new NullPointerException("Cannot register null type class."); } if (!registeredPojoTypes.contains(type)) { registeredPojoTypes.add(type); } }
/** * Returns the registered Kryo types. */ public LinkedHashSet<Class<?>> getRegisteredKryoTypes() { if (isForceKryoEnabled()) { // if we force kryo, we must also return all the types that // were previously only registered as POJO LinkedHashSet<Class<?>> result = new LinkedHashSet<>(); result.addAll(registeredKryoTypes); for(Class<?> t : registeredPojoTypes) { if (!result.contains(t)) { result.add(t); } } return result; } else { return registeredKryoTypes; } }
private static Iterable<String> getDistinctPhasesInOrderOfExecutionPlanAppearance( List<ExecutionPlanItem> planItems ) { LinkedHashSet<String> result = new LinkedHashSet<>(); for ( ExecutionPlanItem executionPlanItem : planItems ) { final String phase = executionPlanItem.getLifecyclePhase(); if ( !result.contains( phase ) ) { result.add( phase ); } } return result; }
/** * Get collection of all {@link ServiceHolder}s bound for providers (custom and default) registered for the given service * provider contract in the underlying {@link InjectionManager injection manager} container. * * @param <T> service provider contract Java type. * @param injectionManager underlying injection manager. * @param contract service provider contract. * @return set of all available service provider instances for the contract */ public static <T> Collection<ServiceHolder<T>> getAllServiceHolders(InjectionManager injectionManager, Class<T> contract) { List<ServiceHolder<T>> providers = getServiceHolders(injectionManager, contract, Comparator.comparingInt(Providers::getPriority), CustomAnnotationLiteral.INSTANCE); providers.addAll(getServiceHolders(injectionManager, contract)); LinkedHashSet<ServiceHolder<T>> providersSet = new LinkedHashSet<>(); for (ServiceHolder<T> provider : providers) { if (!providersSet.contains(provider)) { providersSet.add(provider); } } return providersSet; }
/** * Get collection of all {@link ServiceHolder}s bound for providers (custom and default) registered for the given service * provider contract in the underlying {@link InjectionManager injection manager} container. * * @param <T> service provider contract Java type. * @param injectionManager underlying injection manager. * @param contract service provider contract. * @return set of all available service provider instances for the contract */ public static <T> Collection<ServiceHolder<T>> getAllServiceHolders(InjectionManager injectionManager, Class<T> contract) { List<ServiceHolder<T>> providers = getServiceHolders(injectionManager, contract, Comparator.comparingInt(Providers::getPriority), CustomAnnotationLiteral.INSTANCE); providers.addAll(getServiceHolders(injectionManager, contract)); LinkedHashSet<ServiceHolder<T>> providersSet = new LinkedHashSet<>(); for (ServiceHolder<T> provider : providers) { if (!providersSet.contains(provider)) { providersSet.add(provider); } } return providersSet; }
String name = StringUtil.decapitalize(callReference.getIdentifier().getText()); for (String candidate : NameUtil.getSuggestionsByName(name, "", "", false, false, false)) { if (usedNames.contains(candidate)) continue; if (!isValidName(namesValidator, candidate)) continue; names.add(candidate); boolean array = GoTypeUtil.isIterable(type) && !GoTypeUtil.isString(type); for (String candidate : NameUtil.getSuggestionsByName(typeText, "", "", false, false, array)) { if (usedNames.contains(candidate) || typeText.equals(candidate)) continue; if (!isValidName(namesValidator, candidate)) continue; names.add(candidate); names.add(UniqueNameGenerator.generateUniqueName("i", usedNames));
public RelNode align(Aggregate rel, List<RelFieldCollation> collations) { // 1) We extract the group by positions that are part of the collations and // sort them so they respect it LinkedHashSet<Integer> aggregateColumnsOrder = new LinkedHashSet<>(); ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder(); if (rel.getGroupType() == Group.SIMPLE && !collations.isEmpty()) { for (RelFieldCollation c : collations) { if (c.getFieldIndex() < rel.getGroupCount()) { // Group column found if (aggregateColumnsOrder.add(c.getFieldIndex())) { propagateCollations.add(c.copy(rel.getGroupSet().nth(c.getFieldIndex()))); } } } } for (int i = 0; i < rel.getGroupCount(); i++) { if (!aggregateColumnsOrder.contains(i)) { // Not included in the input collations, but can be propagated as this Aggregate // will enforce it propagateCollations.add(new RelFieldCollation(rel.getGroupSet().nth(i))); } } // 2) We propagate final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build()); // 3) We annotate the Aggregate operator with this info final HiveAggregate newAggregate = (HiveAggregate) rel.copy(rel.getTraitSet(), ImmutableList.of(child)); newAggregate.setAggregateColumnsOrder(aggregateColumnsOrder); return newAggregate; }
retainableOps.add(equalOp1); discardableOps.add(equalOp2); if (equalOp1 instanceof MapJoinOperator) { MapJoinOperator mop = (MapJoinOperator) equalOp1; if (op instanceof MapJoinOperator && !retainableOps.contains(op)) { MapJoinOperator mop = (MapJoinOperator) op; dataSize = StatsUtils.safeAdd(dataSize, mop.getConf().getInMemoryDataSize()); if (op instanceof MapJoinOperator && !discardableOps.contains(op)) { MapJoinOperator mop = (MapJoinOperator) op; dataSize = StatsUtils.safeAdd(dataSize, mop.getConf().getInMemoryDataSize());
public RelNode align(Aggregate rel, List<RelFieldCollation> collations) { // 1) We extract the group by positions that are part of the collations and // sort them so they respect it LinkedHashSet<Integer> aggregateColumnsOrder = new LinkedHashSet<>(); ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder(); if (!rel.indicator && !collations.isEmpty()) { for (RelFieldCollation c : collations) { if (c.getFieldIndex() < rel.getGroupCount()) { // Group column found if (aggregateColumnsOrder.add(c.getFieldIndex())) { propagateCollations.add(c.copy(rel.getGroupSet().nth(c.getFieldIndex()))); } } } } for (int i = 0; i < rel.getGroupCount(); i++) { if (!aggregateColumnsOrder.contains(i)) { // Not included in the input collations, but can be propagated as this Aggregate // will enforce it propagateCollations.add(new RelFieldCollation(rel.getGroupSet().nth(i))); } } // 2) We propagate final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build()); // 3) We annotate the Aggregate operator with this info final HiveAggregate newAggregate = (HiveAggregate) rel.copy(rel.getTraitSet(), ImmutableList.of(child)); newAggregate.setAggregateColumnsOrder(aggregateColumnsOrder); return newAggregate; }
/** * Add a column to the table layout. Each column must have a unique, non-null * name. * * @param name The column name. * @return The builder, for chaining. * @throws IllegalArgumentException if the column already exists. */ public TableLayoutBuilder addColumn(String name) { if (name == null) { throw new NullPointerException("column name"); } if (columns.contains(name)) { throw new IllegalArgumentException("column " + name + " already exists"); } columns.add(name); return this; }
private Set<LinkedHashSet<ThreadInfo>> calculateCycles(Map<Long, ThreadInfo> threadInfoMap) { Set<LinkedHashSet<ThreadInfo>> cycles = new HashSet<>(); for (Map.Entry<Long, ThreadInfo> entry : threadInfoMap.entrySet()) { LinkedHashSet<ThreadInfo> cycle = new LinkedHashSet<>(); for (ThreadInfo t = entry.getValue(); !cycle.contains(t); t = threadInfoMap.get(Long.valueOf(t.getLockOwnerId()))) { cycle.add(t); } if (!cycles.contains(cycle)) { cycles.add(cycle); } } return cycles; }
public synchronized void markSuspectBlock(ExtendedBlock block) { if (stopping) { LOG.debug("{}: Not scheduling suspect block {} for " + "rescanning, because this volume scanner is stopping.", this, block); return; } Boolean recent = recentSuspectBlocks.getIfPresent(block); if (recent != null) { LOG.debug("{}: Not scheduling suspect block {} for " + "rescanning, because we rescanned it recently.", this, block); return; } if (suspectBlocks.contains(block)) { LOG.debug("{}: suspect block {} is already queued for " + "rescanning.", this, block); return; } suspectBlocks.add(block); recentSuspectBlocks.put(block, true); LOG.debug("{}: Scheduling suspect block {} for rescanning.", this, block); notify(); // wake scanner thread. }
@Override public void checkCyclesStart(Class clazz, String name) { final Pair pair = new Pair(clazz, name); final LinkedHashSet<Pair> linkedHashSet = cycleDetectionStack.get(); if (linkedHashSet.contains(pair)) { throw new CyclicDependencyException(Pair.getClassList(linkedHashSet), clazz); } linkedHashSet.add(pair); }
private Set<LinkedHashSet<ThreadInfo>> calculateCycleDeadlockChains(Map<Long, ThreadInfo> threadInfoMap, Set<LinkedHashSet<ThreadInfo>> cycles) { ThreadInfo allThreads[] = threadBean.getThreadInfo(threadBean.getAllThreadIds()); Set<LinkedHashSet<ThreadInfo>> deadlockChain = new HashSet<>(); Set<Long> knownDeadlockedThreads = threadInfoMap.keySet(); for (ThreadInfo threadInfo : allThreads) { Thread.State state = threadInfo.getThreadState(); if (state == Thread.State.BLOCKED && !knownDeadlockedThreads.contains(threadInfo.getThreadId())) { for (LinkedHashSet<ThreadInfo> cycle : cycles) { if (cycle.contains(threadInfoMap.get(Long.valueOf(threadInfo.getLockOwnerId())))) { LinkedHashSet<ThreadInfo> chain = new LinkedHashSet<>(); ThreadInfo node = threadInfo; while (!chain.contains(node)) { chain.add(node); node = threadInfoMap.get(Long.valueOf(node.getLockOwnerId())); } deadlockChain.add(chain); } } } } return deadlockChain; }
private static void addSortedBundle(Bundle bundle, Map<String, Bundle> bundles, LinkedHashSet<Bundle> sortedBundles, LinkedHashSet<String> dependencyStack) { String name = bundle.plugin.getName(); if (dependencyStack.contains(name)) { StringBuilder msg = new StringBuilder("Cycle found in plugin dependencies: "); dependencyStack.forEach(s -> { msg.append(s); msg.append(" -> "); }); msg.append(name); throw new IllegalStateException(msg.toString()); } if (sortedBundles.contains(bundle)) { // already added this plugin, via a dependency return; } dependencyStack.add(name); for (String dependency : bundle.plugin.getExtendedPlugins()) { Bundle depBundle = bundles.get(dependency); if (depBundle == null) { throw new IllegalArgumentException("Missing plugin [" + dependency + "], dependency of [" + name + "]"); } addSortedBundle(depBundle, bundles, sortedBundles, dependencyStack); assert sortedBundles.contains(depBundle); } dependencyStack.remove(name); sortedBundles.add(bundle); }