use of com.google.common.collect.ImmutableList in project presto by prestodb.
the class TestNodeScheduler method setUp.
@BeforeMethod
public void setUp() throws Exception {
finalizerService = new FinalizerService();
nodeTaskMap = new NodeTaskMap(finalizerService);
nodeManager = new InMemoryNodeManager();
ImmutableList.Builder<Node> nodeBuilder = ImmutableList.builder();
nodeBuilder.add(new PrestoNode("other1", URI.create("http://127.0.0.1:11"), NodeVersion.UNKNOWN, false));
nodeBuilder.add(new PrestoNode("other2", URI.create("http://127.0.0.1:12"), NodeVersion.UNKNOWN, false));
nodeBuilder.add(new PrestoNode("other3", URI.create("http://127.0.0.1:13"), NodeVersion.UNKNOWN, false));
ImmutableList<Node> nodes = nodeBuilder.build();
nodeManager.addNode(CONNECTOR_ID, nodes);
NodeSchedulerConfig nodeSchedulerConfig = new NodeSchedulerConfig().setMaxSplitsPerNode(20).setIncludeCoordinator(false).setMaxPendingSplitsPerTask(10);
NodeScheduler nodeScheduler = new NodeScheduler(new LegacyNetworkTopology(), nodeManager, nodeSchedulerConfig, nodeTaskMap);
// contents of taskMap indicate the node-task map for the current stage
taskMap = new HashMap<>();
nodeSelector = nodeScheduler.createNodeSelector(CONNECTOR_ID);
remoteTaskExecutor = Executors.newCachedThreadPool(daemonThreadsNamed("remoteTaskExecutor-%s"));
finalizerService.start();
}
use of com.google.common.collect.ImmutableList in project guava by hceylan.
the class TypeToken method getGenericInterfaces.
/**
* Returns the generic interfaces that this type directly {@code implements}. This method is
* similar but different from {@link Class#getGenericInterfaces()}. For example, {@code
* new TypeToken<List<String>>() {}.getGenericInterfaces()} will return a list that contains
* {@code new TypeToken<Iterable<String>>() {}}; while {@code List.class.getGenericInterfaces()}
* will return an array that contains {@code Iterable<T>}, where the {@code T} is the type
* variable declared by interface {@code Iterable}.
*
* <p>If this type is a type variable or wildcard, its upper bounds are examined and those that
* are either an interface or upper-bounded only by interfaces are returned. This means that the
* returned types could include type variables too.
*/
final ImmutableList<TypeToken<? super T>> getGenericInterfaces() {
if (runtimeType instanceof TypeVariable) {
return boundsAsInterfaces(((TypeVariable<?>) runtimeType).getBounds());
}
if (runtimeType instanceof WildcardType) {
return boundsAsInterfaces(((WildcardType) runtimeType).getUpperBounds());
}
ImmutableList.Builder<TypeToken<? super T>> builder = ImmutableList.builder();
for (Type interfaceType : getRawType().getGenericInterfaces()) {
// interface of T
@SuppressWarnings("unchecked") TypeToken<? super T> resolvedInterface = (TypeToken<? super T>) resolveSupertype(interfaceType);
builder.add(resolvedInterface);
}
return builder.build();
}
use of com.google.common.collect.ImmutableList in project guava by google.
the class QuantilesTest method generatePseudorandomDataset.
private static ImmutableList<Double> generatePseudorandomDataset() {
Random random = new Random(2211275185798966364L);
ImmutableList.Builder<Double> largeDatasetBuilder = ImmutableList.builder();
for (int i = 0; i < PSEUDORANDOM_DATASET_SIZE; i++) {
largeDatasetBuilder.add(random.nextGaussian());
}
return largeDatasetBuilder.build();
}
use of com.google.common.collect.ImmutableList in project guice by google.
the class ProviderMethodsTest method testWildcardProviderMethods.
public void testWildcardProviderMethods() {
final List<String> strings = ImmutableList.of("A", "B", "C");
final List<Number> numbers = ImmutableList.<Number>of(1, 2, 3);
Injector injector = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
@SuppressWarnings("unchecked") Key<List<? super Integer>> listOfSupertypesOfInteger = (Key<List<? super Integer>>) Key.get(Types.listOf(Types.supertypeOf(Integer.class)));
bind(listOfSupertypesOfInteger).toInstance(numbers);
}
@Provides
public List<? extends CharSequence> provideCharSequences() {
return strings;
}
@Provides
public Class<?> provideType() {
return Float.class;
}
});
assertSame(strings, injector.getInstance(HasWildcardInjection.class).charSequences);
assertSame(numbers, injector.getInstance(HasWildcardInjection.class).numbers);
assertSame(Float.class, injector.getInstance(HasWildcardInjection.class).type);
}
use of com.google.common.collect.ImmutableList in project error-prone by google.
the class StrictFormatStringValidation method validateFormatStringParamter.
/** Helps {@code validate()} validate a format string that is declared as a method parameter. */
private static ValidationResult validateFormatStringParamter(ExpressionTree formatStringTree, Symbol formatStringSymbol, List<? extends ExpressionTree> args, VisitorState state) {
if (!isFormatStringParameter(formatStringSymbol, state)) {
return ValidationResult.create(null, String.format("Format strings must be compile time constant or parameters annotated " + "@FormatString: %s", formatStringTree));
}
List<VarSymbol> ownerParams = ((MethodSymbol) formatStringSymbol.owner).getParameters();
int ownerFormatStringIndex = ownerParams.indexOf(formatStringSymbol);
ImmutableList.Builder<Type> ownerFormatArgTypesBuilder = ImmutableList.builder();
for (VarSymbol paramSymbol : ownerParams.subList(ownerFormatStringIndex + 1, ownerParams.size())) {
ownerFormatArgTypesBuilder.add(paramSymbol.type);
}
ImmutableList<Type> ownerFormatArgTypes = ownerFormatArgTypesBuilder.build();
Types types = state.getTypes();
ImmutableList.Builder<Type> calleeFormatArgTypesBuilder = ImmutableList.builder();
for (ExpressionTree formatArgExpression : args) {
calleeFormatArgTypesBuilder.add(types.erasure(((JCExpression) formatArgExpression).type));
}
ImmutableList<Type> calleeFormatArgTypes = calleeFormatArgTypesBuilder.build();
if (ownerFormatArgTypes.size() != calleeFormatArgTypes.size()) {
return ValidationResult.create(null, String.format("The number of format arguments passed " + "with an @FormatString must match the number of format arguments in the " + "@FormatMethod header where the format string was declared.\n\t" + "Format args passed: %d\n\tFormat args expected: %d", calleeFormatArgTypes.size(), ownerFormatArgTypes.size()));
} else {
for (int i = 0; i < calleeFormatArgTypes.size(); i++) {
if (!ASTHelpers.isSameType(ownerFormatArgTypes.get(i), calleeFormatArgTypes.get(i), state)) {
return ValidationResult.create(null, String.format("The format argument types passed " + "with an @FormatString must match the types of the format arguments in " + "the @FormatMethod header where the format string was declared.\n\t" + "Format arg types passed: %s\n\tFormat arg types expected: %s", calleeFormatArgTypes.toArray(), ownerFormatArgTypes.toArray()));
}
}
}
// Format string usage was valid.
return null;
}
Aggregations