Java Code Examples for com.google.common.collect.ImmutableSet#iterator()
The following examples show how to use
com.google.common.collect.ImmutableSet#iterator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColumnarSplitDictReader.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
public void init(InputSplit split, TaskAttemptContext context) throws IOException, InterruptedException { FileSystem fs = FileSystem.get(context.getConfiguration()); FileSplit fSplit = (FileSplit) split; Path path = fSplit.getPath(); dictsReader = new DictsReader(path, fs); ImmutableMap<String, Dictionary> dimensionDictMap = dictsReader.readDicts(); ImmutableSet<Map.Entry<String, Dictionary>> set = dimensionDictMap.entrySet(); itr = set.iterator(); readCount = new AtomicInteger(0); logger.info("Reader for dictionary reader initialized. "); }
Example 2
Source File: TestTopicTreeImplEdgeCases.java From hivemq-community-edition with Apache License 2.0 | 5 votes |
@Test public void test_add_same_topic_twice_different_qos_more_than_32_subscribers() throws Exception { topicTree.addTopic("client1", new Topic("a/b", QoS.EXACTLY_ONCE), (byte) 0, null); for (int i = 0; i < 32; i++) { topicTree.addTopic("client" + (i + 2), new Topic("a/b", QoS.EXACTLY_ONCE), (byte) 0, null); } topicTree.addTopic("client1", new Topic("a/b", QoS.AT_LEAST_ONCE), (byte) 0, null); final ImmutableSet<SubscriberWithIdentifiers> subscribers = topicTree.getSubscribers("a/b"); assertEquals(33, subscribers.size()); assertEquals(33, topicTree.subscriptionCounter.getCount()); final UnmodifiableIterator<SubscriberWithIdentifiers> subscribersIterator = subscribers.iterator(); boolean found = false; while (subscribersIterator.hasNext()) { final SubscriberWithIdentifiers next = subscribersIterator.next(); if (next.getSubscriber().equals("client1")) { found = true; assertEquals(1, next.getQos()); } } assertTrue(found); }
Example 3
Source File: ClassPathResultTest.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Test public void testGetClassPathEntries() { ImmutableListMultimap<ClassPathEntry, DependencyPath> tree = ImmutableListMultimap.of( jarA, dependencyPath_A, jarB, dependencyPath_B, jarA, dependencyPath_A_B_A); ClassPathResult result = new ClassPathResult(tree, ImmutableSet.of()); ImmutableSet<ClassPathEntry> classPathEntries = result.getClassPathEntries("com.google:a:1"); assertEquals(1, classPathEntries.size()); UnmodifiableIterator<ClassPathEntry> iterator = classPathEntries.iterator(); assertEquals(Paths.get("a.jar"), iterator.next().getJar()); }
Example 4
Source File: ImmutableCollectionSerializers.java From dremio-oss with Apache License 2.0 | 5 votes |
@Override public void write(final Kryo kryo, final Output output, final ImmutableSet<Object> object) { output.writeInt(object.size(), true); final UnmodifiableIterator iterator = object.iterator(); while (iterator.hasNext()) { final Object value = iterator.next(); kryo.writeClassAndObject(output, value); } }
Example 5
Source File: SourceFiles.java From dagger2-sample with Apache License 2.0 | 5 votes |
/** * This method generates names and keys for the framework classes necessary for all of the * bindings. It is responsible for the following: * <ul> * <li>Choosing a name that associates the binding with all of the dependency requests for this * type. * <li>Choosing a name that is <i>probably</i> associated with the type being bound. * <li>Ensuring that no two bindings end up with the same name. * </ul> * * @return Returns the mapping from {@link BindingKey} to field, sorted by the name of the field. */ static ImmutableMap<BindingKey, FrameworkField> generateBindingFieldsForDependencies( DependencyRequestMapper dependencyRequestMapper, Iterable<? extends DependencyRequest> dependencies) { ImmutableSetMultimap<BindingKey, DependencyRequest> dependenciesByKey = indexDependenciesByKey(dependencies); Map<BindingKey, Collection<DependencyRequest>> dependenciesByKeyMap = dependenciesByKey.asMap(); ImmutableMap.Builder<BindingKey, FrameworkField> bindingFields = ImmutableMap.builder(); for (Entry<BindingKey, Collection<DependencyRequest>> entry : dependenciesByKeyMap.entrySet()) { BindingKey bindingKey = entry.getKey(); Collection<DependencyRequest> requests = entry.getValue(); Class<?> frameworkClass = dependencyRequestMapper.getFrameworkClass(requests.iterator().next()); // collect together all of the names that we would want to call the provider ImmutableSet<String> dependencyNames = FluentIterable.from(requests).transform(new DependencyVariableNamer()).toSet(); if (dependencyNames.size() == 1) { // if there's only one name, great! use it! String name = Iterables.getOnlyElement(dependencyNames); bindingFields.put(bindingKey, FrameworkField.createWithTypeFromKey(frameworkClass, bindingKey, name)); } else { // in the event that a field is being used for a bunch of deps with different names, // add all the names together with "And"s in the middle. E.g.: stringAndS Iterator<String> namesIterator = dependencyNames.iterator(); String first = namesIterator.next(); StringBuilder compositeNameBuilder = new StringBuilder(first); while (namesIterator.hasNext()) { compositeNameBuilder.append("And").append( CaseFormat.LOWER_CAMEL.to(UPPER_CAMEL, namesIterator.next())); } bindingFields.put(bindingKey, FrameworkField.createWithTypeFromKey( frameworkClass, bindingKey, compositeNameBuilder.toString())); } } return bindingFields.build(); }
Example 6
Source File: SchedulerTest.java From caffeine with Apache License 2.0 | 5 votes |
@DataProvider(name = "schedulers") public Iterator<Scheduler> providesSchedulers() { ImmutableSet<Scheduler> schedulers = ImmutableSet.of( Scheduler.forScheduledExecutorService(sameThreadScheduledExecutor()), Scheduler.forScheduledExecutorService(scheduledExecutor), Scheduler.disabledScheduler(), Scheduler.systemScheduler()); return schedulers.iterator(); }
Example 7
Source File: ImmutablesTester.java From gwt-jackson with Apache License 2.0 | 5 votes |
public void testImmutableSet( ObjectMapperTester<ImmutableSet<Integer>> mapper ) { String json = mapper.write( ImmutableSet.of( 3, 7, 8 ) ); assertEquals( "[3,7,8]", json ); ImmutableSet<Integer> set = mapper.read( json ); assertEquals( 3, set.size() ); Iterator<Integer> it = set.iterator(); assertEquals( Integer.valueOf( 3 ), it.next() ); assertEquals( Integer.valueOf( 7 ), it.next() ); assertEquals( Integer.valueOf( 8 ), it.next() ); set = mapper.read( "[ ]" ); assertEquals( 0, set.size() ); }
Example 8
Source File: ServerOpHelper.java From geowave with Apache License 2.0 | 4 votes |
public static boolean updateServerOps( final ServerSideOperations operations, final String index, final ServerOpConfig... configs) { if ((configs != null) && (configs.length > 0)) { final Map<String, ImmutableSet<ServerOpScope>> iteratorScopes = operations.listServerOps(index); for (final ServerOpConfig config : configs) { boolean mustDelete = false; boolean exists = false; final ImmutableSet<ServerOpScope> existingScopes = iteratorScopes.get(config.getServerOpName()); ImmutableSet<ServerOpScope> configuredScopes; if (config.getScopes() == null) { configuredScopes = Sets.immutableEnumSet(EnumSet.allOf(ServerOpScope.class)); } else { configuredScopes = Sets.immutableEnumSet(config.getScopes()); } Map<String, String> configuredOptions = null; if (existingScopes != null) { if (existingScopes.size() == configuredScopes.size()) { exists = true; for (final ServerOpScope s : existingScopes) { if (!configuredScopes.contains(s)) { // this iterator exists with the wrong // scope, we will assume we want to remove // it and add the new configuration LOGGER.warn( "found iterator '" + config.getServerOpName() + "' missing scope '" + s.name() + "', removing it and re-attaching"); mustDelete = true; break; } } } if (existingScopes.size() > 0) { // see if the options are the same, if they are not // the same, apply a merge with the existing options // and the configured options final Iterator<ServerOpScope> it = existingScopes.iterator(); while (it.hasNext()) { final ServerOpScope scope = it.next(); final Map<String, String> existingOptions = operations.getServerOpOptions(index, config.getServerOpName(), scope); configuredOptions = config.getOptions(existingOptions); if (existingOptions == null) { mustDelete = (configuredOptions == null); } else if (configuredOptions == null) { mustDelete = true; } else { // neither are null, compare the size of // the entry sets and check that they // are equivalent final Set<Entry<String, String>> existingEntries = existingOptions.entrySet(); final Set<Entry<String, String>> configuredEntries = configuredOptions.entrySet(); if (existingEntries.size() != configuredEntries.size()) { mustDelete = true; } else { mustDelete = (!existingEntries.containsAll(configuredEntries)); } } // we found the setting existing in one // scope, assume the options are the same // for each scope break; } } } if (configuredOptions == null) { configuredOptions = config.getOptions(new HashMap<String, String>()); } if (mustDelete) { operations.updateServerOp( index, config.getServerOpPriority(), config.getServerOpName(), config.getServerOpClass(), configuredOptions, existingScopes, configuredScopes); } else if (!exists) { operations.addServerOp( index, config.getServerOpPriority(), config.getServerOpName(), config.getServerOpClass(), configuredOptions, configuredScopes); } } } return true; }