List of usage examples for com.google.common.collect Maps newTreeMap
public static <K extends Comparable, V> TreeMap<K, V> newTreeMap()
From source file:com.huawei.streaming.cql.tasks.CreateFunctionTask.java
private TreeMap<String, String> parseStreamProperties(StreamPropertiesContext streamPropertiesContext) { TreeMap<String, String> properties = Maps.newTreeMap(); for (KeyValuePropertyContext ctx : streamPropertiesContext.getProperties()) { String key = ctx.getKey(); String value = ctx.getValue(); properties.put(key, value);/*from ww w . j a v a 2 s.c om*/ } return properties; }
From source file:org.apache.giraph.metrics.NoOpMetricsRegistry.java
@Override public SortedMap<String, SortedMap<MetricName, Metric>> groupedMetrics() { return Maps.newTreeMap(); }
From source file:org.glassfish.jersey.internal.ExceptionMapperFactory.java
@SuppressWarnings("unchecked") private <T extends Throwable> ExceptionMapper<T> find(Class<T> type, T exceptionInstance) { Map<Integer, ExceptionMapper<T>> orderedMappers = Maps.newTreeMap(); for (ExceptionMapperType mapperType : exceptionMapperTypes) { int d = distance(type, mapperType.exceptionType); if (d >= 0) { orderedMappers.put(d, mapperType.mapper); }//from w ww . jav a 2 s . c o m } if (orderedMappers.size() == 0) { return null; } if (exceptionInstance != null) { for (ExceptionMapper<T> mapper : orderedMappers.values()) { if (mapper instanceof ExtendedExceptionMapper) { final boolean mappable = ((ExtendedExceptionMapper<T>) mapper).isMappable(exceptionInstance); if (mappable) { return mapper; } } else { return mapper; } } return null; } else { return orderedMappers.values().iterator().next(); } }
From source file:com.google.enterprise.connector.ldap.MockLdapHandlers.java
private static Map<String, Multimap<String, String>> makeSmallMultimapRepo() { Map<String, Multimap<String, String>> repo = Maps.newTreeMap(); String key;//from w w w .j av a2 s . c om ImmutableMultimap<String, String> person; key = "cn=Robert Smith,ou=people,dc=example,dc=com"; person = ImmutableMultimap.of("dn", key, "cn", "Robert Smith", "foo", "bar"); repo.put(key, person); key = "cn=Joseph Blow,ou=people,dc=example,dc=com"; person = ImmutableMultimap.of("dn", key, "cn", "Joseph Blow", "argle", "bargle"); repo.put(key, person); key = "cn=Jane Doe,ou=people,dc=example,dc=com"; person = ImmutableMultimap.of("dn", key, "cn", "Jane Doe", "foo", "baz"); repo.put(key, person); return repo; }
From source file:com.alibaba.wasp.master.handler.TableEventHandler.java
public boolean reOpenAllEntityGroups(List<EntityGroupInfo> entityGroups) throws IOException { boolean done = false; LOG.info("Bucketing entityGroups by entityGroup server..."); TreeMap<ServerName, List<EntityGroupInfo>> serverToEntityGroups = Maps.newTreeMap(); NavigableMap<EntityGroupInfo, ServerName> egiHserverMapping = FMetaScanner .allTableEntityGroups(server.getConfiguration(), tableName, false); List<EntityGroupInfo> reEntityGroups = new ArrayList<EntityGroupInfo>(); for (EntityGroupInfo egi : entityGroups) { ServerName egLocation = egiHserverMapping.get(egi); // Skip the offlined split parent EntityGroup if (null == egLocation) { LOG.info("Skip " + egi); continue; }/* w w w . j a v a 2s. co m*/ if (!serverToEntityGroups.containsKey(egLocation)) { LinkedList<EntityGroupInfo> egiList = Lists.newLinkedList(); serverToEntityGroups.put(egLocation, egiList); } reEntityGroups.add(egi); serverToEntityGroups.get(egLocation).add(egi); } LOG.info("Reopening " + reEntityGroups.size() + " entityGroups on " + serverToEntityGroups.size() + " fservers."); this.fMasterServices.getAssignmentManager().setEntityGroupsToReopen(reEntityGroups); BulkReOpen bulkReopen = new BulkReOpen(this.server, serverToEntityGroups, this.fMasterServices.getAssignmentManager()); while (true) { try { if (bulkReopen.bulkReOpen()) { done = true; break; } else { LOG.warn("Timeout before reopening all entityGroups"); } } catch (InterruptedException e) { LOG.warn("Reopen was interrupted"); // Preserve the interrupt. Thread.currentThread().interrupt(); break; } } return done; }
From source file:com.google.gdt.eclipse.designer.uibinder.model.widgets.WidgetTopBoundsSupport.java
private void invokeSizeScript(String scriptName, boolean required, Dimension size) throws Exception { String script = XmlObjectUtils.getParameter(m_widget, scriptName); if (script != null) { Map<String, Object> variables = Maps.newTreeMap(); variables.put("model", m_widget); variables.put("widget", m_widget.getObject()); variables.put("size", size); m_widget.getUIObjectUtils().executeScript(script, variables); }// w w w. j av a 2 s . c o m }
From source file:org.onosproject.store.primitives.resources.impl.AtomixConsistentTreeMapService.java
@Override protected TreeMap<String, MapEntryValue> createMap() { return Maps.newTreeMap(); }
From source file:com.moz.fiji.schema.impl.hbase.HBaseTableKeyValueDatabase.java
/** {@inheritDoc} */ @Override// www . ja v a 2s .c om public NavigableMap<Long, byte[]> getTimedValues(String table, String key, int numVersions) throws IOException { Preconditions.checkArgument(numVersions >= 1, "numVersions must be positive"); final byte[] bKey = Bytes.toBytes(key); Get get = new Get(Bytes.toBytes(table)).addColumn(mFamilyBytes, bKey); Result result = mTable.get(get); /** Map from timestamp to values. */ final NavigableMap<Long, byte[]> timedValues = Maps.newTreeMap(); // Pull out the full map: family -> qualifier -> timestamp -> TableLayoutDesc. // Family and qualifier are already specified : the 2 outer maps must be size 11. final NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> familyMap = result.getMap(); Preconditions.checkState(familyMap.size() == 1); final NavigableMap<byte[], NavigableMap<Long, byte[]>> qualifierMap = familyMap.get(familyMap.firstKey()); Preconditions.checkState(qualifierMap.size() == 1); final NavigableMap<Long, byte[]> timeSerieMap = qualifierMap.get(qualifierMap.firstKey()); for (Map.Entry<Long, byte[]> timeSerieEntry : timeSerieMap.entrySet()) { final long timestamp = timeSerieEntry.getKey(); final byte[] bytes = timeSerieEntry.getValue(); Preconditions.checkState(timedValues.put(timestamp, bytes) == null); } return timedValues; }
From source file:com.jvms.i18neditor.Editor.java
public void importResources(Path dir) { if (!closeCurrentSession()) { return;//from ww w . jav a 2 s. c o m } if (Files.isDirectory(dir, LinkOption.NOFOLLOW_LINKS)) { reset(); resourcesDir = dir; } else { showError(MessageBundle.get("resources.open.error.multiple")); return; } try { Files.walk(resourcesDir, 1).filter(path -> Resources.isResource(path)).forEach(path -> { try { Resource resource = Resources.read(path); setupResource(resource); } catch (Exception e) { e.printStackTrace(); showError(MessageBundle.get("resources.open.error.single", path.toString())); } }); List<String> recentDirs = settings.getListProperty("history"); recentDirs.remove(resourcesDir); recentDirs.add(resourcesDir.toString()); if (recentDirs.size() > 5) { recentDirs.remove(0); } settings.setProperty("history", recentDirs); editorMenu.setRecentItems(Lists.reverse(recentDirs)); Map<String, String> keys = Maps.newTreeMap(); resources.forEach(resource -> keys.putAll(resource.getTranslations())); List<String> keyList = Lists.newArrayList(keys.keySet()); translationTree.setModel(new TranslationTreeModel(keyList)); updateUI(); } catch (IOException e) { e.printStackTrace(); showError(MessageBundle.get("resources.open.error.multiple")); } }
From source file:org.apache.giraph.metrics.NoOpMetricsRegistry.java
@Override public SortedMap<String, SortedMap<MetricName, Metric>> groupedMetrics(MetricPredicate predicate) { return Maps.newTreeMap(); }