Example usage for com.google.common.collect ImmutableBiMap keySet

List of usage examples for com.google.common.collect ImmutableBiMap keySet

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableBiMap keySet.

Prototype

Set<K> keySet();

Source Link

Document

Returns a Set view of the keys contained in this map.

Usage

From source file:com.facebook.tsdb.tsdash.server.data.hbase.IDMap.java

public String[] getTags() throws IOException {
    ImmutableBiMap<String, ID> tagsMap = syncTagsLoader.get();
    return tagsMap.keySet().toArray(new String[0]);
}

From source file:com.facebook.tsdb.tsdash.server.data.hbase.IDMap.java

public String[] getMetrics() throws IOException {
    ImmutableBiMap<String, ID> metricsMap = syncMetricsLoader.get();
    return metricsMap.keySet().toArray(new String[0]);
}

From source file:com.facebook.tsdb.tsdash.server.data.hbase.IDMap.java

public String[] getTagValues() throws IOException {
    ImmutableBiMap<String, ID> tagValuesMap = syncTagValuesLoader.get();
    return tagValuesMap.keySet().toArray(new String[0]);
}

From source file:net.tsquery.data.hbase.IDMap.java

public String[] getMetrics() throws IOException {
    ImmutableBiMap<String, ID> metricsMap = syncMetricsLoader.get();
    ImmutableSet<String> strings = metricsMap.keySet();
    return strings.toArray(new String[strings.size()]);
}

From source file:com.github.rinde.rinsim.central.arrays.ArraysSolverValidator.java

/**
 * Validates the inputs for the {@link MultiVehicleArraysSolver}. This method
 * checks all properties as defined in//w  w  w.  j a v a  2 s.com
 * {@link MultiVehicleArraysSolver#solve(int[][], int[], int[], int[][], int[], int[][], int[][], int[], int[], SolutionObject[])}
 * . If the inputs are not correct an {@link IllegalArgumentException} is
 * thrown.
 * @param travelTime Parameter as specified by
 *          {@link MultiVehicleArraysSolver#solve(int[][], int[], int[], int[][], int[], int[][], int[][], int[], int[], SolutionObject[])}
 *          .
 * @param releaseDates Parameter as specified by
 *          {@link MultiVehicleArraysSolver#solve(int[][], int[], int[], int[][], int[], int[][], int[][], int[], int[], SolutionObject[])}
 *          .
 * @param dueDates Parameter as specified by
 *          {@link MultiVehicleArraysSolver#solve(int[][], int[], int[], int[][], int[], int[][], int[][], int[], int[], SolutionObject[])}
 *          .
 * @param servicePairs Parameter as specified by
 *          {@link MultiVehicleArraysSolver#solve(int[][], int[], int[], int[][], int[], int[][], int[][], int[], int[], SolutionObject[])}
 *          .
 * @param serviceTimes Parameter as specified by
 *          {@link MultiVehicleArraysSolver#solve(int[][], int[], int[], int[][], int[], int[][], int[][], int[], int[], SolutionObject[])}
 *          .
 * @param vehicleTravelTimes Parameter as specified by
 *          {@link MultiVehicleArraysSolver#solve(int[][], int[], int[], int[][], int[], int[][], int[][], int[], int[], SolutionObject[])}
 *          .
 * @param inventories Parameter as specified by
 *          {@link MultiVehicleArraysSolver#solve(int[][], int[], int[], int[][], int[], int[][], int[][], int[], int[], SolutionObject[])}
 *          .
 * @param remainingServiceTimes Parameter as specified by
 *          {@link MultiVehicleArraysSolver#solve(int[][], int[], int[], int[][], int[], int[][], int[][], int[], int[], SolutionObject[])}
 *          .
 * @param currentDestinations Parameter as specified by
 *          {@link MultiVehicleArraysSolver#solve(int[][], int[], int[], int[][], int[], int[][], int[][], int[], int[], SolutionObject[])}
 *          .
 * @param currentSolutions Parameter as specified by
 *          {@link MultiVehicleArraysSolver#solve(int[][], int[], int[], int[][], int[], int[][], int[][], int[], int[], SolutionObject[])}
 *          .
 */
public static void validateInputs(int[][] travelTime, int[] releaseDates, int[] dueDates, int[][] servicePairs,
        int[] serviceTimes, int[][] vehicleTravelTimes, int[][] inventories, int[] remainingServiceTimes,
        int[] currentDestinations, @Nullable SolutionObject[] currentSolutions) {

    validateInputs(travelTime, releaseDates, dueDates, servicePairs, serviceTimes);

    // number of vehicles v
    final int v = vehicleTravelTimes.length;
    final int n = travelTime.length;
    checkArgument(v > 0, "At least one vehicle is required.");

    checkArgument(v == remainingServiceTimes.length,
            "Expected a remainingServiceTimes array of size %s, but found one with " + "size %s.", v,
            remainingServiceTimes.length);
    checkArgument(currentDestinations.length == v,
            "The currentDestinations array should be of length v=%s, it is %s.", v, currentDestinations.length);

    validateVehicleTravelTimes(v, n, vehicleTravelTimes, currentDestinations);

    final ImmutableSet.Builder<Integer> b = ImmutableSet.builder();
    for (int i = 0; i < servicePairs.length; i++) {
        b.add(servicePairs[i][0]);
        b.add(servicePairs[i][1]);
    }
    final Set<Integer> availLocs = b.build();

    final int m = n - 2 - servicePairs.length * 2;
    checkArgument(inventories.length == m, "Invalid number of inventory entries, must be equal to number of "
            + "delivery locations: %s, found: %s.", m, servicePairs.length);

    final Multimap<Integer, Integer> inventoriesMap = HashMultimap.create();
    final Set<Integer> parcelsInInventory = newHashSet();
    for (int i = 0; i < m; i++) {
        checkArgument(2 == inventories[i].length,
                "We expected inventories matrix of size m x 2, but we found m x %s " + "at index %s.",
                inventories[i].length, i);
        checkArgument(inventories[i][0] >= 0 && inventories[i][0] < v,
                "Found a reference to a non-existing vehicle (%s) in inventories at " + "row %s.",
                inventories[i][0], i);
        checkArgument(inventories[i][1] >= 1 && inventories[i][1] < n - 1,
                "Found a reference to a non-existing location (%s) in inventories at" + " row %s.",
                inventories[i][1], i);
        checkArgument(!availLocs.contains(inventories[i][1]),
                "Found a reference to a location (%s) in inventories at row %s which "
                        + "is available, as such, it can not be in the inventory.",
                inventories[i][1], i);
        checkArgument(!parcelsInInventory.contains(inventories[i][1]),
                "Found a duplicate inventory entry, first duplicate at row %s.", i);
        parcelsInInventory.add(inventories[i][1]);
        inventoriesMap.put(inventories[i][0], inventories[i][1]);
    }

    for (int i = 0; i < v; i++) {
        checkArgument(remainingServiceTimes[i] >= 0, "Remaining service time must be >= 0, found %s.",
                remainingServiceTimes[i]);
    }

    final ImmutableBiMap.Builder<Integer, Integer> servicePairsBuilder = ImmutableBiMap.builder();
    for (int i = 0; i < servicePairs.length; i++) {
        servicePairsBuilder.put(servicePairs[i][0], servicePairs[i][1]);
    }
    final ImmutableBiMap<Integer, Integer> servicePairsMap = servicePairsBuilder.build();

    for (int i = 0; i < v; i++) {
        if (remainingServiceTimes[i] != 0) {
            checkArgument(currentDestinations[i] != 0);
        }

        if (currentDestinations[i] != 0) {
            final int dest = currentDestinations[i];
            checkArgument(dest >= 1 && dest < n - 1,
                    "The destination must be a valid location, it can not be the " + "depot. It is %s.", dest);

            final boolean isAvailablePickupLoc = servicePairsMap.keySet().contains(dest);
            final boolean isInInventory = inventoriesMap.containsValue(dest);
            checkArgument(isAvailablePickupLoc != isInInventory,
                    "The destination location %s must be an available pickup location "
                            + "OR a delivery location which is in the inventory, available "
                            + "pickup loc: %s, in inventory: %s.",
                    dest, isAvailablePickupLoc, isInInventory);

            if (parcelsInInventory.contains(dest)) {
                checkArgument(inventoriesMap.get(i).contains(dest),
                        "When a vehicle is moving towards a destination which is a "
                                + "delivery location, it must contain this parcel in its "
                                + "cargo. Vehicle %s, destination %s.",
                        i, dest);
            }
        }
    }

    if (currentSolutions != null) {
        validateCurrentSolutions(v, n, currentSolutions, currentDestinations, inventoriesMap, servicePairsMap);
    }
}

From source file:com.google.errorprone.scanner.ScannerSupplierImpl.java

ScannerSupplierImpl(ImmutableBiMap<String, BugCheckerInfo> checks,
        ImmutableMap<String, BugPattern.SeverityLevel> severities, ImmutableSet<String> disabled) {
    checkArgument(Sets.difference(severities.keySet(), checks.keySet()).isEmpty(),
            "enabledChecks must be a subset of allChecks");
    checkArgument(Sets.difference(disabled, checks.keySet()).isEmpty(),
            "disabled must be a subset of allChecks");
    this.checks = checks;
    this.severities = severities;
    this.disabled = disabled;
}

From source file:com.qubole.quark.planner.QuarkCube.java

private void validateCubeLatticeFilter(Lattice.Builder latticeBuilder,
        ImmutableBiMap<Integer, Integer> dimensionToCubeColumn) {
    if (latticeBuilder.filter != null) {
        ImmutableBitSet rCols = RelOptUtil.InputFinder.bits(latticeBuilder.filter);
        ImmutableBitSet dims = ImmutableBitSet.of(dimensionToCubeColumn.keySet());
        if (!dims.contains(rCols)) {
            throw new RuntimeException("Cube filter is only allowed on dimensions");
        }//from   ww  w.j  a va 2 s.  c o m
    }
}

From source file:cz.cuni.mff.ms.brodecva.botnicek.ide.design.system.model.NormalizedNamingAuthority.java

@Override
public void tryReplace(final Map<? extends String, ? extends String> oldToNew) {
    Preconditions.checkNotNull(oldToNew);

    final ImmutableBiMap<String, String> copy = ImmutableBiMap.copyOf(oldToNew);

    for (final Map.Entry<String, String> replacementPair : copy.entrySet()) {
        final String oldName = replacementPair.getKey();
        final String newName = replacementPair.getValue();

        Preconditions.checkArgument(isUsed(oldName), ExceptionLocalizer.print("NameNotUsed", oldName));
        Preconditions.checkArgument(oldName.equals(newName) || isUsable(newName),
                ExceptionLocalizer.print("NameNotUsable", newName));
    }/*ww w .j ava 2 s  .  com*/

    final Set<String> oldNames = copy.keySet();
    final Set<String> newNames = copy.values();
    for (final String oldName : oldNames) {
        this.used.remove(oldName);
    }

    for (final String newName : newNames) {
        this.used.add(newName);
    }
}

From source file:com.google.auto.value.processor.BuilderMethodClassifier.java

private BuilderMethodClassifier(ErrorReporter errorReporter, ProcessingEnvironment processingEnv,
        TypeElement autoValueClass, TypeElement builderType,
        ImmutableBiMap<ExecutableElement, String> getterToPropertyName, TypeSimplifier typeSimplifier) {
    this.errorReporter = errorReporter;
    this.typeUtils = processingEnv.getTypeUtils();
    this.elementUtils = processingEnv.getElementUtils();
    this.autoValueClass = autoValueClass;
    this.builderType = builderType;
    this.getterToPropertyName = getterToPropertyName;
    ImmutableMap.Builder<String, ExecutableElement> getterToPropertyNameBuilder = ImmutableMap.builder();
    for (ExecutableElement getter : getterToPropertyName.keySet()) {
        getterToPropertyNameBuilder.put(getter.getSimpleName().toString(), getter);
    }//from w ww  . j  a  v a2s  .  c  o  m
    this.getterNameToGetter = getterToPropertyNameBuilder.build();
    this.typeSimplifier = typeSimplifier;
    this.eclipseHack = new EclipseHack(processingEnv);
}

From source file:com.facebook.buck.cxx.PrefixMapDebugPathSanitizer.java

public PrefixMapDebugPathSanitizer(int pathSize, char separator, Path fakeCompilationDirectory,
        ImmutableBiMap<Path, Path> other, Path realCompilationDirectory, CxxToolProvider.Type cxxType) {
    super(separator, pathSize, fakeCompilationDirectory);
    this.isGcc = cxxType == CxxToolProvider.Type.GCC;
    this.compilationDir = realCompilationDirectory;
    ImmutableBiMap.Builder<Path, Path> pathsBuilder = ImmutableBiMap.builder();
    // As these replacements are processed one at a time, if one is a prefix (or actually is just
    // contained in) another, it must be processed after that other one. To ensure that we can
    // process them in the correct order, they are inserted into allPaths in order of length
    // (longest first). Then, if they are processed in the order in allPaths, prefixes will be
    // handled correctly.
    pathsBuilder.putAll(FluentIterable.from(other.entrySet()).toSortedList(
            (left, right) -> right.getKey().toString().length() - left.getKey().toString().length()));
    // We assume that nothing in other is a prefix of realCompilationDirectory (though the reverse
    // is fine).//from w ww.j av a 2  s  .c o  m
    pathsBuilder.put(realCompilationDirectory, fakeCompilationDirectory);
    for (Path p : other.keySet()) {
        Assertions.assertCondition(!realCompilationDirectory.toString().contains(p.toString()));
    }

    this.allPaths = pathsBuilder.build();
}