public ValuesOperatorFactory( int operatorId, PlanNodeId planNodeId, List<Type> types, List<Page> pages) { this.operatorId = operatorId; this.planNodeId = requireNonNull(planNodeId, "planNodeId is null"); this.types = ImmutableList.copyOf(requireNonNull(types, "types is null")); this.pages = ImmutableList.copyOf(requireNonNull(pages, "pages is null")); }
static { ImmutableSet.Builder<Integer> intValues = ImmutableSet.builder(); // Add boundary values manually to avoid over/under flow (this covers 2^N for 0 and 31). intValues.add(Integer.MAX_VALUE - 1, Integer.MAX_VALUE); // Add values up to 40. This covers cases like "square of a prime" and such. for (int i = 1; i <= 40; i++) { intValues.add(i); } // Now add values near 2^N for lots of values of N. for (int exponent : asList(2, 3, 4, 9, 15, 16, 17, 24, 25, 30)) { int x = 1 << exponent; intValues.add(x, x + 1, x - 1); } intValues.add(9999).add(10000).add(10001).add(1000000); // near powers of 10 intValues.add(5792).add(5793); // sqrt(2^25) rounded up and down POSITIVE_INTEGER_CANDIDATES = intValues.build(); NEGATIVE_INTEGER_CANDIDATES = ImmutableList.copyOf( Iterables.concat( Iterables.transform(POSITIVE_INTEGER_CANDIDATES, NEGATE_INT), ImmutableList.of(Integer.MIN_VALUE))); NONZERO_INTEGER_CANDIDATES = ImmutableList.copyOf( Iterables.concat(POSITIVE_INTEGER_CANDIDATES, NEGATIVE_INTEGER_CANDIDATES)); ALL_INTEGER_CANDIDATES = Iterables.concat(NONZERO_INTEGER_CANDIDATES, ImmutableList.of(0)); }
/** * Constructs a MultiJoin. * * @param cluster cluster that join belongs to * @param inputs inputs into this multi-join * @param condition join filter applicable to this join node * @param rowType row type of the join result of this node * @param joinInputs * @param joinTypes the join type corresponding to each input; if an input is null-generating in a * left or right outer join, the entry indicates the type of outer join; otherwise, the entry * is set to INNER * @param filters filters associated with each join input * @param joinPredicateInfo join predicate information */ public HiveMultiJoin( RelOptCluster cluster, List<RelNode> inputs, RexNode condition, RelDataType rowType, List<Pair<Integer, Integer>> joinInputs, List<JoinRelType> joinTypes, List<RexNode> filters, JoinPredicateInfo joinPredicateInfo) { super(cluster, TraitsUtil.getDefaultTraitSet(cluster)); this.inputs = inputs; this.condition = condition; this.rowType = rowType; assert joinInputs.size() == joinTypes.size(); this.joinInputs = ImmutableList.copyOf(joinInputs); this.joinTypes = ImmutableList.copyOf(joinTypes); this.filters = ImmutableList.copyOf(filters); this.outerJoin = containsOuter(); if (joinPredicateInfo == null) { try { this.joinPredInfo = HiveCalciteUtil.JoinPredicateInfo.constructJoinPredicateInfo(this); } catch (CalciteSemanticException e) { throw new RuntimeException(e); } } else { this.joinPredInfo = joinPredicateInfo; } }
protected ImmutableList<NodeT> childrenInOrder(final Iterable<NodeT> children) { if (headInitial) { return ImmutableList.copyOf(children); } else { return ImmutableList.copyOf(children).reverse(); } }
public LocalResourceContainer build() { return new LocalResourceContainer( ImmutableList.copyOf(resources), ImmutableList.copyOf(resourceRoots), ImmutableList.copyOf(assets), ImmutableList.copyOf(assetRoots)); }
/** Returns the changes comparing this nodes to the provided nodes. */ public Delta delta(DiscoveryNodes other) { List<DiscoveryNode> removed = newArrayList(); List<DiscoveryNode> added = newArrayList(); for (DiscoveryNode node : other) { if (!this.nodeExists(node.id())) { removed.add(node); } } for (DiscoveryNode node : this) { if (!other.nodeExists(node.id())) { added.add(node); } } DiscoveryNode previousMasterNode = null; DiscoveryNode newMasterNode = null; if (masterNodeId != null) { if (other.masterNodeId == null || !other.masterNodeId.equals(masterNodeId)) { previousMasterNode = other.masterNode(); newMasterNode = masterNode(); } } return new Delta( previousMasterNode, newMasterNode, localNodeId, ImmutableList.copyOf(removed), ImmutableList.copyOf(added)); }
private void assertConfigurationIds(String resourcePath, String... configurationIds) { List<String> expectedConfigurationIds = ImmutableList.copyOf(configurationIds); when(resource.getPath()).thenReturn(resourcePath); List<String> detectedConfigurationIds = ImmutableList.copyOf(underTest.findConfigurationIds(resource)); assertEquals(expectedConfigurationIds, detectedConfigurationIds); }
@Test public void testCommitsSurviveShutDown() throws Exception { GeoGIG geogig = helper.getGeogig(); insert(); update(); List<RevCommit> expected = ImmutableList.copyOf(geogig.command(LogOp.class).call()); File repoDir = helper.getRepositoryDirectory(); assertTrue(repoDir.exists() && repoDir.isDirectory()); // shut down server destroyGeoServer(); TestPlatform testPlatform = new TestPlatform(repoDir); Context context = new CLITestContextBuilder(testPlatform).build(); geogig = new GeoGIG(context); try { assertNotNull(geogig.getRepository()); List<RevCommit> actual = ImmutableList.copyOf(geogig.command(LogOp.class).call()); assertEquals(expected, actual); } finally { geogig.close(); } }
@VisibleForTesting // productionVisibility = Visibility.PRIVATE public CppCompilationContext build(ActionOwner owner, MiddlemanFactory middlemanFactory) { // We don't create middlemen in LIPO collector subtree, because some target CT // will do that instead. Artifact prerequisiteStampFile = (ruleContext != null && ruleContext.getFragment(CppConfiguration.class).isLipoContextCollector()) ? getMiddlemanArtifact(middlemanFactory) : createMiddleman(owner, middlemanFactory); return new CppCompilationContext( new CommandLineContext( ImmutableList.copyOf(includeDirs), ImmutableList.copyOf(quoteIncludeDirs), ImmutableList.copyOf(systemIncludeDirs), ImmutableList.copyOf(defines)), prerequisiteStampFile == null ? ImmutableSet.<Artifact>of() : ImmutableSet.of(prerequisiteStampFile), declaredIncludeDirs.build(), declaredIncludeWarnDirs.build(), declaredIncludeSrcs.build(), pregreppedHdrs.build(), moduleInfo.build(), picModuleInfo.build(), transitiveModuleMaps.build(), directModuleMaps.build(), cppModuleMap, provideTransitiveModuleMaps, useHeaderModules); }
/** * Constructs a {@code TestReport} instance. * * @param buildId the build id. * @param buildDate the build date. * @param buildDuration the build duration. * @param numberOfPassedTests the number of passed tests. * @param numberOfIgnoredTests the number of ignored tests. * @param numberOfFailedTests the number of failed tests. * @param failedTests the failed tests. * @param ignoredTests the ignored tests. * @throws java.lang.NullPointerException if {@code buildTypeId}, {@code buildDate} and/or {@code * failedTests} are {@code null}. * @throws java.lang.IllegalArgumentException if {@code buildTypeId} is empty. */ public TestReport( String buildTypeId, int buildId, Date buildDate, long buildDuration, int numberOfPassedTests, int numberOfIgnoredTests, int numberOfFailedTests, List<Test> failedTests, List<Test> ignoredTests) { checkNotNull(buildDate, "'buildDate' parameter cannot be null"); checkNotNull(failedTests, "'failedTests' parameter cannot be null"); checkNotNull(buildTypeId, "'buildTypeId' parameter cannot be null"); checkArgument(!buildTypeId.isEmpty(), "'buildTypeId' parameter cannot be empty"); this.buildTypeId = buildTypeId; this.buildId = buildId; this.buildDate = buildDate; this.buildDuration = buildDuration; this.numberOfPassedTests = numberOfPassedTests; this.numberOfIgnoredTests = numberOfIgnoredTests; this.numberOfFailedTests = numberOfFailedTests; this.failedTests = ImmutableList.copyOf(failedTests); this.ignoredTests = ImmutableList.copyOf(ignoredTests); }
private Implementation( Signature signature, boolean nullable, List<Boolean> nullableArguments, MethodHandle methodHandle, List<ImplementationDependency> dependencies, Optional<MethodHandle> constructor, List<ImplementationDependency> constructorDependencies, List<Class<?>> argumentNativeContainerTypes, Map<String, Class<?>> specializedTypeParameters) { this.signature = requireNonNull(signature, "signature is null"); this.nullable = nullable; this.nullableArguments = ImmutableList.copyOf(requireNonNull(nullableArguments, "nullableArguments is null")); this.methodHandle = requireNonNull(methodHandle, "methodHandle is null"); this.dependencies = ImmutableList.copyOf(requireNonNull(dependencies, "dependencies is null")); this.constructor = requireNonNull(constructor, "constructor is null"); this.constructorDependencies = ImmutableList.copyOf( requireNonNull(constructorDependencies, "constructorDependencies is null")); this.argumentNativeContainerTypes = ImmutableList.copyOf( requireNonNull(argumentNativeContainerTypes, "argumentNativeContainerTypes is null")); this.specializedTypeParameters = ImmutableMap.copyOf( requireNonNull(specializedTypeParameters, "specializedTypeParameters is null")); }
private ReflectionParametricScalar( Signature signature, String description, boolean hidden, Map<Signature, Implementation> exactImplementations, List<Implementation> specializedImplementations, List<Implementation> implementations, boolean deterministic) { super( signature.getName(), signature.getTypeParameterRequirements(), signature.getReturnType().toString(), signature .getArgumentTypes() .stream() .map(TypeSignature::toString) .collect(toImmutableList())); this.description = description; this.hidden = hidden; this.exactImplementations = ImmutableMap.copyOf(requireNonNull(exactImplementations, "exactImplementations is null")); this.specializedImplementations = ImmutableList.copyOf( requireNonNull(specializedImplementations, "specializedImplementations is null")); this.implementations = ImmutableList.copyOf(requireNonNull(implementations, "implementations is null")); this.deterministic = deterministic; }
@SuppressWarnings({"null", "unchecked"}) public static final Collection<? extends Player> getOnlinePlayers() { if (hasCollecionGetOnlinePlayers) { return ImmutableList.copyOf(Bukkit.getOnlinePlayers()); } else { if (getOnlinePlayers == null) { try { getOnlinePlayers = Bukkit.class.getDeclaredMethod("getOnlinePlayers"); } catch (final NoSuchMethodException e) { Skript.outdatedError(e); } catch (final SecurityException e) { Skript.exception(e); } } try { final Object o = getOnlinePlayers.invoke(null); if (o instanceof Collection<?>) return ImmutableList.copyOf((Collection<? extends Player>) o); else return Arrays.asList(((Player[]) o).clone()); } catch (final IllegalAccessException e) { Skript.outdatedError(e); } catch (final IllegalArgumentException e) { Skript.outdatedError(e); } catch (final InvocationTargetException e) { Skript.exception(e); } return Collections.emptyList(); } }
static { OBJECT_MAPPER.configure(JsonParser.Feature.ALLOW_COMMENTS, true); // Jackson 1.2+ VALID_QUERIES = ImmutableList.copyOf(loadResource(VALID_QUERIES_RESOURCE_PATH, ValidQuery[].class)); IN_VALID_QUERIES = ImmutableList.copyOf(loadResource(INVALID_QUERIES_RESOURCE_PATH, InvalidQuery[].class)); }
@Test public void testContinuousSettings() throws Exception { Map<String, Object> mb = ImmutableMap.<String, Object>builder() .put("inbound.column-names", ImmutableList.of("a", "b", "c", "d", "e")) .put("inbound.id-columns", ImmutableList.of("a")) .put("inbound.numeric-columns", ImmutableList.of(1, "e")) .put("inbound.ignored-columns", ImmutableList.of("c")) .build(); Config conf = overlayConfigOnDefault(mb); InboundSettings settings = InboundSettings.create(conf); assertEquals(ImmutableList.of(0), ImmutableList.copyOf(settings.getIdColumns())); assertEquals(ImmutableList.of(3), ImmutableList.copyOf(settings.getCategoricalColumns())); assertEquals(ImmutableList.of(1, 4), ImmutableList.copyOf(settings.getNumericColumns())); assertEquals(ImmutableList.of(2), ImmutableList.copyOf(settings.getIgnoredColumns())); assertNull(settings.getTargetColumn()); /* Spec spec = settings.getSpec(); Assert.assertEquals(5, spec.size()); Assert.assertEquals(DataType.STRING, spec.getField(0).spec().getDataType()); Assert.assertEquals(DataType.DOUBLE, spec.getField(1).spec().getDataType()); Assert.assertEquals(DataType.STRING, spec.getField(2).spec().getDataType()); */ }
public void setOutputValues(Iterable<?> objects) { if (objects == null) { viewer.setOutputValues(ImmutableList.of()); } else { Iterable<?> nonNulls = Iterables.filter(objects, Predicates.notNull()); viewer.setOutputValues(ImmutableList.copyOf(ImmutableList.copyOf(nonNulls))); } }
public ValuesOperator(OperatorContext operatorContext, List<Type> types, List<Page> pages) { this.operatorContext = requireNonNull(operatorContext, "operatorContext is null"); this.types = ImmutableList.copyOf(requireNonNull(types, "types is null")); requireNonNull(pages, "pages is null"); this.pages = ImmutableList.copyOf(pages).iterator(); }
public List<ITrait> getAllTraitsForStats(String stats) { if (this.traits.containsKey(stats)) { return ImmutableList.copyOf(this.traits.get(stats)); } else if (this.traits.containsKey(null)) { return ImmutableList.copyOf(this.traits.get(null)); } return ImmutableList.of(); }
/** * Construct a new immutable copy of the given method contract. * * @param other - the contract to clone. * @return A immutable copy of the given contract. */ private static FuzzyMethodContract immutableCopy(FuzzyMethodContract other) { FuzzyMethodContract copy = new FuzzyMethodContract(other); // Ensure that the lists are immutable copy.paramMatchers = ImmutableList.copyOf(copy.paramMatchers); copy.exceptionMatchers = ImmutableList.copyOf(copy.exceptionMatchers); return copy; }
public void testCopyOf_collection_general() { Collection<String> c = MinimalCollection.of("a", "b", "a"); List<String> list = ImmutableList.copyOf(c); assertEquals(asList("a", "b", "a"), list); List<String> mutableList = asList("a", "b"); list = ImmutableList.copyOf(mutableList); mutableList.set(0, "c"); assertEquals(asList("a", "b"), list); }
private Cli( String name, String description, TypeConverter typeConverter, Class<? extends C> defaultCommand, Iterable<Class<? extends C>> defaultGroupCommands, Iterable<GroupBuilder<C>> groups) { Preconditions.checkNotNull(name, "name is null"); Preconditions.checkNotNull(typeConverter, "typeConverter is null"); CommandMetadata defaultCommandMetadata = null; if (defaultCommand != null) { defaultCommandMetadata = MetadataLoader.loadCommand(defaultCommand); } final List<CommandMetadata> allCommands = new ArrayList<CommandMetadata>(); List<CommandMetadata> defaultCommandGroup = Lists.newArrayList(MetadataLoader.loadCommands(defaultGroupCommands)); // currentlly the default command is required to be in the commands list. If that changes, we'll // need to add it here and add checks for existence allCommands.addAll(defaultCommandGroup); List<CommandGroupMetadata> commandGroups = Lists.newArrayList( Iterables.transform( groups, new Function<GroupBuilder<C>, CommandGroupMetadata>() { public CommandGroupMetadata apply(GroupBuilder<C> group) { CommandMetadata groupDefault = MetadataLoader.loadCommand(group.defaultCommand); List<CommandMetadata> groupCommands = MetadataLoader.loadCommands(group.commands); // currentlly the default command is required to be in the commands list. If // that changes, we'll need to add it here and add checks for existence allCommands.addAll(groupCommands); return MetadataLoader.loadCommandGroup( group.name, group.description, groupDefault, groupCommands); } })); // add commands to groups based on the value of groups in the @Command annotations // rather than change the entire way metadata is loaded, I figured just post-processing was an // easier, yet uglier, way to go MetadataLoader.loadCommandsIntoGroupsByAnnotation( allCommands, commandGroups, defaultCommandGroup); this.metadata = MetadataLoader.loadGlobal( name, description, defaultCommandMetadata, ImmutableList.copyOf(defaultCommandGroup), ImmutableList.copyOf(commandGroups)); }
private HdfsPartition( List<LiteralExpr> partitionKeyValues, HdfsStorageDescriptor fileFormatDescriptor, List<HdfsPartition.FileDescriptor> fileDescriptors, long id) { this.partitionKeyValues = ImmutableList.copyOf(partitionKeyValues); this.fileDescriptors = ImmutableList.copyOf(fileDescriptors); this.fileFormatDescriptor = fileFormatDescriptor; this.id = id; }
public FunctionDefStatement( Identifier ident, Iterable<Parameter<Expression, Expression>> parameters, FunctionSignature.WithValues<Expression, Expression> signature, Iterable<Statement> statements) { this.ident = ident; this.signature = signature; this.statements = ImmutableList.copyOf(statements); this.parameters = ImmutableList.copyOf(parameters); }
// where not pre-sorted @ImmutableConstructor private CurveCurrencyParameterSensitivities( List<? extends CurveCurrencyParameterSensitivity> sensitivities) { if (sensitivities.size() < 2) { this.sensitivities = ImmutableList.copyOf(sensitivities); } else { List<CurveCurrencyParameterSensitivity> mutable = new ArrayList<>(sensitivities); mutable.sort(CurveCurrencyParameterSensitivity::compareKey); this.sensitivities = ImmutableList.copyOf(mutable); } }
/** * Constructs a ApplicationBundler. * * @param excludePackages Class packages to exclude * @param includePackages Always includes classes/resources in these packages. Note that classes * in these packages will not get inspected for dependencies. */ public ApplicationBundler(Iterable<String> excludePackages, Iterable<String> includePackages) { this.excludePackages = ImmutableList.copyOf(excludePackages); this.includePackages = ImmutableList.copyOf(includePackages); this.acceptClassPath = Sets.difference( Sets.newHashSet( Splitter.on(File.pathSeparatorChar).split(System.getProperty("java.class.path"))), Sets.newHashSet( Splitter.on(File.pathSeparatorChar) .split(System.getProperty("sun.boot.class.path")))); }
private static IterablesChain<Artifact> getArchiveInputs( JavaTargetAttributes attributes, Function<Artifact, Artifact> derivedJarFunction) { IterablesChain.Builder<Artifact> inputs = IterablesChain.builder(); inputs.add( ImmutableList.copyOf( Iterables.transform(attributes.getRuntimeClassPathForArchive(), derivedJarFunction))); // TODO(bazel-team): Remove? Resources not used as input to singlejar action inputs.add(ImmutableList.copyOf(attributes.getResources().values())); inputs.add(attributes.getClassPathResources()); return inputs.build(); }
/** * Utility class for handling some stuff in regards to JEI.<br> * Most (if not all) the code in this class has been ripped off<br> * from something within JEI and adjusted for AbyssalCraft use.<br> * Because of the above statement, some of it could work less<br> * compared to the JEI code (since this class is initialized<br> * at a different time, among things). */ public JEIUtils(IItemRegistry registry) { List<ItemStack> fuelsTMutable = new ArrayList<>(); List<ItemStack> fuelsCMutable = new ArrayList<>(); for (ItemStack stack : registry.getItemList()) { addItemStack(stack, FuelType.TRANSMUTATOR, fuelsTMutable); addItemStack(stack, FuelType.CRYSTALLIZER, fuelsCMutable); } transmutatorFuels = ImmutableList.copyOf(fuelsTMutable); crystallizerFuels = ImmutableList.copyOf(fuelsCMutable); }
public void testCopyOf_concurrentlyMutating() { List<String> sample = Lists.newArrayList("a", "b", "c"); for (int delta : new int[] {-1, 0, 1}) { for (int i = 0; i < sample.size(); i++) { Collection<String> misleading = Helpers.misleadingSizeCollection(delta); List<String> expected = sample.subList(0, i); misleading.addAll(expected); assertEquals(expected, ImmutableList.copyOf(misleading)); assertEquals(expected, ImmutableList.copyOf((Iterable<String>) misleading)); } } }
/** * Set type <code>e</code> as <code>type</code> * * @param e * @param type */ void setType(ECR e, ValueType type) { ECR root = findRoot(e); root.setType(type); Collection<Pair<Size, ECR>> ccjoins = ImmutableList.copyOf(root.getCCjoins()); root.clearCCjoins(ccjoins); for (Pair<Size, ECR> cjoinPair : ccjoins) ccjoin(cjoinPair.fst(), root, cjoinPair.snd()); Collection<ECR> cjoins = ImmutableList.copyOf(root.getCjoins()); root.clearCjoins(cjoins); for (ECR joinECR : cjoins) cjoin(root, joinECR); }
public void testConstrainedMultimapLegal() { Multimap<String, Integer> multimap = LinkedListMultimap.create(); Multimap<String, Integer> constrained = MapConstraints.constrainedMultimap(multimap, TEST_CONSTRAINT); multimap.put(TEST_KEY, TEST_VALUE); constrained.put("foo", 1); multimap.get("bar").add(2); constrained.get("baz").add(3); multimap.get("qux").addAll(Arrays.asList(4)); constrained.get("zig").addAll(Arrays.asList(5)); multimap.putAll("zag", Arrays.asList(6)); constrained.putAll("bee", Arrays.asList(7)); multimap.putAll(new ImmutableMultimap.Builder<String, Integer>().put("bim", 8).build()); constrained.putAll(new ImmutableMultimap.Builder<String, Integer>().put("bop", 9).build()); multimap.putAll(new ImmutableMultimap.Builder<String, Integer>().put("dig", 10).build()); constrained.putAll(new ImmutableMultimap.Builder<String, Integer>().put("dag", 11).build()); assertTrue(multimap.equals(constrained)); assertTrue(constrained.equals(multimap)); ASSERT .that(ImmutableList.copyOf(multimap.entries())) .is(ImmutableList.copyOf(constrained.entries())); ASSERT.that(constrained.asMap().get("foo")).has().item(1); assertNull(constrained.asMap().get("missing")); assertEquals(multimap.asMap(), constrained.asMap()); assertEquals(multimap.values(), constrained.values()); assertEquals(multimap.keys(), constrained.keys()); assertEquals(multimap.keySet(), constrained.keySet()); assertEquals(multimap.toString(), constrained.toString()); assertEquals(multimap.hashCode(), constrained.hashCode()); ASSERT .that(multimap.entries()) .has() .allOf( Maps.immutableEntry(TEST_KEY, TEST_VALUE), Maps.immutableEntry("foo", 1), Maps.immutableEntry("bar", 2), Maps.immutableEntry("baz", 3), Maps.immutableEntry("qux", 4), Maps.immutableEntry("zig", 5), Maps.immutableEntry("zag", 6), Maps.immutableEntry("bee", 7), Maps.immutableEntry("bim", 8), Maps.immutableEntry("bop", 9), Maps.immutableEntry("dig", 10), Maps.immutableEntry("dag", 11)) .inOrder(); assertFalse(constrained.asMap().values() instanceof Serializable); Iterator<Collection<Integer>> iterator = constrained.asMap().values().iterator(); iterator.next(); iterator.next().add(12); assertTrue(multimap.containsEntry("foo", 12)); }