Example usage for com.google.common.collect Range closedOpen

List of usage examples for com.google.common.collect Range closedOpen

Introduction

In this page you can find the example usage for com.google.common.collect Range closedOpen.

Prototype

public static <C extends Comparable<?>> Range<C> closedOpen(C lower, C upper) 

Source Link

Document

Returns a range that contains all values greater than or equal to lower and strictly less than upper .

Usage

From source file:edu.mit.streamjit.impl.compiler2.Compiler2.java

private void createSteadyStateCode() {
    for (Actor a : actors) {
        for (int i = 0; i < a.outputs().size(); ++i) {
            Storage s = a.outputs().get(i);

            if (s.isInternal())
                continue;
            int itemsWritten = a.push(i).max() * initSchedule.get(a.group()) * a.group().schedule().get(a);
            a.outputIndexFunctions().set(i,
                    a.outputIndexFunctions().get(i).compose(new AdditionIndexFunction(itemsWritten)));
        }//from w ww .  j  a  v a 2  s. co m
        for (int i = 0; i < a.inputs().size(); ++i) {

            Storage s = a.inputs().get(i);
            if (s.isInternal())
                continue;

            int itemsRead = a.pop(i).max() * initSchedule.get(a.group()) * a.group().schedule().get(a);
            a.inputIndexFunctions().set(i,
                    a.inputIndexFunctions().get(i).compose(new AdditionIndexFunction(itemsRead)));
        }
    }

    for (Storage s : storage)
        s.computeSteadyStateRequirements(externalSchedule);
    this.steadyStateStorage = createStorage(false,
            new PeekPokeStorageFactory(EXTERNAL_STORAGE_STRATEGY.asFactory(config)));

    ImmutableMap<Storage, ConcreteStorage> internalStorage = createStorage(true,
            INTERNAL_STORAGE_STRATEGY.asFactory(config));

    List<Core> ssCores = new ArrayList<>(maxNumCores);

    IndexFunctionTransformer ift = new IdentityIndexFunctionTransformer();
    for (int i = 0; i < maxNumCores; ++i) {

        ImmutableTable.Builder<Actor, Integer, IndexFunctionTransformer> inputTransformers = ImmutableTable
                .builder(), outputTransformers = ImmutableTable.builder();
        for (Actor a : Iterables.filter(actors, WorkerActor.class)) {
            for (int j = 0; j < a.inputs().size(); ++j) {
                inputTransformers.put(a, j, ift);
            }

            for (int j = 0; j < a.outputs().size(); ++j) {
                outputTransformers.put(a, j, ift);
            }
        }

        ImmutableMap.Builder<ActorGroup, Integer> unrollFactors = ImmutableMap.builder();
        for (ActorGroup g : groups) {
            if (g.isTokenGroup())
                continue;
            ////to be continued
            ////

        }

        ssCores.add(new Core(CollectionUtils.union(steadyStateStorage, internalStorage),
                (table, wa) -> SWITCHING_STRATEGY.createSwitch(table, wa, config), unrollFactors.build(),
                inputTransformers.build(), outputTransformers.build()));
    }

    int throughputPerSteadyState = 0;
    for (ActorGroup g : groups)
        if (!g.isTokenGroup())
            ALLOCATION_STRATEGY.allocateGroup(g, Range.closedOpen(0, externalSchedule.get(g)), ssCores, config);
        else {
            assert g.actors().size() == 1;
            TokenActor ta = (TokenActor) g.actors().iterator().next();
            assert g.schedule().get(ta) == 1;
            ConcreteStorage storage = steadyStateStorage
                    .get(Iterables.getOnlyElement(ta.isInput() ? g.outputs() : g.inputs()));
            int executions = externalSchedule.get(g);
            if (ta.isInput())
                readInstructions.add(makeReadInstruction(ta, storage, executions));
            else {
                writeInstructions.add(makeWriteInstruction(ta, storage, executions));
                throughputPerSteadyState += executions;
            }
        }
    ImmutableList.Builder<MethodHandle> steadyStateCodeBuilder = ImmutableList.builder();
    for (Core c : ssCores)
        if (!c.isEmpty())
            steadyStateCodeBuilder.add(c.code());
    //Provide at least one core of code, even if it doesn't do anything; the
    //blob host will still copy inputs to outputs.
    this.steadyStateCode = steadyStateCodeBuilder.build();
    if (steadyStateCode.isEmpty())
        this.steadyStateCode = ImmutableList.of(Combinators.nop());

    createMigrationInstructions();
    createDrainInstructions();

    Boolean reportThroughput = (Boolean) config.getExtraData("reportThroughput");
    if (reportThroughput != null && reportThroughput) {
        ReportThroughputInstruction rti = new ReportThroughputInstruction(throughputPerSteadyState);
        readInstructions.add(rti);
        writeInstructions.add(rti);
    }
}

From source file:diskCacheV111.srm.dcache.Storage.java

@Override
public List<FileMetaData> listDirectory(SRMUser user, URI surl, final boolean verbose, int offset, int count)
        throws SRMException {
    try {/*from ww w . j  a v  a2  s .c  o m*/
        FsPath path = config.getPath(surl);
        Subject subject = asDcacheUser(user).getSubject();
        Restriction restriction = asDcacheUser(user).getRestriction();
        FmdListPrinter printer = verbose ? new VerboseListPrinter() : new FmdListPrinter();
        Range<Integer> range = offset < Integer.MAX_VALUE - count ? Range.closedOpen(offset, offset + count)
                : Range.atLeast(offset);
        _listSource.printDirectory(subject, restriction, printer, path, null, range);
        return printer.getResult();
    } catch (TimeoutCacheException e) {
        throw new SRMInternalErrorException("Internal name space timeout", e);
    } catch (InterruptedException e) {
        throw new SRMInternalErrorException("List aborted by administrator", e);
    } catch (NotDirCacheException e) {
        throw new SRMInvalidPathException("Not a directory", e);
    } catch (FileNotFoundCacheException | NotInTrashCacheException e) {
        throw new SRMInvalidPathException("No such file or directory", e);
    } catch (PermissionDeniedCacheException e) {
        throw new SRMAuthorizationException("Permission denied", e);
    } catch (CacheException e) {
        throw new SRMException(String.format("List failed [rc=%d,msg=%s]", e.getRc(), e.getMessage()));
    }
}

From source file:io.prestosql.plugin.hive.parquet.AbstractTestParquetReader.java

private static ContiguousSet<Integer> intsBetween(int lowerInclusive, int upperExclusive) {
    return ContiguousSet.create(Range.closedOpen(lowerInclusive, upperExclusive), DiscreteDomain.integers());
}

From source file:io.prestosql.plugin.hive.parquet.AbstractTestParquetReader.java

private static ContiguousSet<Long> longsBetween(long lowerInclusive, long upperExclusive) {
    return ContiguousSet.create(Range.closedOpen(lowerInclusive, upperExclusive), DiscreteDomain.longs());
}

From source file:io.prestosql.plugin.hive.parquet.AbstractTestParquetReader.java

private static ContiguousSet<BigInteger> bigIntegersBetween(BigInteger lowerInclusive,
        BigInteger upperExclusive) {
    return ContiguousSet.create(Range.closedOpen(lowerInclusive, upperExclusive), DiscreteDomain.bigIntegers());
}