Example usage for com.google.common.collect Iterables unmodifiableIterable

List of usage examples for com.google.common.collect Iterables unmodifiableIterable

Introduction

In this page you can find the example usage for com.google.common.collect Iterables unmodifiableIterable.

Prototype

@Deprecated
public static <E> Iterable<E> unmodifiableIterable(ImmutableCollection<E> iterable) 

Source Link

Document

Simply returns its argument.

Usage

From source file:com.b2international.snowowl.datastore.version.VersioningManagerBroker.java

/**Returns with all registered component versioning manager interface-class mappings.*/
public Iterable<Pair<Class<IVersioningManager>, Class<IVersioningManager>>> getVersioningManagerClasses() {
    final Collection<Pair<Class<IVersioningManager>, Class<IVersioningManager>>> $ = Sets.newHashSet();
    for (final Pair<Class<IVersioningManager>, Class<IVersioningManager>> pair : cache.get().values()) {
        $.add(pair);//from   w  ww .  ja va2 s.  c  o m
    }
    return Iterables.unmodifiableIterable($);
}

From source file:com.comphenix.protocol.concurrency.SortedCopyOnWriteArray.java

/**
 * Retrieves an iterator over the elements in the given list. 
 * Warning: No not attempt to remove elements using the iterator.
 *//*  w ww . j ava  2s .  c  o m*/
public Iterator<T> iterator() {
    return Iterables.unmodifiableIterable(list).iterator();
}

From source file:org.apache.tez.runtime.common.resources.MemoryDistributor.java

/**
 * Used by the Tez framework to distribute initial memory after components
 * have made their initial requests.//from   ww  w .  j  av  a  2s . com
 * @throws TezException
 */
public void makeInitialAllocations() throws TezException {
    Preconditions.checkState(numInputsSeen.get() == numTotalInputs,
            "All inputs are expected to ask for memory");
    Preconditions.checkState(numOutputsSeen.get() == numTotalOutputs,
            "All outputs are expected to ask for memory");

    logInitialRequests(requestList);

    Iterable<InitialMemoryRequestContext> requestContexts = Iterables.transform(requestList,
            new Function<RequestorInfo, InitialMemoryRequestContext>() {
                public InitialMemoryRequestContext apply(RequestorInfo requestInfo) {
                    return requestInfo.getRequestContext();
                }
            });

    Iterable<Long> allocations = null;
    if (!isEnabled) {
        allocations = Iterables.transform(requestList, new Function<RequestorInfo, Long>() {
            public Long apply(RequestorInfo requestInfo) {
                return requestInfo.getRequestContext().getRequestedSize();
            }
        });
    } else {
        InitialMemoryAllocator allocator = ReflectionUtils.createClazzInstance(allocatorClassName);
        allocator.setConf(conf);
        allocations = allocator.assignMemory(totalJvmMemory, numTotalInputs, numTotalOutputs,
                Iterables.unmodifiableIterable(requestContexts));
        validateAllocations(allocations, requestList.size());
        logFinalAllocations(allocations, requestList);
    }

    // Making the callbacks directly for now, instead of spawning threads. The
    // callback implementors - all controlled by Tez at the moment are
    // lightweight.
    Iterator<Long> allocatedIter = allocations.iterator();
    for (RequestorInfo rInfo : requestList) {
        long allocated = allocatedIter.next();
        if (LOG.isDebugEnabled()) {
            LOG.info("Informing: " + rInfo.getRequestContext().getComponentType() + ", "
                    + rInfo.getRequestContext().getComponentVertexName() + ", "
                    + rInfo.getRequestContext().getComponentClassName() + ": requested="
                    + rInfo.getRequestContext().getRequestedSize() + ", allocated=" + allocated);
        }
        rInfo.getCallback().memoryAssigned(allocated);
    }
}

From source file:org.apache.giraph.graph.HashMapVertex.java

@Override
public Iterable<M> getMessages() {
    return Iterables.unmodifiableIterable(msgList);
}

From source file:org.apache.arrow.flight.ArrowMessage.java

public Iterable<ArrowBuf> getBufs() {
    return Iterables.unmodifiableIterable(bufs);
}

From source file:org.apache.aurora.common.stats.TimeSeriesRepositoryImpl.java

@Override
public synchronized Iterable<Number> getTimestamps() {
    return Iterables.unmodifiableIterable(timestamps);
}

From source file:org.apache.aurora.scheduler.offers.HostOffers.java

/**
 * Returns a weakly-consistent iterable giving the available offers to a given
 * {@code groupKey}. This iterable can handle concurrent operations on its underlying
 * collection, and may reflect changes that happen after the construction of the iterable.
 * This property is mainly used in {@code launchTask}.
 *
 * @param groupKey The task group to get offers for.
 * @return The offers a given task group can use.
 *//*from w w  w  .  j av  a2 s . c o m*/
synchronized Iterable<HostOffer> getAllMatching(TaskGroupKey groupKey, ResourceRequest resourceRequest) {

    return Iterables.unmodifiableIterable(FluentIterable.from(offers.getOrdered(groupKey, resourceRequest))
            .filter(o -> !isGloballyBanned(o)).filter(o -> !isStaticallyBanned(o, groupKey))
            .filter(HostOffer::hasCpuAndMem).filter(o -> !isVetoed(o, resourceRequest, Optional.of(groupKey))));
}

From source file:com.google.devtools.build.lib.rules.android.ResourceContainerConverter.java

/**
 * Convert ResourceDependencies to commandline args and artifacts, assuming the commandline
 * arguments should be split into direct deps and transitive deps.
 *//*from   w w w . j  a va  2  s .c o  m*/
static void convertDependencies(ResourceDependencies dependencies, CustomCommandLine.Builder cmdBuilder,
        NestedSetBuilder<Artifact> inputs, ToArg toArg, ToArtifacts toArtifacts) {

    if (dependencies != null) {
        // TODO(bazel-team): Find an appropriately lazy method to deduplicate the dependencies between
        // the direct and transitive data.
        // Add transitive data inside an unmodifiableIterable to ensure it won't be expanded until
        // iteration.
        if (!dependencies.getTransitiveResources().isEmpty()) {
            cmdBuilder.addJoinStrings("--data", toArg.listSeparator(), Iterables
                    .unmodifiableIterable(Iterables.transform(dependencies.getTransitiveResources(), toArg)));
        }
        // Add direct data inside an unmodifiableIterable to ensure it won't be expanded until
        // iteration.
        if (!dependencies.getDirectResources().isEmpty()) {
            cmdBuilder.addJoinStrings("--directData", toArg.listSeparator(), Iterables
                    .unmodifiableIterable(Iterables.transform(dependencies.getDirectResources(), toArg)));
        }
        // This flattens the nested set. Since each ResourceContainer needs to be transformed into
        // Artifacts, and the NestedSetBuilder.wrap doesn't support lazy Iterator evaluation
        // and SpawnActionBuilder.addInputs evaluates Iterables, it becomes necessary to make the
        // best effort and let it get flattened.
        inputs.addTransitive(NestedSetBuilder.wrap(Order.NAIVE_LINK_ORDER,
                FluentIterable.from(dependencies.getResources()).transformAndConcat(toArtifacts)));
    }
}

From source file:com.analog.lyric.dimple.model.transform.JunctionTreeTransformMap.java

public Iterable<AddedJointVariable<?>> addedJointVariables() {
    return Iterables.unmodifiableIterable(_addedDeterministicVariables.values());
}

From source file:com.bazaarvoice.snitch.variables.VariableRegistry.java

/** Return the set of known variables in the system. */
public Iterable<Variable> getVariables() {
    if (!_alreadyScanned) {
        scanClassPath();/*from   w  w w.  ja  v  a  2s  .c om*/
    }

    checkForRecentlyLoadedClasses();

    // We need to merge _staticVariables and _instanceVariables together here.  We know that they're both
    // implemented using thread-safe collections, so we can just concatenate them together and be confident that
    // any consumer will never experience any inconsistencies while iterating.
    return Iterables.unmodifiableIterable(Iterables.concat(_staticVariables, _instanceVariables.values()));
}