Java Code Examples for com.google.common.collect.SetMultimap#entries()

The following examples show how to use com.google.common.collect.SetMultimap#entries() . 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: TableService.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public List<Pair<TableDesc, TableExtDesc>> extractHiveTableMeta(String[] tables, String project) throws Exception { // de-dup
    SetMultimap<String, String> db2tables = LinkedHashMultimap.create();
    for (String fullTableName : tables) {
        String[] parts = HadoopUtil.parseHiveTableName(fullTableName);
        db2tables.put(parts[0], parts[1]);
    }

    // load all tables first
    List<Pair<TableDesc, TableExtDesc>> allMeta = Lists.newArrayList();
    ProjectInstance projectInstance = getProjectManager().getProject(project);
    ISourceMetadataExplorer explr = SourceManager.getSource(projectInstance).getSourceMetadataExplorer();
    for (Map.Entry<String, String> entry : db2tables.entries()) {
        Pair<TableDesc, TableExtDesc> pair = explr.loadTableMetadata(entry.getKey(), entry.getValue(), project);
        TableDesc tableDesc = pair.getFirst();
        Preconditions.checkState(tableDesc.getDatabase().equals(entry.getKey().toUpperCase(Locale.ROOT)));
        Preconditions.checkState(tableDesc.getName().equals(entry.getValue().toUpperCase(Locale.ROOT)));
        Preconditions.checkState(tableDesc.getIdentity()
                .equals(entry.getKey().toUpperCase(Locale.ROOT) + "." + entry.getValue().toUpperCase(Locale.ROOT)));
        TableExtDesc extDesc = pair.getSecond();
        Preconditions.checkState(tableDesc.getIdentity().equals(extDesc.getIdentity()));
        allMeta.add(pair);
    }
    return allMeta;
}
 
Example 2
Source File: FileTree.java    From PeerWasp with MIT License 5 votes vote down vote up
private FileComponent findComponentInSetMultimap(FileComponent toSearch,
		SetMultimap<String, ? extends FileComponent> filesByContent){
	FileComponent result = null;
	String hash = "";
	if(toSearch.isFile()){
		hash = toSearch.getContentHash();
	} else {
		hash = ((FolderComposite)toSearch).getStructureHash();
	}

	logger.trace("Contenthash to search for: {}", hash);
	Set<? extends FileComponent> sameContentSet = filesByContent.get(hash);

	for(Map.Entry<String, ? extends FileComponent> entry : filesByContent.entries()){
		logger.trace("Path: {} Hash: {}", entry.getValue().getPath(), entry.getKey());
	}
	long minTimeDiff = Long.MAX_VALUE;
	for(FileComponent candidate : sameContentSet) {
		long timeDiff = toSearch.getAction().getTimestamp() - candidate.getAction().getTimestamp();
		if(timeDiff < minTimeDiff) {
			minTimeDiff = timeDiff;
			result = candidate;
		}
	}
	if(result != null){
		boolean isRemoved = sameContentSet.remove(result);
		logger.trace("findComponentsInSetMultimap - file: {} removed {}", result.getPath(), isRemoved);
	}

	return result;
}
 
Example 3
Source File: SetMultimapExpression.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Set<Entry<K, V>> entries() {
	final SetMultimap<K, V> setMultimap = get();
	return (setMultimap == null) ? EMPTY_SETMULTIMAP.entries()
			: setMultimap.entries();
}