JoinUsingAnalysis(List<Integer> leftJoinFields, List<Integer> rightJoinFields, List<Integer> otherLeftFields, List<Integer> otherRightFields) { this.leftJoinFields = ImmutableList.copyOf(leftJoinFields); this.rightJoinFields = ImmutableList.copyOf(rightJoinFields); this.otherLeftFields = ImmutableList.copyOf(otherLeftFields); this.otherRightFields = ImmutableList.copyOf(otherRightFields); checkArgument(leftJoinFields.size() == rightJoinFields.size(), "Expected join fields for left and right to have the same size"); }
public UnnestOperatorFactory(int operatorId, PlanNodeId planNodeId, List<Integer> replicateChannels, List<Type> replicateTypes, List<Integer> unnestChannels, List<Type> unnestTypes, boolean withOrdinality) { this.operatorId = operatorId; this.planNodeId = requireNonNull(planNodeId, "planNodeId is null"); this.replicateChannels = ImmutableList.copyOf(requireNonNull(replicateChannels, "replicateChannels is null")); this.replicateTypes = ImmutableList.copyOf(requireNonNull(replicateTypes, "replicateTypes is null")); checkArgument(replicateChannels.size() == replicateTypes.size(), "replicateChannels and replicateTypes do not match"); this.unnestChannels = ImmutableList.copyOf(requireNonNull(unnestChannels, "unnestChannels is null")); this.unnestTypes = ImmutableList.copyOf(requireNonNull(unnestTypes, "unnestTypes is null")); checkArgument(unnestChannels.size() == unnestTypes.size(), "unnestChannels and unnestTypes do not match"); this.withOrdinality = withOrdinality; }
@JsonCreator public HiveBucketProperty( @JsonProperty("bucketedBy") List<String> bucketedBy, @JsonProperty("bucketCount") int bucketCount, @JsonProperty("sortedBy") List<SortingColumn> sortedBy) { this.bucketedBy = ImmutableList.copyOf(requireNonNull(bucketedBy, "bucketedBy is null")); this.bucketCount = bucketCount; this.sortedBy = ImmutableList.copyOf(requireNonNull(sortedBy, "sortedBy is null")); }
@Test public void testProjectNoColumns() { PageProcessor pageProcessor = new PageProcessor(Optional.empty(), ImmutableList.of(), OptionalInt.of(MAX_BATCH_SIZE)); Page inputPage = new Page(createLongSequenceBlock(0, 100)); Iterator<Optional<Page>> output = processAndAssertRetainedPageSize(pageProcessor, inputPage); List<Optional<Page>> outputPages = ImmutableList.copyOf(output); assertEquals(outputPages.size(), 1); Page outputPage = outputPages.get(0).orElse(null); assertEquals(outputPage.getChannelCount(), 0); assertEquals(outputPage.getPositionCount(), inputPage.getPositionCount()); }
public void delete(@NotNull List<KeyStroke> keys) { myKeys.remove(ImmutableList.copyOf(keys)); List<KeyStroke> prefix = new ArrayList<KeyStroke>(); final int prefixLength = keys.size() - 1; for (int i = 0; i < prefixLength; i++) { prefix.add(keys.get(i)); decrement(ImmutableList.copyOf(prefix)); } }
private List<DruidCoordinatorHelper> makeIndexingServiceHelpers() { List<DruidCoordinatorHelper> helpers = new ArrayList<>(); helpers.add(new DruidCoordinatorSegmentInfoLoader(DruidCoordinator.this)); helpers.add(segmentCompactor); helpers.addAll(indexingServiceHelpers); log.info( "Done making indexing service helpers [%s]", helpers.stream().map(helper -> helper.getClass().getCanonicalName()).collect(Collectors.toList()) ); return ImmutableList.copyOf(helpers); }
@Override public Collection<String> create(String[] elements) { List<String> unfiltered = newArrayList(); unfiltered.add("yyy"); unfiltered.addAll(ImmutableList.copyOf(elements)); unfiltered.add("zzz"); return Collections2.filter(unfiltered, LENGTH_1); } })
/** * Reads all the lines of this source as a list of strings. The returned list will be empty if * this source is empty. * * <p>Like {@link BufferedReader#readLine()}, this method considers a line to be a sequence of * text that is terminated by (but does not include) one of {@code \r\n}, {@code \r} or {@code * \n}. If the source's content does not end in a line termination sequence, it is treated as if * it does. * * @throws IOException if an I/O error occurs while reading from this source */ public ImmutableList<String> readLines() throws IOException { Closer closer = Closer.create(); try { BufferedReader reader = closer.register(openBufferedStream()); List<String> result = Lists.newArrayList(); String line; while ((line = reader.readLine()) != null) { result.add(line); } return ImmutableList.copyOf(result); } catch (Throwable e) { throw closer.rethrow(e); } finally { closer.close(); } }
private PluginClassLoader( List<URL> urls, ClassLoader spiClassLoader, Iterable<String> spiPackages, Iterable<String> spiResources) { // plugins should not have access to the system (application) class loader super(urls.toArray(new URL[urls.size()]), PLATFORM_CLASS_LOADER); this.spiClassLoader = requireNonNull(spiClassLoader, "spiClassLoader is null"); this.spiPackages = ImmutableList.copyOf(spiPackages); this.spiResources = ImmutableList.copyOf(spiResources); }
static <E> List<List<E>> create(List<? extends List<? extends E>> lists) { ImmutableList.Builder<List<E>> axesBuilder = new ImmutableList.Builder<>(lists.size()); for (List<? extends E> list : lists) { List<E> copy = ImmutableList.copyOf(list); if (copy.isEmpty()) { return ImmutableList.of(); } axesBuilder.add(copy); } return new CartesianList<E>(axesBuilder.build()); }
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)); } } }
private static ImmutableList<URL> getClassLoaderUrls(ClassLoader classloader) { if (classloader instanceof URLClassLoader) { return ImmutableList.copyOf(((URLClassLoader) classloader).getURLs()); } if (classloader.equals(ClassLoader.getSystemClassLoader())) { return parseJavaClassPath(); } return ImmutableList.of(); }
public MergingPageOutput(Iterable<? extends Type> types, long minPageSizeInBytes, int minRowCount, int maxPageSizeInBytes) { this.types = ImmutableList.copyOf(requireNonNull(types, "types is null")); checkArgument(minPageSizeInBytes >= 0, "minPageSizeInBytes must be greater or equal than zero"); checkArgument(minRowCount >= 0, "minRowCount must be greater or equal than zero"); checkArgument(maxPageSizeInBytes > 0, "maxPageSizeInBytes must be greater than zero"); checkArgument(maxPageSizeInBytes >= minPageSizeInBytes, "maxPageSizeInBytes must be greater or equal than minPageSizeInBytes"); checkArgument(minPageSizeInBytes <= MAX_MIN_PAGE_SIZE, "minPageSizeInBytes must be less or equal than %d", MAX_MIN_PAGE_SIZE); this.minPageSizeInBytes = minPageSizeInBytes; this.minRowCount = minRowCount; pageBuilder = PageBuilder.withMaxPageSize(maxPageSizeInBytes, this.types); }
public void testConvertAllIsView() { List<String> mutableList = Lists.newArrayList("789", "123"); Iterable<Long> convertedValues = STR_TO_LONG.convertAll(mutableList); assertEquals(ImmutableList.of(789L, 123L), ImmutableList.copyOf(convertedValues)); Iterator<Long> iterator = convertedValues.iterator(); iterator.next(); iterator.remove(); assertEquals(ImmutableList.of("123"), mutableList); }
private ArrayTable(Iterable<? extends R> rowKeys, Iterable<? extends C> columnKeys) { this.rowList = ImmutableList.copyOf(rowKeys); this.columnList = ImmutableList.copyOf(columnKeys); checkArgument(rowList.isEmpty() == columnList.isEmpty()); /* * TODO(jlevy): Support only one of rowKey / columnKey being empty? If we * do, when columnKeys is empty but rowKeys isn't, rowKeyList() can contain * elements but rowKeySet() will be empty and containsRow() won't * acknolwedge them. */ rowKeyToIndex = Maps.indexMap(rowList); columnKeyToIndex = Maps.indexMap(columnList); @SuppressWarnings("unchecked") V[][] tmpArray = (V[][]) new Object[rowList.size()][columnList.size()]; array = tmpArray; // Necessary because in GWT the arrays are initialized with "undefined" instead of null. eraseAll(); }
public DelegatingSystemTablesProvider(List<SystemTablesProvider> delegates) { requireNonNull(delegates, "delegates is null"); checkArgument(delegates.size() >= 1, "empty delegates"); this.delegates = ImmutableList.copyOf(delegates); }
@JsonCreator public HiveWrittenPartitions(@JsonProperty("partitionNames") List<String> partitionNames) { this.partitionNames = ImmutableList.copyOf(requireNonNull(partitionNames, "partitionNames is null")); }
@Test public void testBatchedOutput() { PageProcessor pageProcessor = new PageProcessor(Optional.empty(), ImmutableList.of(new InputPageProjection(0, BIGINT)), OptionalInt.of(MAX_BATCH_SIZE)); Page inputPage = new Page(createLongSequenceBlock(0, (int) (MAX_BATCH_SIZE * 2.5))); Iterator<Optional<Page>> output = processAndAssertRetainedPageSize(pageProcessor, inputPage); List<Optional<Page>> outputPages = ImmutableList.copyOf(output); assertEquals(outputPages.size(), 3); for (int i = 0; i < outputPages.size(); i++) { Page actualPage = outputPages.get(i).orElse(null); int offset = i * MAX_BATCH_SIZE; Page expectedPage = new Page(createLongSequenceBlock(offset, offset + Math.min(inputPage.getPositionCount() - offset, MAX_BATCH_SIZE))); assertPageEquals(ImmutableList.of(BIGINT), actualPage, expectedPage); } }