List of usage examples for com.google.common.collect TreeMultimap create
public static <K, V> TreeMultimap<K, V> create(Comparator<? super K> keyComparator, Comparator<? super V> valueComparator)
From source file:io.github.egonw.analysis.StructuralAnalysis.java
/** Computes bridge atoms and bonds for structures that share components. */ private void sharedComponents() { for (String atomSet : StructuralAnalysis.richAtomSets.keySet()) { TreeMultimap<String, String> connectionsSet = TreeMultimap.create(new CMLNameComparator(), new CMLNameComparator()); RichAtomSet richAtomSet = this.getRichAtomSet(atomSet); for (String component : richAtomSet.getComponents()) { RichStructure<?> richComponent = this.getRichStructure(component); Set<String> contexts = Sets.intersection(richComponent.getContexts(), StructuralAnalysis.richAtomSets.keySet()); for (String context : contexts) { if (richAtomSet.getSubSystems().contains(context) || richAtomSet.getSuperSystems().contains(context) || context.equals(atomSet)) { continue; }//from w ww . j a va 2 s . co m connectionsSet.put(context, component); } } this.makeConnections(richAtomSet, connectionsSet); } }
From source file:org.onebusaway.nyc.vehicle_tracking.impl.inference.BlockStateService.java
private Map<BlockLocationKey, BestBlockStates> computeBlockStatesForObservation(Observation observation) { final Map<BlockLocationKey, BestBlockStates> results = Maps.newHashMap(); Set<String> validRunIds = null; if (_requireRunMatchesForNullDSC) { validRunIds = Sets.newHashSet(Iterables.concat(observation.getBestFuzzyRunIds(), Collections.singleton(observation.getOpAssignedRunId()))); }/*from w w w . j a v a2 s . co m*/ final NycRawLocationRecord record = observation.getRecord(); final String vehicleAgencyId = record.getVehicleId().getAgencyId(); final long time = observation.getTime(); final Date timeFrom = new Date(time - _tripSearchTimeAfterLastStop); final Date timeTo = new Date(time + _tripSearchTimeBeforeFirstStop); final CoordinateBounds bounds = SphericalGeometryLibrary.bounds(record.getLatitude(), record.getLongitude(), _tripSearchRadius); final Coordinate obsPoint = new Coordinate(record.getLongitude(), record.getLatitude()); final Envelope searchEnv = new Envelope(bounds.getMinLon(), bounds.getMaxLon(), bounds.getMinLat(), bounds.getMaxLat()); @SuppressWarnings("unchecked") final List<Collection<LocationIndexedLine>> lineMatches = _index.query(searchEnv); final Multimap<BlockInstance, Double> instancesToDists = TreeMultimap .create(BlockInstanceComparator.INSTANCE, Ordering.natural()); // lines under the current observed location for (final LocationIndexedLine line : Iterables.concat(lineMatches)) { final LinearLocation here = line.project(obsPoint); final Coordinate pointOnLine = line.extractPoint(here); final double dist = pointOnLine.distance(obsPoint); // filter out if too far away if (dist > _tripSearchRadius) continue; final Multimap<LocationIndexedLine, TripInfo> linesToTripInfoForVehicleAgencyId = _linesToTripInfoByAgencyId .get(vehicleAgencyId); if (linesToTripInfoForVehicleAgencyId == null || linesToTripInfoForVehicleAgencyId.isEmpty()) { continue; } // trips that follow the path under the current observed location for (final TripInfo tripInfo : linesToTripInfoForVehicleAgencyId.get(line)) { final Collection<BlockTripIndex> indices = tripInfo.getIndices(); final Collection<BlockLayoverIndex> layoverIndices = tripInfo.getLayoverIndices(); final Collection<FrequencyBlockTripIndex> frequencyIndices = tripInfo.getFrequencyIndices(); final Coordinate startOfLine = line.extractPoint(line.getStartIndex()); final double distTraveledOnLine = TurboButton.distance(pointOnLine.y, pointOnLine.x, startOfLine.y, startOfLine.x); final double distanceAlongShape = tripInfo.getDistanceFrom() + distTraveledOnLine; List<BlockInstance> instances = _blockCalendarService.getActiveBlocksInTimeRange(indices, layoverIndices, frequencyIndices, timeFrom.getTime(), timeTo.getTime()); for (BlockInstance instance : instances) { for (BlockTripEntry blockTrip : instance.getBlock().getTrips()) { /* * XXX: This is still questionable, however, * ScheduledBlockLocationServiceImpl.java appears to do something * similar, where it assumes the block's distance-along can be * related to the shape's (for the particular BlockTripEntry). * (see ScheduledBlockLocationServiceImpl.getLocationAlongShape) * * Anyway, what we're doing is using the blockTrip's * getDistanceAlongBlock to find out what the distance-along the * block is for the start of the shape, then we're using our * computed distance along shape for the snapped point to find the * total distanceAlongBlock. */ final double distanceAlongBlock = blockTrip.getDistanceAlongBlock() + distanceAlongShape; /* * Here we make sure that the DSC and/or run-info matches */ if (_requireDSCImpliedRoutes) { if (!observation.getImpliedRouteCollections() .contains(blockTrip.getTrip().getRouteCollection().getId())) continue; } if (_requireRunMatchesForNullDSC) { /* * When there is no valid DSC only allow snapping * to assigned or best fuzzy run. */ if (!observation.hasValidDsc()) { if (Sets.intersection(validRunIds, _runService.getRunIdsForTrip(blockTrip.getTrip())).isEmpty()) { continue; } } } instancesToDists.put(instance, distanceAlongBlock); } } } } for (final Entry<BlockInstance, Collection<Double>> biEntry : instancesToDists.asMap().entrySet()) { final BlockInstance instance = biEntry.getKey(); final int searchTimeFrom = (int) (timeFrom.getTime() - instance.getServiceDate()) / 1000; final int searchTimeTo = (int) (timeTo.getTime() - instance.getServiceDate()) / 1000; final Map<Map.Entry<BlockTripEntry, String>, Min<ScheduledBlockLocation>> tripToDists = Maps .newHashMap(); /* * TODO could do some really easy improved traversing of these * distances... */ for (final Double distanceAlongBlock : biEntry.getValue()) { final ScheduledBlockLocation location = _scheduledBlockLocationService .getScheduledBlockLocationFromDistanceAlongBlock(instance.getBlock(), distanceAlongBlock); if (location == null) continue; /* * Don't consider opposite direction trips. */ if (movedInOppositeDirection(observation, location)) continue; /* * Should be increasing time for increasing distanceAlongBlock... */ final int schedTime = location.getScheduledTime(); if (schedTime > searchTimeTo) break; if (schedTime < searchTimeFrom) continue; final BlockTripEntry activeTrip = location.getActiveTrip(); final Map.Entry<BlockTripEntry, String> tripDistEntry = Maps.immutableEntry(activeTrip, activeTrip.getTrip().getDirectionId()); Min<ScheduledBlockLocation> thisMin = tripToDists.get(tripDistEntry); if (thisMin == null) { thisMin = new Min<ScheduledBlockLocation>(); tripToDists.put(tripDistEntry, thisMin); } final double dist = TurboButton.distance(observation.getLocation(), location.getLocation()); thisMin.add(dist, location); } for (final Min<ScheduledBlockLocation> thisMin : tripToDists.values()) { final ScheduledBlockLocation location = thisMin.getMinElement(); final BlockTripEntry activeTrip = location.getActiveTrip(); final String dsc = _destinationSignCodeService .getDestinationSignCodeForTripId(activeTrip.getTrip().getId()); final RunTripEntry rte = _runService.getRunTripEntryForTripAndTime(activeTrip.getTrip(), location.getScheduledTime()); final BlockState state = new BlockState(instance, location, rte, dsc); final BlockLocationKey key = new BlockLocationKey(instance, 0, Double.POSITIVE_INFINITY); BestBlockStates currentStates = results.get(key); if (currentStates == null) { currentStates = new BestBlockStates(Sets.newHashSet(state)); results.put(key, currentStates); } else { currentStates.getAllStates().add(state); } } } return results; }
From source file:org.apache.beam.sdk.io.FileSystems.java
@VisibleForTesting static Map<String, FileSystem> verifySchemesAreUnique(PipelineOptions options, Set<FileSystemRegistrar> registrars) { Multimap<String, FileSystem> fileSystemsBySchemes = TreeMultimap.create(Ordering.<String>natural(), Ordering.arbitrary());/*from www. j a va 2 s. co m*/ for (FileSystemRegistrar registrar : registrars) { for (FileSystem fileSystem : registrar.fromOptions(options)) { fileSystemsBySchemes.put(fileSystem.getScheme(), fileSystem); } } for (Entry<String, Collection<FileSystem>> entry : fileSystemsBySchemes.asMap().entrySet()) { if (entry.getValue().size() > 1) { String conflictingFileSystems = Joiner.on(", ") .join(FluentIterable.from(entry.getValue()).transform(new Function<FileSystem, String>() { @Override public String apply(@Nonnull FileSystem input) { return input.getClass().getName(); } }).toSortedList(Ordering.<String>natural())); throw new IllegalStateException(String.format("Scheme: [%s] has conflicting filesystems: [%s]", entry.getKey(), conflictingFileSystems)); } } ImmutableMap.Builder<String, FileSystem> schemeToFileSystem = ImmutableMap.builder(); for (Entry<String, FileSystem> entry : fileSystemsBySchemes.entries()) { schemeToFileSystem.put(entry.getKey(), entry.getValue()); } return schemeToFileSystem.build(); }
From source file:de.hzi.helmholtz.Compare.PathwayComparisonUsingModules.java
public Multimap<Double, String> SubsetsMatching(final PathwayUsingModules firstPathway, final PathwayUsingModules secondPathway, BiMap<String, Integer> newSourceGeneIdToPositionMap, BiMap<String, Integer> newTargetGeneIdToPositionMap, int Yes) { Multimap<Double, String> resultPerfect = TreeMultimap.create(Ordering.natural().reverse(), Ordering.natural());//from w w w .j a v a 2 s. c o m PathwayUsingModules firstPathwayCopy = new PathwayUsingModules(firstPathway);// Copy of the Query pathway PathwayUsingModules secondPathwayCopy = new PathwayUsingModules(secondPathway);// Copy of the Target pathway' // PathwayUsingModules secondPathwayCopy1 = new PathwayUsingModules(secondPathway); int currentQueryGene = 0; Iterator<Module> sourceGeneIt = firstPathway.geneIterator(); List<String> QueryToRemove = new ArrayList<String>(); List<String> TargetToRemove = new ArrayList<String>(); while (sourceGeneIt.hasNext()) { currentQueryGene++; Module queryGene = sourceGeneIt.next(); int currentTargetGene = 0; Multiset<String> qfunction = LinkedHashMultiset.create(); List<String> qfunctionList = new ArrayList<String>(); List<String> qactivity = new ArrayList<String>(); List<Set<String>> qsubstrate = new ArrayList<Set<String>>(); for (Domain d : queryGene.getDomains()) { qfunction.add(d.getDomainFunctionString()); qfunctionList.add(d.getDomainFunctionString()); qactivity.add(d.getStatus().toString()); qsubstrate.add(d.getSubstrates()); } Iterator<Module> targetGeneIt = secondPathway.geneIterator(); while (targetGeneIt.hasNext()) { currentTargetGene++; Module targetGene = targetGeneIt.next(); Multiset<String> tfunction = LinkedHashMultiset.create(); List<String> tfunctionList = new ArrayList<String>(); List<String> tactivity = new ArrayList<String>(); List<Set<String>> tsubstrate = new ArrayList<Set<String>>(); for (Domain d : targetGene.getDomains()) { tfunctionList.add(d.getDomainFunctionString()); tfunction.add(d.getDomainFunctionString()); tactivity.add(d.getStatus().toString()); tsubstrate.add(d.getSubstrates()); } Multiset<String> DomainsCovered = Multisets.intersection(qfunction, tfunction); if (DomainsCovered.size() == qfunction.size() && DomainsCovered.size() == tfunction.size()) { Multimap<Double, Multimap<String, Integer>> activityscores = myFunction.calculate(qactivity, tactivity); Multimap<String, Integer> Functionscores = ArrayListMultimap.create(); int TranspositionDomains = LevenshteinDistance.computeLevenshteinDistance(qfunctionList, tfunctionList); if (TranspositionDomains > 0) { TranspositionDomains = 1; } Functionscores.put(qfunction.size() + "-0", TranspositionDomains); Multimap<Double, Multimap<String, Integer>> substratescore = myFunction .calculate(getSubstrateList(qsubstrate), getSubstrateList(tsubstrate)); Object activityScore = activityscores.asMap().keySet().toArray()[0]; Object substrateScore = substratescore.asMap().keySet().toArray()[0]; double finalScore = Math .round((((2.9 * 1.0) + (0.05 * Double.parseDouble(activityScore.toString().trim())) + (0.05 * Double.parseDouble(substrateScore.toString().trim()))) / 3) * 100.0) / 100.0; String ConvertedGeneIDs = ""; if (Yes == 0) { ConvertedGeneIDs = reconstructWithGeneId(Integer.toString(currentQueryGene), newSourceGeneIdToPositionMap) + "->" + reconstructWithGeneId(Integer.toString(currentTargetGene), newTargetGeneIdToPositionMap); } else { ConvertedGeneIDs = reconstructWithGeneId(Integer.toString(currentTargetGene), newTargetGeneIdToPositionMap) + "->" + reconstructWithGeneId(Integer.toString(currentQueryGene), newSourceGeneIdToPositionMap); } resultPerfect.put(finalScore, ConvertedGeneIDs); ScoreFunctionMatchMisMatch.put(ConvertedGeneIDs, Functionscores); ScoreStatusMatchMisMatch.putAll(ConvertedGeneIDs, activityscores.values()); ScoreSubstrateMatchMisMatch.putAll(ConvertedGeneIDs, substratescore.values()); TargetToRemove.add(reconstructWithGeneId(Integer.toString(currentTargetGene), newTargetGeneIdToPositionMap)); QueryToRemove.add(reconstructWithGeneId(Integer.toString(currentQueryGene), newSourceGeneIdToPositionMap)); } } } for (String i : TargetToRemove) { secondPathwayCopy.removeModule(i); } for (String i : QueryToRemove) { firstPathwayCopy.removeModule(i); } if (firstPathwayCopy.size() > 0 && secondPathwayCopy.size() > 0) { // Re-construct the bimaps newSourceGeneIdToPositionMap = HashBiMap.create(); int temp = 0; for (Module e : firstPathwayCopy.getModules()) { temp = temp + 1; newSourceGeneIdToPositionMap.put(e.getModuleId(), temp); } newTargetGeneIdToPositionMap = HashBiMap.create(); temp = 0; for (Module e : secondPathwayCopy.getModules()) { temp = temp + 1; newTargetGeneIdToPositionMap.put(e.getModuleId(), temp); } resultPerfect.putAll(SubsetIdentification(firstPathwayCopy, secondPathwayCopy, newSourceGeneIdToPositionMap, newTargetGeneIdToPositionMap, Yes)); } ////System.out.println(resultPerfect); return resultPerfect; }
From source file:de.hzi.helmholtz.Compare.PathwayComparisonWithModules.java
public void SubsetMatchingOfPathways() { PathwayWithModules newSource = new PathwayWithModules(source); PathwayWithModules newTarget = new PathwayWithModules(target); BiMap<Integer, Integer> newSourceGeneIdToPositionMap = srcGeneIdToPositionMap; BiMap<Integer, Integer> newTargetGeneIdToPositionMap = tgtGeneIdToPositionMap; int Yes = 0;/*from ww w . j av a 2s . c o m*/ Multimap<Double, String> forward = SubsetsMatching(newSource, newTarget, newSourceGeneIdToPositionMap, newTargetGeneIdToPositionMap, Yes); // key: qgeneId, value: {score=tgenecombination;...} newSource = new PathwayWithModules(SimpleCompareWithModules.sourcecopy); newTarget = new PathwayWithModules(SimpleCompareWithModules.targetcopy); Yes = 1; Multimap<Double, String> reverse = SubsetsMatching(newTarget, newSource, newTargetGeneIdToPositionMap, newSourceGeneIdToPositionMap, Yes); TreeMultimap<Double, String> globalMap = TreeMultimap.create(Ordering.natural().reverse(), Ordering.natural()); globalMap.putAll(forward); globalMap.putAll(reverse); //System.out.println(globalMap); bestResultMapping = GetBestFromGlobalMap(globalMap); // Calculations4SubsetBitScore System.out.println(bestResultMapping); Double Bitscore = Calculations4SubsetBitScore(bestResultMapping); int m = SimpleCompare.SizeofTargetPathwaysInDatabase; int n = SimpleCompare.SizeofQueryPathway; double eval = (m * n * kscore * (Math.exp(-(lambda * Bitscore)))); System.out.println(Bitscore); String[] SourcePathwaysID = source.getPathwayId().split("_"); String[] TargetPathwaysID = target.getPathwayId().split("_"); System.out.println("*********************"); // write result ot database for further use try { // todatabase.WriteToDatabase(UniqueJobID, SourcePathwaysID[0].trim(), SourcePathwaysID[1].trim(), TargetPathwaysID[0].trim(), TargetPathwaysID[1].trim(), bestResultMapping.toString(), Bitscore, eval); } catch (Exception e) { e.printStackTrace(); } }
From source file:de.hzi.helmholtz.Compare.PathwayComparisonUsingModules.java
public Multimap<Double, String> SubsetIdentification(PathwayUsingModules firstPathway, PathwayUsingModules secondPathway, BiMap<String, Integer> newSourceGeneIdToPositionMap, BiMap<String, Integer> newTargetGeneIdToPositionMap, int Yes) { Multimap<Double, String> result = TreeMultimap.create(Ordering.natural().reverse(), Ordering.natural()); Iterator<Module> sourceGeneIt = firstPathway.geneIterator(); int currentQueryGene = 0; while (sourceGeneIt.hasNext()) { currentQueryGene++;//from w w w . ja v a 2 s . c o m Module queryGene = sourceGeneIt.next(); Multimap<Integer, String> resultr = TreeMultimap.create(Ordering.natural(), Ordering.natural()); int currentTargetGene = 0; Multiset<String> qfunction = LinkedHashMultiset.create(); List<String> qfunctionList = new ArrayList<String>(); List<String> qactivity = new ArrayList<String>(); List<Set<String>> qsubstrate = new ArrayList<Set<String>>(); for (Domain d : queryGene.getDomains()) { qfunction.add(d.getDomainFunctionString()); qfunctionList.add(d.getDomainFunctionString()); qactivity.add(d.getStatus().toString()); qsubstrate.add(d.getSubstrates()); } List<String> TargenesSelected = new ArrayList<String>(); Iterator<Module> targetGeneIt = secondPathway.geneIterator(); while (targetGeneIt.hasNext()) { currentTargetGene++; Module targetGene = targetGeneIt.next(); Multiset<String> tfunction = LinkedHashMultiset.create(); List<String> tactivity = new ArrayList<String>(); List<Set<String>> tsubstrate = new ArrayList<Set<String>>(); List<String> tfunctionList = new ArrayList<String>(); Iterator<Domain> dIter = targetGene.domainIterator(); while (dIter.hasNext()) { Domain d = dIter.next(); tfunction.add(d.getDomainFunctionString()); tfunctionList.add(d.getDomainFunctionString()); tactivity.add(d.getStatus().toString()); tsubstrate.add(d.getSubstrates()); } Multiset<String> DomainsCovered = Multisets.intersection(qfunction, tfunction); int Differences = Math.max(Math.abs(DomainsCovered.size() - tfunction.size()), Math.abs(DomainsCovered.size() - qfunction.size())); if (DomainsCovered.size() == tfunction.size() && tfunction.size() > 4) { TargenesSelected.add(Integer.toString(currentTargetGene)); } else { resultr.put(Differences, Integer.toString(currentTargetGene)); } } int count = 0; if (resultr.size() > 0) { int tsize = 0; if ((firstPathway.size() > 8 && firstPathway.size() < 10) || (secondPathway.size() > 8 && secondPathway.size() < 10)) { tsize = 2; } else if ((firstPathway.size() > 2 && firstPathway.size() < 8) && (secondPathway.size() > 2 && secondPathway.size() < 8)) { tsize = 4; } else { tsize = 1; } while (TargenesSelected.size() < tsize) { Multiset<String> k = LinkedHashMultiset.create(resultr.values()); Multiset<String> t = LinkedHashMultiset.create(TargenesSelected); Multiset<String> Covered = Multisets.intersection(k, t); if (Covered.size() == k.size()) { break; } try { TargenesSelected.addAll( resultr.get(Integer.parseInt(resultr.keySet().toArray()[count].toString()))); } catch (Exception ds) { } count = count + 1; } } // ////System.out.println(TargenesSelected); // Permutation perm = new Permutation(); // List<String> perms = perm.run(TargenesSelected); CombinationGenerator c = new CombinationGenerator(10, 10); List<String> perms = c.GenerateAllPossibleCombinations(TargenesSelected); myFunction sim = new myFunction(); double score = 0; String targetIdentified = ""; List<Module> targetGenesList = secondPathway.getModules(); for (String permu : perms) { String[] values = permu.replace("[", "").replace("]", "").split(","); List<String> mergedTargetgenes = new ArrayList<String>(); List<Integer> ToRemove = new ArrayList<Integer>(); List<String> tactivity = new ArrayList<String>(); List<Set<String>> tsubstrate = new ArrayList<Set<String>>(); for (String j : values) { ToRemove.add(Integer.parseInt(j.trim())); for (Domain i : targetGenesList.get(Integer.parseInt(j.trim()) - 1).getDomains()) { mergedTargetgenes.add(i.getDomainFunctionString()); tactivity.add(i.getStatus().toString()); tsubstrate.add(i.getSubstrates()); } } Multimap<Double, Multimap<String, Integer>> FunctionScores = sim.calculate(qfunctionList, mergedTargetgenes); Multimap<Double, Multimap<String, Integer>> activityscores = myFunction.calculate(qactivity, tactivity); Multimap<Double, Multimap<String, Integer>> substratescores = myFunction .calculate(getSubstrateList(qsubstrate), getSubstrateList(tsubstrate)); Object FunctionScore = FunctionScores.asMap().keySet().toArray()[0]; Object activityScore = activityscores.asMap().keySet().toArray()[0]; Object substrateScore = substratescores.asMap().keySet().toArray()[0]; double finalScore = Math .round((((2.9 * Double.parseDouble(FunctionScore.toString().trim())) + (0.05 * Double.parseDouble(activityScore.toString().trim())) + (0.05 * Double.parseDouble(substrateScore.toString().trim()))) / 3) * 100.0) / 100.0; targetIdentified = permu.replace(",", "+"); String ConvertedGeneIDs = ""; if (Yes == 0) { ConvertedGeneIDs = reconstructWithGeneId(Integer.toString(currentQueryGene), newSourceGeneIdToPositionMap) + "->" + reconstructWithGeneId(targetIdentified.replace("[", "").replace("]", ""), newTargetGeneIdToPositionMap); } else { ConvertedGeneIDs = reconstructWithGeneId(targetIdentified.replace("[", "").replace("]", ""), newTargetGeneIdToPositionMap) + "->" + reconstructWithGeneId(Integer.toString(currentQueryGene), newSourceGeneIdToPositionMap); } // String ConvertedGeneIDs = reconstructWithGeneId(Integer.toString(currentQueryGene), newSourceGeneIdToPositionMap) + "->" + reconstructWithGeneId(targetIdentified.replace("[", "").replace("]", ""), newTargetGeneIdToPositionMap); result.put(finalScore, ConvertedGeneIDs); ScoreFunctionMatchMisMatch.putAll(ConvertedGeneIDs, FunctionScores.values()); ScoreStatusMatchMisMatch.putAll(ConvertedGeneIDs, activityscores.values()); ScoreSubstrateMatchMisMatch.putAll(ConvertedGeneIDs, substratescores.values()); } } return result; }
From source file:com.palantir.atlasdb.keyvalue.cassandra.CassandraKeyValueService.java
private List<Callable<Void>> getLoadWithTsTasksForSingleHost(final InetAddress host, final String tableName, Collection<Cell> cells, final long startTs, final boolean loadAllTs, final ThreadSafeResultVisitor v, final ConsistencyLevel consistency) throws Exception { final ColumnParent colFam = new ColumnParent(internalTableName(tableName)); TreeMultimap<byte[], Cell> cellsByCol = TreeMultimap.create(UnsignedBytes.lexicographicalComparator(), Ordering.natural());//from w ww .ja v a2 s . com for (Cell cell : cells) { cellsByCol.put(cell.getColumnName(), cell); } List<Callable<Void>> tasks = Lists.newArrayList(); int fetchBatchCount = configManager.getConfig().fetchBatchCount(); for (final byte[] col : cellsByCol.keySet()) { if (cellsByCol.get(col).size() > fetchBatchCount) { log.warn( "Re-batching in getLoadWithTsTasksForSingleHost a call to {} for table {} that attempted to " + "multiget {} rows; this may indicate overly-large batching on a higher level.\n{}", host, tableName, cellsByCol.get(col).size(), CassandraKeyValueServices.getFilteredStackTrace("com.palantir")); } for (final List<Cell> partition : Lists.partition(ImmutableList.copyOf(cellsByCol.get(col)), fetchBatchCount)) { tasks.add(new Callable<Void>() { @Override public Void call() throws Exception { return clientPool.runWithPooledResourceOnHost(host, new FunctionCheckedException<Client, Void, Exception>() { @Override public Void apply(Client client) throws Exception { ByteBuffer start = CassandraKeyValueServices.makeCompositeBuffer(col, startTs - 1); ByteBuffer end = CassandraKeyValueServices.makeCompositeBuffer(col, -1); SliceRange slice = new SliceRange(start, end, false, loadAllTs ? Integer.MAX_VALUE : 1); SlicePredicate pred = new SlicePredicate(); pred.setSlice_range(slice); List<ByteBuffer> rowNames = Lists .newArrayListWithCapacity(partition.size()); for (Cell c : partition) { rowNames.add(ByteBuffer.wrap(c.getRowName())); } Map<ByteBuffer, List<ColumnOrSuperColumn>> results = multigetInternal( client, tableName, rowNames, colFam, pred, consistency); v.visit(results); return null; } @Override public String toString() { return "multiget_slice(" + host + ", " + colFam + ", " + partition.size() + " rows" + ")"; } }); } }); } } return tasks; }
From source file:com.zimbra.cs.account.Entry.java
/** * Sort a collection of Entries by locale-sensitive String comparison on * each entry's displayName. If there is no display name, use entry.getLabel() * as the key.//from w ww . j a va2 s. c om */ public static List<Entry> sortByDisplayName(Collection<? extends Entry> entries, Locale locale) { List<Entry> sorted = Lists.newArrayList(); // short-circuit if there is only one entry or no entry if (entries.size() <= 1) { sorted.addAll(entries); } else { Collator collator = Collator.getInstance(locale); TreeMultimap<CollationKey, Entry> map = TreeMultimap.create(Ordering.natural(), new SortByLabelAsc()); for (Entry entry : entries) { String key = entry.getAttr(Provisioning.A_displayName); if (key == null) { key = entry.getLabel(); } CollationKey collationKey = collator.getCollationKey(key); map.put(collationKey, entry); } sorted.addAll(map.values()); } return sorted; }
From source file:de.hzi.helmholtz.Compare.PathwayComparisonUsingModules.java
public void SubsetMatchingOfPathways() { PathwayUsingModules newSource = new PathwayUsingModules(source); PathwayUsingModules newTarget = new PathwayUsingModules(target); BiMap<String, Integer> newSourceGeneIdToPositionMap = srcGeneIdToPositionMap; BiMap<String, Integer> newTargetGeneIdToPositionMap = tgtGeneIdToPositionMap; int Yes = 0;/*w ww . j a v a 2 s .c o m*/ Multimap<Double, String> forward = SubsetsMatching(newSource, newTarget, newSourceGeneIdToPositionMap, newTargetGeneIdToPositionMap, Yes); // key: qgeneId, value: {score=tgenecombination;...} newSource = new PathwayUsingModules(SimpleCompareUsingModules.sourcecopy); newTarget = new PathwayUsingModules(SimpleCompareUsingModules.targetcopy); Yes = 1; Multimap<Double, String> reverse = SubsetsMatching(newTarget, newSource, newTargetGeneIdToPositionMap, newSourceGeneIdToPositionMap, Yes); TreeMultimap<Double, String> globalMap = TreeMultimap.create(Ordering.natural().reverse(), Ordering.natural()); globalMap.putAll(forward); globalMap.putAll(reverse); ////System.out.println(globalMap); bestResultMapping = GetBestFromGlobalMap(globalMap); // Calculations4SubsetBitScore System.out.println(bestResultMapping); Double Bitscore = Calculations4SubsetBitScore(bestResultMapping); int m = SimpleCompareUsingModules.SizeofTargetPathwaysInDatabase; int n = SimpleCompareUsingModules.SizeofQueryPathway; double eval = (m * n * kscore * (Math.exp(-(lambda * Bitscore)))); //System.out.println(Bitscore); maxbitscore = Bitscore; String[] SourcePathwaysID = source.getPathwayId().split("_"); String[] TargetPathwaysID = target.getPathwayId().split("_"); // write result ot database for further use try { if (self != 1) { // todatabase.WriteToDatabase(UniqueJobID, SourcePathwaysID[0].trim(), SourcePathwaysID[1].trim(), TargetPathwaysID[0].trim(), TargetPathwaysID[1].trim(), bestResultMapping.toString(), Bitscore, eval); } } catch (Exception ex) { ex.printStackTrace(); } }
From source file:org.apache.beam.sdk.options.PipelineOptionsFactory.java
/** * Validates that any method with the same name must have the same return type for all derived * interfaces of {@link PipelineOptions}. * * @param iface The interface to validate. *///from w w w . j a v a 2s.c o m private static void validateReturnType(Class<? extends PipelineOptions> iface) { Iterable<Method> interfaceMethods = FluentIterable .from(ReflectHelpers.getClosureOfMethodsOnInterface(iface)).filter(NOT_SYNTHETIC_PREDICATE) .toSortedSet(MethodComparator.INSTANCE); SortedSetMultimap<Method, Method> methodNameToMethodMap = TreeMultimap.create(MethodNameComparator.INSTANCE, MethodComparator.INSTANCE); for (Method method : interfaceMethods) { methodNameToMethodMap.put(method, method); } List<MultipleDefinitions> multipleDefinitions = Lists.newArrayList(); for (Map.Entry<Method, Collection<Method>> entry : methodNameToMethodMap.asMap().entrySet()) { Set<Class<?>> returnTypes = FluentIterable.from(entry.getValue()) .transform(ReturnTypeFetchingFunction.INSTANCE).toSet(); SortedSet<Method> collidingMethods = FluentIterable.from(entry.getValue()) .toSortedSet(MethodComparator.INSTANCE); if (returnTypes.size() > 1) { MultipleDefinitions defs = new MultipleDefinitions(); defs.method = entry.getKey(); defs.collidingMethods = collidingMethods; multipleDefinitions.add(defs); } } throwForMultipleDefinitions(iface, multipleDefinitions); }