Java Code Examples for java.util.Map#isEmpty()

The following examples show how to use java.util.Map#isEmpty() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: dubbox   File: InjvmProtocol.java    License: Apache License 2.0 6 votes vote down vote up
static Exporter<?> getExporter(Map<String, Exporter<?>> map, URL key) {
    Exporter<?> result = null;

    if (!key.getServiceKey().contains("*")) {
        result = map.get(key.getServiceKey());
    } else {
        if (map != null && !map.isEmpty()) {
            for (Exporter<?> exporter : map.values()) {
                if (UrlUtils.isServiceKeyMatch(key, exporter.getInvoker().getUrl())) {
                    result = exporter;
                    break;
                }
            }
        }
    }

    if (result == null) {
        return null;
    } else if (ProtocolUtils.isGeneric(
        result.getInvoker().getUrl().getParameter(Constants.GENERIC_KEY))) {
        return null;
    } else {
        return result;
    }
}
 
Example 2
Source Project: disconf   File: SpringRegistry.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public <T> List<T> findByType(Class<T> type, boolean newInstance) {

    if (applicationContext == null) {
        LOGGER.error("Spring Context is null. Cannot autowire " + type.getCanonicalName());
        return new ArrayList<T>(0);
    }

    if (type == null) {
        return new ArrayList<T>(0);
    }

    Map<String, T> map = findByTypeWithName(type);
    if (map == null || map.isEmpty()) {
        if (newInstance) {
            LOGGER.debug("Not found from Spring IoC container for " + type.getSimpleName() + ", and try to init by "
                    + "calling newInstance.");
            return simpleRegistry.findByType(type, newInstance);
        }
    }

    return new ArrayList<T>(map.values());
}
 
Example 3
/**
 * This method finds out the cache to be used for lov's result cache. This key is composed mainly by the user identifier and the lov definition. Note that,
 * in case when the lov is a query and there is correlation, the executed statement if different from the original query (since correlation expression is
 * injected inside SQL query using in-line view construct), therefore we should consider the modified query.
 *
 * @param profile
 *            The user profile
 * @param lovDefinition
 *            The lov original definition
 * @param dependencies
 *            The dependencies to be considered (if any)
 * @param executionInstance
 *            The execution instance (it may be null, since a lov can be executed outside an execution instance context)
 * @return The key to be used in cache
 */
private String getCacheKey(IEngUserProfile profile, ILovDetail lovDefinition, List<ObjParuse> dependencies, ExecutionInstance executionInstance)
		throws Exception {
	logger.debug("IN");
	String toReturn = null;
	String userID = (String) ((UserProfile) profile).getUserId();
	if (lovDefinition instanceof QueryDetail) {
		QueryDetail queryDetail = (QueryDetail) lovDefinition;
		QueryDetail clone = queryDetail.clone();
		// clone.setQueryDefinition(queryDetail.getWrappedStatement(dependencies, executionInstance.getBIObject().getDrivers()));
		Map<String, String> parameters = queryDetail.getParametersNameToValueMap(executionInstance.getBIObject().getDrivers());
		String statement = queryDetail.getWrappedStatement(dependencies, executionInstance.getBIObject().getDrivers());
		statement = StringUtilities.substituteProfileAttributesInString(statement, profile);
		if (parameters != null && !parameters.isEmpty()) {
			Map<String, String> types = queryDetail.getParametersNameToTypeMap(executionInstance.getBIObject().getDrivers());
			statement = StringUtilities.substituteParametersInString(statement, parameters, types, false);
		}
		clone.setQueryDefinition(statement);
		toReturn = userID + ";" + clone.toXML();
	} else {
		toReturn = userID + ";" + lovDefinition.toXML();
	}
	logger.debug("OUT: returning [" + toReturn + "]");
	return toReturn;
}
 
Example 4
/**
 * Gets the values that have occurrences closest to given target count.
 * Above the count is always preferred to below the count, but exact is preferred to above.
 * TODO: VERIFY this works.
 */
static Set<String> getClosestValuesByCount(Map<String, Integer> counts, int targetCount) {
    Map<Integer, Set<String>> countMechs = makeCountValueMap(counts);
    if (countMechs.isEmpty()) {
        return Collections.emptySet();
    }
    List<Integer> highToLowCounts = new ArrayList<>(countMechs.keySet());
    Collections.sort(highToLowCounts, Collections.reverseOrder());

    ListIterator<Integer> it = highToLowCounts.listIterator();
    int count = it.next();
    while(it.hasNext() && (count = it.next()) >= targetCount) {
        ;
    }
    if (count >= targetCount) {
        return countMechs.get(count);
    } else {
        it.previous(); // discard to go back one
        if (it.hasPrevious()) {
            return countMechs.get(it.previous());
        } else {
            return countMechs.get(count);
        }
    }
}
 
Example 5
Source Project: JglTF   File: Technique.java    License: MIT License 6 votes vote down vote up
/**
 * Remove the given attributes. The attributes of this instance will be 
 * replaced with a map that contains all previous mappings, except for 
 * the one with the given key.<br> 
 * If this new map would be empty, then it will be set to 
 * <code>null</code>. 
 * 
 * @param key The key
 * @throws NullPointerException If the given key is <code>null</code>
 * 
 */
public void removeAttributes(String key) {
    if (key == null) {
        throw new NullPointerException("The key may not be null");
    }
    Map<String, String> oldMap = this.attributes;
    Map<String, String> newMap = new LinkedHashMap<String, String>();
    if (oldMap!= null) {
        newMap.putAll(oldMap);
    }
    newMap.remove(key);
    if (newMap.isEmpty()) {
        this.attributes = null;
    } else {
        this.attributes = newMap;
    }
}
 
Example 6
@Override
public Collection<T> getReverseDeps(Iterable<T> targets, QueryExpressionContext<T> context)
    throws InterruptedException {
  Map<SkyKey, T> targetsByKey = Maps.newHashMapWithExpectedSize(Iterables.size(targets));
  for (T target : targets) {
    targetsByKey.put(getSkyKey(target), target);
  }
  Map<SkyKey, ImmutableList<ClassifiedDependency<T>>> reverseDepsByKey =
      targetifyValues(targetsByKey, graph.getReverseDeps(targetsByKey.keySet()));
  if (targetsByKey.size() != reverseDepsByKey.size()) {
    Iterable<ConfiguredTargetKey> missingTargets =
        Sets.difference(targetsByKey.keySet(), reverseDepsByKey.keySet()).stream()
            .map(SKYKEY_TO_CTKEY)
            .collect(Collectors.toList());
    eventHandler.handle(Event.warn("Targets were missing from graph: " + missingTargets));
  }
  Map<T, ImmutableList<ClassifiedDependency<T>>> reverseDepsByCT = new HashMap<>();
  for (Map.Entry<SkyKey, ImmutableList<ClassifiedDependency<T>>> entry :
      reverseDepsByKey.entrySet()) {
    reverseDepsByCT.put(targetsByKey.get(entry.getKey()), entry.getValue());
  }
  return reverseDepsByCT.isEmpty() ? Collections.emptyList() : filterReverseDeps(reverseDepsByCT);
}
 
Example 7
public OpenNLPChunkerFilterFactory(Map<String,String> args) {
  super(args);
  chunkerModelFile = get(args, CHUNKER_MODEL);
  if (!args.isEmpty()) {
    throw new IllegalArgumentException("Unknown parameters: " + args);
  }
}
 
Example 8
Source Project: dubbox   File: RegistryProtocol.java    License: Apache License 2.0 5 votes vote down vote up
private static String[] getFilteredKeys(URL url) {
    Map<String, String> params = url.getParameters();
    if (params != null && !params.isEmpty()) {
        List<String> filteredKeys = new ArrayList<String>();
        for (Map.Entry<String, String> entry : params.entrySet()) {
            if (entry != null && entry.getKey() != null && entry.getKey().startsWith(Constants.HIDE_KEY_PREFIX)) {
                filteredKeys.add(entry.getKey());
            }
        }
        return filteredKeys.toArray(new String[filteredKeys.size()]);
    } else {
        return new String[] {};
    }
}
 
Example 9
Source Project: Openfire   File: ProfiledConnection.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns an array of sorted queries (as ProfiledConnectionEntry objects) by type
 *
 * @param type       the type of query to check
 * @param sortByTime sort the resulting list by Time if true,
 *                   otherwise sort by count if false (default)
 * @return an array of ProfiledConnectionEntry objects
 */
public static ProfiledConnectionEntry[] getSortedQueries(Type type, boolean sortByTime) {
    Map<String, ProfiledConnectionEntry> queries;

    switch (type) {
        case select:
            queries = selectQueries;
            break;
        case update:
            queries = updateQueries;
            break;
        case insert:
            queries = insertQueries;
            break;
        case delete:
            queries = deleteQueries;
            break;
        default:
            throw new IllegalArgumentException("Invalid type");
    }

    // No queries, return null
    if (queries.isEmpty()) {
        return null;
    }

    ProfiledConnectionEntry [] result = queries.values().toArray(
            new ProfiledConnectionEntry[queries.size()]);

    quickSort(result, sortByTime, 0, result.length - 1);
    return result;
}
 
Example 10
private void validateErrorEventData(Map<String, Object> edata, List<String> missingFields) {
  if (edata == null || edata.isEmpty()) {
    missingFields.add("edata");
  } else {
    if (StringUtils.isBlank((String) edata.get(JsonKey.ERROR))) {
      missingFields.add(JsonKey.ERROR);
    }
    if (StringUtils.isBlank((String) edata.get(JsonKey.ERR_TYPE))) {
      missingFields.add(JsonKey.ERR_TYPE);
    }
    if (StringUtils.isBlank((String) edata.get(JsonKey.STACKTRACE))) {
      missingFields.add(JsonKey.STACKTRACE);
    }
  }
}
 
Example 11
Source Project: timely   File: TagListParser.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * An alternative combiner for a map of string to string instead of a list of
 * tags
 * 
 * @return string representation
 */
public String combine(Map<String, String> tags) {
    StringBuilder builder = new StringBuilder();
    if (!tags.isEmpty()) {
        tags.forEach((k, v) -> builder.append(tagParser.combine(new Tag(k, v))).append(','));
        builder.setLength(builder.length() - 1);
    }
    return builder.toString();
}
 
Example 12
Source Project: bjnetwork   File: BJNetRequestManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 构建网络请求
 *
 * @param method
 * @param requestBody
 * @param url
 * @param cacheTimeSeconds
 * @param headers
 * @return
 */
protected Request buildRequest(HttpMethod method, RequestBody requestBody, String url, int cacheTimeSeconds,
    Map<String, String> headers) {

    if (TextUtils.isEmpty(url))
        throw new IllegalArgumentException("url is empty!!");

    Request.Builder builder = new Request.Builder();
    builder.method(method.getMethod(), requestBody);
    builder.url(url);
    if (cacheTimeSeconds > 0) {
        CacheControl cacheControl = new CacheControl.Builder()
                .maxAge(cacheTimeSeconds, TimeUnit.SECONDS)
                .build();
        builder.cacheControl(cacheControl);
    }

    if (headers != null && !headers.isEmpty()) {
        Iterator<String> iterator = headers.keySet().iterator();
        while (iterator.hasNext()) {
            String key = iterator.next();
            String value = headers.get(key);
            builder.addHeader(key, value);
        }
    }

    // 增加一个 tag 对象, 用于和 callback 建立标识.
    builder.tag(new Object());

    return builder.build();
}
 
Example 13
Source Project: connect-utils   File: GenericAssertions.java    License: Apache License 2.0 5 votes vote down vote up
private void writeEntries(BufferedWriter writer, String header, Map<?, ?> entries) throws IOException {
  if (!entries.isEmpty()) {
    writer.append(header);
    writer.newLine();

    for (Map.Entry<?, ?> kvp : entries.entrySet()) {
      writer.append("  ");
      writer.append(kvp.getKey().toString());
      writer.append(": ");
      writer.append(kvp.getValue().toString());
      writer.newLine();
    }
    writer.newLine();
  }
}
 
Example 14
Source Project: ranger   File: TestJSONUtil.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testJsonToMapIsEmpty() {
	String jsonStr = "";
	Map<String, String> dbMap = jsonUtil.jsonToMap(jsonStr);
	boolean isEmpty = dbMap.isEmpty();
	Assert.assertTrue(isEmpty);
}
 
Example 15
@GET
@Path("/mydatanoparams")
@Produces(MediaType.APPLICATION_JSON)
@UserConstraint(functionalities = { SpagoBIConstants.SELF_SERVICE_DATASET_MANAGEMENT })
public String getMyDataDataSetWithoutParameters(@QueryParam("typeDoc") String typeDoc) {
	logger.debug("IN");
	try {
		List<IDataSet> dataSets;
		List<IDataSet> dataSetsNoParams = new ArrayList<IDataSet>(0);
		if (UserUtilities.isAdministrator(getUserProfile())) {
			dataSets = getDatasetManagementAPI().getAllDataSet();
		} else {
			dataSets = getDatasetManagementAPI().getMyDataDataSet();
		}

		if (dataSets != null) {
			for (Iterator iterator = dataSets.iterator(); iterator.hasNext();) {
				IDataSet iDataSet = (IDataSet) iterator.next();
				Map params = iDataSet.getParamsMap();
				if (params == null || params.isEmpty()) {
					dataSetsNoParams.add(iDataSet);
				}
			}
		}

		return serializeDataSets(dataSetsNoParams, typeDoc);
	} catch (Throwable t) {
		throw new SpagoBIServiceException(this.request.getPathInfo(), "An unexpected error occured while executing service", t);
	} finally {
		logger.debug("OUT");
	}
}
 
Example 16
Source Project: rpi   File: AliyunWebUtils.java    License: Apache License 2.0 5 votes vote down vote up
public static String buildQuery(Map<String, String> params, String charset) throws IOException {
    if (params == null || params.isEmpty()) {
        return null;
    }

    StringBuilder query = new StringBuilder();
    Set<Entry<String, String>> entries = params.entrySet();
    boolean hasParam = false;

    for (Entry<String, String> entry : entries) {
        String name = entry.getKey();
        String value = entry.getValue();
        // 忽略参数名或参数值为空的参数
        if (name == null || value == null || name.trim().length() == 0
            || value.trim().length() == 0) {
            continue;
        }
        if (hasParam) {
            query.append("&");
        } else {
            hasParam = true;
        }

        query.append(name).append("=").append(URLEncoder.encode(value, charset));
    }

    return query.toString();
}
 
Example 17
@ApiOperation(value = "Create new variables on a task", tags = { "Tasks", "Task Variables" },
        notes = "This endpoint can be used in 2 ways: By passing a JSON Body (RestVariable or an Array of RestVariable) or by passing a multipart/form-data Object.\n"
                + "It is possible to create simple (non-binary) variable or list of variables or new binary variable \n"
                + "Any number of variables can be passed into the request body array.\n"
                + "NB: Swagger V2 specification does not support this use case that is why this endpoint might be buggy/incomplete if used with other tools.")
@ApiImplicitParams({
        @ApiImplicitParam(name = "body", type = "org.flowable.rest.service.api.engine.variable.RestVariable", value = "Create a variable on a task", paramType = "body", example = "{\n" +
                "    \"name\":\"intProcVar\"\n" +
                "    \"type\":\"integer\"\n" +
                "    \"value\":123,\n" +
                " }"),
        @ApiImplicitParam(name = "name", value = "Required name of the variable", dataType = "string", paramType = "form", example = "Simple content item"),
        @ApiImplicitParam(name = "type", value = "Type of variable that is created. If omitted, reverts to raw JSON-value type (string, boolean, integer or double)",dataType = "string", paramType = "form", example = "integer"),
        @ApiImplicitParam(name = "scope",value = "Scope of variable that is created. If omitted, local is assumed.", dataType = "string",  paramType = "form", example = "local")
})
@ApiResponses(value = {
        @ApiResponse(code = 201, message = "Indicates the variables were created and the result is returned."),
        @ApiResponse(code = 400, message = "Indicates the name of a variable to create was missing or that an attempt is done to create a variable on a standalone task (without a process associated) with scope global or an empty array of variables was included in the request or request did not contain an array of variables. Status message provides additional information."),
        @ApiResponse(code = 404, message = "Indicates the requested task was not found."),
        @ApiResponse(code = 409, message = "Indicates the task already has a variable with the given name. Use the PUT method to update the task variable instead."),
        @ApiResponse(code = 415, message = "Indicates the serializable data contains an object for which no class is present in the JVM running the Flowable engine and therefore cannot be deserialized.")
})
@PostMapping(value = "/runtime/tasks/{taskId}/variables", produces = "application/json", consumes = {"application/json", "multipart/form-data"})
public Object createTaskVariable(@ApiParam(name = "taskId") @PathVariable String taskId, HttpServletRequest request, HttpServletResponse response) {

    Task task = getTaskFromRequest(taskId);

    Object result = null;
    if (request instanceof MultipartHttpServletRequest) {
        result = setBinaryVariable((MultipartHttpServletRequest) request, task, true);
    } else {

        List<RestVariable> inputVariables = new ArrayList<>();
        List<RestVariable> resultVariables = new ArrayList<>();
        result = resultVariables;

        try {
            @SuppressWarnings("unchecked")
            List<Object> variableObjects = (List<Object>) objectMapper.readValue(request.getInputStream(), List.class);
            for (Object restObject : variableObjects) {
                RestVariable restVariable = objectMapper.convertValue(restObject, RestVariable.class);
                inputVariables.add(restVariable);
            }
        } catch (Exception e) {
            throw new FlowableIllegalArgumentException("Failed to serialize to a RestVariable instance", e);
        }

        if (inputVariables == null || inputVariables.size() == 0) {
            throw new FlowableIllegalArgumentException("Request did not contain a list of variables to create.");
        }

        RestVariableScope sharedScope = null;
        RestVariableScope varScope = null;
        Map<String, Object> variablesToSet = new HashMap<>();

        for (RestVariable var : inputVariables) {
            // Validate if scopes match
            varScope = var.getVariableScope();
            if (var.getName() == null) {
                throw new FlowableIllegalArgumentException("Variable name is required");
            }

            if (varScope == null) {
                varScope = RestVariableScope.LOCAL;
            }
            if (sharedScope == null) {
                sharedScope = varScope;
            }
            if (varScope != sharedScope) {
                throw new FlowableIllegalArgumentException("Only allowed to update multiple variables in the same scope.");
            }

            if (hasVariableOnScope(task, var.getName(), varScope)) {
                throw new FlowableConflictException("Variable '" + var.getName() + "' is already present on task '" + task.getId() + "'.");
            }

            Object actualVariableValue = restResponseFactory.getVariableValue(var);
            variablesToSet.put(var.getName(), actualVariableValue);
            resultVariables.add(restResponseFactory.createRestVariable(var.getName(), actualVariableValue, varScope, task.getId(), RestResponseFactory.VARIABLE_TASK, false));
        }

        if (!variablesToSet.isEmpty()) {
            if (sharedScope == RestVariableScope.LOCAL) {
                taskService.setVariablesLocal(task.getId(), variablesToSet);
            } else {
                if (task.getExecutionId() != null) {
                    // Explicitly set on execution, setting non-local
                    // variables on task will override local-variables if
                    // exists
                    runtimeService.setVariables(task.getExecutionId(), variablesToSet);
                } else {
                    // Standalone task, no global variables possible
                    throw new FlowableIllegalArgumentException("Cannot set global variables on task '" + task.getId() + "', task is not part of process.");
                }
            }
        }
    }

    response.setStatus(HttpStatus.CREATED.value());
    return result;
}
 
Example 18
/**
 * The RTO requires that we do not reorder solutions. This means that it
 * must use an un-conditional approach to variable materialization for
 * constraints with SOMETIMES materialization requirements. This has two
 * practical impacts:
 * <p>
 * 1. We can not attach a filter with SOMETIMES requirements to a JOIN and
 * wrap it with a {@link TryBeforeMaterializationConstraint} since this
 * requires a {@link ConditionalRoutingOp} with an altSink and that will
 * reorder solutions.
 * <p>
 * 2. We can not use a pattern which involves an {@link InlineMaterializeOp}
 * followed by a {@link ConditionalRoutingOp} with an altSink followed by a
 * {@link PipelineJoin} against the lexicon. This also reorders the
 * solutions (primarily because of the {@link ConditionalRoutingOp} since we
 * can force the {@link PipelineJoin} to not reorder solutions).
 * <p>
 * The code below uses the {@link ChunkedMaterializationOp}. This does not
 * reorder the solutions. It can also materialize inline IVs giving us a
 * single operator that prepare the solutions for filter evaluation.
 */
@SuppressWarnings("rawtypes")
protected static PipelineOp addNonConditionalMaterializationSteps(//
        PipelineOp left,//
        final Set<IVariable<?>> doneSet,//
        final Map<IConstraint, Set<IVariable<IV>>> needsMaterialization,
        final Long cutoffLimit,//
        final Properties queryHints,//
        final AST2BOpContext ctx//
        ) {
    
    if (needsMaterialization.isEmpty()) {
     
        // No filters.
        return left;
        
    }

    // Collect variables that require materialization.
    final Set<IVariable<IV>> matvars = new LinkedHashSet<IVariable<IV>>();

    for (Map.Entry<IConstraint, Set<IVariable<IV>>> e : needsMaterialization
            .entrySet()) {

        matvars.addAll(e.getValue());

    }

    if (!matvars.isEmpty()) {

        // Materialize those variables.
        left = addChunkedMaterializationStep(left, matvars,
                true/* materializeInlineIVs */, cutoffLimit, queryHints,
                ctx);

        // Add them to the doneSet.
        doneSet.addAll(matvars);

    }

    // Attach all constraints.
    for(IConstraint c : needsMaterialization.keySet()) {
    
        /*
         * Note: While this is using a ConditionalRoutingOp, it is NOT
         * use the altSink. All solutions flow through the default sink.
         * This use does not cause the solutions to be reordered.
         * Parallel evaluation is also disabled.
         */

        left = applyQueryHints(//
            new ConditionalRoutingOp(leftOrEmpty(left),//
                new NV(BOp.Annotations.BOP_ID, ctx.nextId()),//
                new NV(PipelineOp.Annotations.MAX_PARALLEL, 1),//
                // disallow reordering of solutions by the query engine.
                new NV(PipelineJoin.Annotations.REORDER_SOLUTIONS, Boolean.FALSE),//
                new NV(ConditionalRoutingOp.Annotations.CONDITION, c)//
            ), queryHints, ctx);
    
    }
    
    return left;

}
 
Example 19
Source Project: metanome-algorithms   File: BINDER.java    License: Apache License 2.0 4 votes vote down vote up
private Map<AttributeCombination, List<AttributeCombination>> generateNPlusOneAryCandidates(Map<AttributeCombination, List<AttributeCombination>> naryDep2ref) {
		Map<AttributeCombination, List<AttributeCombination>> nPlusOneAryDep2ref = new HashMap<AttributeCombination, List<AttributeCombination>>();
		
		if ((naryDep2ref == null) || (naryDep2ref.isEmpty()))
			return nPlusOneAryDep2ref;
		
		int previousSize = naryDep2ref.keySet().iterator().next().size();
		
//if (previousSize >= 3)
//	return nPlusOneAryDep2ref;
//System.out.println("apriori-gen level: " + (previousSize + 1));
		
		List<AttributeCombination> deps = new ArrayList<>(naryDep2ref.keySet());
		for (int i = 0; i < deps.size() - 1; i++) {
			AttributeCombination depPivot = deps.get(i);
			for (int j = i + 1; j < deps.size(); j++) { // if INDs of the form AA<CD should be discovered as well, remove + 1
				AttributeCombination depExtension = deps.get(j);
				
				// Ensure same tables
				if (depPivot.getTable() != depExtension.getTable())
					continue;
				
				// Ensure same prefix
				if (!this.samePrefix(depPivot, depExtension))
					continue;
				
				int depPivotAttr = depPivot.getAttributes()[previousSize - 1];
				int depExtensionAttr = depExtension.getAttributes()[previousSize - 1];
				
				// Ensure non-empty attribute extension
				if ((previousSize == 1) && ((this.columnSizes.getLong(depPivotAttr) == 0) || (this.columnSizes.getLong(depExtensionAttr) == 0)))
					continue;
				
				for (AttributeCombination refPivot : naryDep2ref.get(depPivot)) {
					for (AttributeCombination refExtension : naryDep2ref.get(depExtension)) {
						
						// Ensure same tables
						if (refPivot.getTable() != refExtension.getTable())
							continue;
						
						// Ensure same prefix
						if (!this.samePrefix(refPivot, refExtension))
							continue;
						
						int refPivotAttr = refPivot.getAttributes()[previousSize - 1];
						int refExtensionAttr = refExtension.getAttributes()[previousSize - 1];
						
						// Ensure that the extension attribute is different from the pivot attribute; remove check if INDs of the form AB<CC should be discovered as well
						if (refPivotAttr == refExtensionAttr)
							continue;
						
						// We want the lhs and rhs to be disjunct, because INDs with non-disjunct sides usually don't have practical relevance; remove this check if INDs with overlapping sides are of interest
						if ((depPivotAttr == refExtensionAttr) || (depExtensionAttr == refPivotAttr))
							continue;
						//if (nPlusOneDep.contains(nPlusOneRef.getAttributes()[previousSize - 1]) ||
						//	nPlusOneRef.contains(nPlusOneDep.getAttributes()[previousSize - 1]))
						//	continue;
						
						// The new candidate was created with two lhs and their rhs that share the same prefix; but other subsets of the lhs and rhs must also exist if the new candidate is larger than two attributes
						// TODO: Test if the other subsets exist as well (because this test is expensive, same prefix of two INDs might be a strong enough filter for now)

						// Merge the dep attributes and ref attributes, respectively
						AttributeCombination nPlusOneDep = new AttributeCombination(depPivot.getTable(), depPivot.getAttributes(), depExtensionAttr);
						AttributeCombination nPlusOneRef = new AttributeCombination(refPivot.getTable(), refPivot.getAttributes(), refExtensionAttr);
						
						// Store the new candidate
						if (!nPlusOneAryDep2ref.containsKey(nPlusOneDep))
							nPlusOneAryDep2ref.put(nPlusOneDep, new LinkedList<AttributeCombination>());
						nPlusOneAryDep2ref.get(nPlusOneDep).add(nPlusOneRef);
						
//System.out.println(CollectionUtils.concat(nPlusOneDep.getAttributes(), ",") + "c" + CollectionUtils.concat(nPlusOneRef.getAttributes(), ","));
					}
				}
			}
		}
		return nPlusOneAryDep2ref;
	}
 
Example 20
/**
 * * 判断一个Map是否为空
 * 
 * @param map 要判断的Map
 * @return true:为空 false:非空
 */
public static boolean isEmpty(Map<?, ?> map)
{
    return isNull(map) || map.isEmpty();
}