List of usage examples for com.google.common.collect Maps newTreeMap
public static <C, K extends C, V> TreeMap<K, V> newTreeMap(@Nullable Comparator<C> comparator)
From source file:co.cask.cdap.api.dataset.lib.KeyValueTable.java
/** * Reads the values for an array of given keys. * * @param keys the keys to be read/*from ww w . ja v a2 s . c o m*/ * @return a map of the stored values, keyed by key */ public Map<byte[], byte[]> readAll(byte[][] keys) { List<Get> gets = Lists.newArrayListWithCapacity(keys.length); for (byte[] key : keys) { gets.add(new Get(key).add(KEY_COLUMN)); } List<Row> results = table.get(gets); Map<byte[], byte[]> values = Maps.newTreeMap(Bytes.BYTES_COMPARATOR); for (Row row : results) { if (row.get(KEY_COLUMN) != null) { values.put(row.getRow(), row.get(KEY_COLUMN)); } } return values; }
From source file:com.netflix.astyanax.impl.AstyanaxCheckpointManager.java
@Override public SortedMap<String, String> getCheckpoints() throws ConnectionException { SortedMap<String, String> checkpoints = Maps.newTreeMap(tokenComparator); for (Column<String> column : keyspace.prepareQuery(columnFamily).getKey(bbKey).execute().getResult()) { checkpoints.put(column.getName(), column.getStringValue()); }//from w w w . jav a2 s.co m return checkpoints; }
From source file:io.sarl.eclipse.wizards.elements.newevent.NewSarlEventWizardPage.java
@Override protected void getTypeContent(Resource ecoreResource, String typeComment) throws CoreException { GeneratedCode code = this.sarlGenerator.createScript(ecoreResource, getPackageFragment().getElementName()); io.sarl.lang.sarl.Event event = this.sarlGenerator.createEvent(code, getTypeName(), getSuperClass()); this.sarlGenerator.attachComment(code, event, typeComment); Map<SignatureKey, IMethod> constructors; String superClass = getSuperClass(); if (Strings.isNullOrEmpty(superClass) || !isCreateConstructors()) { constructors = null;/*from w w w . ja v a 2 s. c om*/ } else { constructors = Maps.newTreeMap((Comparator<SignatureKey>) null); } populateInheritanceContext(Jdt2Ecore.toTypeFinder(getJavaProject()), // Discarding final operation. null, // Discarding overridable operation. null, // Discarding inherited fields, null, // Discarding the operations to implement. null, constructors, code.getCodeGenerator().getActionSignatureProvider(), getSuperClass(), Collections.<String>emptyList()); if (constructors != null) { Jdt2Ecore.createStandardConstructors(code, constructors.values(), event); } code.finalizeScript(); }
From source file:io.sarl.eclipse.wizards.elements.aop.newevent.NewSarlEventWizardPage.java
@Override protected void getTypeContent(Resource ecoreResource, String typeComment) throws CoreException { IScriptBuilder scriptBuilder = this.codeBuilderFactory.createScript(getPackageFragment().getElementName(), ecoreResource);//from ww w. java 2s .c o m IEventBuilder event = scriptBuilder.addEvent(getTypeName()); event.setExtends(getSuperClass()); event.setDocumentation(typeComment.trim()); Map<ActionParameterTypes, IMethod> constructors; String superClass = getSuperClass(); if (Strings.isNullOrEmpty(superClass) || !isCreateConstructors()) { constructors = null; } else { constructors = Maps.newTreeMap((Comparator<ActionParameterTypes>) null); } this.jdt2sarl.populateInheritanceContext(this.jdt2sarl.toTypeFinder(getJavaProject()), // Discarding final operation. null, // Discarding overridable operation. null, // Discarding inherited fields, null, // Discarding the operations to implement. null, constructors, getSuperClass(), Collections.<String>emptyList()); if (constructors != null) { this.jdt2sarl.createStandardConstructors(event, constructors.values(), event.getSarlEvent()); } scriptBuilder.finalizeScript(); }
From source file:com.palantir.atlasdb.keyvalue.impl.Cells.java
public static <T> NavigableMap<byte[], SortedMap<byte[], T>> breakCellsUpByRow( Iterable<Map.Entry<Cell, T>> map) { NavigableMap<byte[], SortedMap<byte[], T>> ret = Maps.newTreeMap(UnsignedBytes.lexicographicalComparator()); for (Map.Entry<Cell, T> e : map) { byte[] row = e.getKey().getRowName(); SortedMap<byte[], T> sortedMap = ret.get(row); if (sortedMap == null) { sortedMap = Maps.newTreeMap(UnsignedBytes.lexicographicalComparator()); ret.put(row, sortedMap);/* ww w . j av a 2 s . com*/ } sortedMap.put(e.getKey().getColumnName(), e.getValue()); } return ret; }
From source file:io.sarl.eclipse.wizards.elements.newbehavior.NewSarlBehaviorWizardPage.java
@Override protected void getTypeContent(Resource ecoreResource, String typeComment) throws CoreException { GeneratedCode code = this.sarlGenerator.createScript(ecoreResource, getPackageFragment().getElementName()); io.sarl.lang.sarl.Behavior behavior = this.sarlGenerator.createBehavior(code, getTypeName(), getSuperClass());//from w w w . j av a 2s . com this.sarlGenerator.attachComment(code, behavior, typeComment); Map<ActionKey, IMethod> operationsToImplement; Map<SignatureKey, IMethod> constructors; String superClass = getSuperClass(); if (Strings.isNullOrEmpty(superClass) || !isCreateConstructors()) { constructors = null; } else { constructors = Maps.newTreeMap((Comparator<SignatureKey>) null); } if (isCreateInherited()) { operationsToImplement = Maps.newTreeMap((Comparator<ActionKey>) null); } else { operationsToImplement = null; } populateInheritanceContext(Jdt2Ecore.toTypeFinder(getJavaProject()), // Discarding final operation. null, // Discarding overridable operation. null, // Discarding inherited fields, null, operationsToImplement, constructors, code.getCodeGenerator().getActionSignatureProvider(), getSuperClass(), Collections.<String>emptyList()); if (constructors != null) { Jdt2Ecore.createStandardConstructors(code, constructors.values(), behavior); } if (operationsToImplement != null) { Jdt2Ecore.createActions(code, operationsToImplement.values(), behavior); } code.finalizeScript(); }
From source file:com.metamx.druid.query.group.orderby.DefaultLimitSpec.java
private Ordering<Row> makeComparator(List<DimensionSpec> dimensions, List<AggregatorFactory> aggs, List<PostAggregator> postAggs) { Ordering<Row> ordering = new Ordering<Row>() { @Override/* w w w . j a v a 2s . c o m*/ public int compare(Row left, Row right) { return Longs.compare(left.getTimestampFromEpoch(), right.getTimestampFromEpoch()); } }; Map<String, Ordering<Row>> possibleOrderings = Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER); for (DimensionSpec spec : dimensions) { final String dimension = spec.getOutputName(); possibleOrderings.put(dimension, dimensionOrdering(dimension)); } for (final AggregatorFactory agg : aggs) { final String column = agg.getName(); possibleOrderings.put(column, metricOrdering(column, agg.getComparator())); } for (PostAggregator postAgg : postAggs) { final String column = postAgg.getName(); possibleOrderings.put(column, metricOrdering(column, postAgg.getComparator())); } for (OrderByColumnSpec columnSpec : columns) { Ordering<Row> nextOrdering = possibleOrderings.get(columnSpec.getDimension()); if (nextOrdering == null) { throw new ISE("Unknown column in order clause[%s]", columnSpec); } switch (columnSpec.getDirection()) { case DESCENDING: nextOrdering = nextOrdering.reverse(); } ordering = ordering.compound(nextOrdering); } return ordering; }
From source file:com.palantir.atlasdb.keyvalue.rdbms.utils.AtlasSqlUtils.java
private static <K, V> SortedMap<K, Set<V>> listSortedMapToSetSortedMap(SortedMap<K, List<V>> map) { SortedMap<K, Set<V>> result = Maps.newTreeMap(map.comparator()); for (Entry<K, List<V>> e : map.entrySet()) { result.put(e.getKey(), Sets.<V>newHashSet(e.getValue())); }/*www. j a v a2s . co m*/ return result; }
From source file:io.sarl.eclipse.wizards.elements.aop.newbehavior.NewSarlBehaviorWizardPage.java
@Override protected void getTypeContent(Resource ecoreResource, String typeComment) throws CoreException { IScriptBuilder scriptBuilder = this.codeBuilderFactory.createScript(getPackageFragment().getElementName(), ecoreResource);//from w ww.j av a2s. c o m IBehaviorBuilder behavior = scriptBuilder.addBehavior(getTypeName()); behavior.setExtends(getSuperClass()); behavior.setDocumentation(typeComment); Map<ActionPrototype, IMethod> operationsToImplement; Map<ActionParameterTypes, IMethod> constructors; String superClass = getSuperClass(); if (Strings.isNullOrEmpty(superClass) || !isCreateConstructors()) { constructors = null; } else { constructors = Maps.newTreeMap((Comparator<ActionParameterTypes>) null); } if (isCreateInherited()) { operationsToImplement = Maps.newTreeMap((Comparator<ActionPrototype>) null); } else { operationsToImplement = null; } this.jdt2sarl.populateInheritanceContext(this.jdt2sarl.toTypeFinder(getJavaProject()), // Discarding final operation. null, // Discarding overridable operation. null, // Discarding inherited fields, null, operationsToImplement, constructors, getSuperClass(), Collections.<String>emptyList()); if (constructors != null) { this.jdt2sarl.createStandardConstructors(behavior, constructors.values(), behavior.getSarlBehavior()); } if (operationsToImplement != null) { this.jdt2sarl.createActions(behavior, operationsToImplement.values()); } scriptBuilder.finalizeScript(); }
From source file:org.apache.pulsar.client.impl.conf.ConsumerConfigurationData.java
public ConsumerConfigurationData<T> clone() { try {//from www . j a va 2 s. com @SuppressWarnings("unchecked") ConsumerConfigurationData<T> c = (ConsumerConfigurationData<T>) super.clone(); c.topicNames = Sets.newTreeSet(this.topicNames); c.properties = Maps.newTreeMap(this.properties); return c; } catch (CloneNotSupportedException e) { throw new RuntimeException("Failed to clone ConsumerConfigurationData"); } }