Java Code Examples for java.util.Collections#EMPTY_SET

The following examples show how to use java.util.Collections#EMPTY_SET . 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 check out the related API usage on the sidebar.
Example 1
Source Project: beam   File: BeamTableFunctionScanRule.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public RelNode convert(RelNode relNode) {
  TableFunctionScan tableFunctionScan = (TableFunctionScan) relNode;
  // only support one input for table function scan.
  List<RelNode> inputs = new ArrayList<>();
  checkArgument(
      relNode.getInputs().size() == 1,
      "Wrong number of inputs for %s, expected 1 input but received: %s",
      BeamTableFunctionScanRel.class.getSimpleName(),
      relNode.getInputs().size());
  inputs.add(
      convert(
          relNode.getInput(0),
          relNode.getInput(0).getTraitSet().replace(BeamLogicalConvention.INSTANCE)));
  return new BeamTableFunctionScanRel(
      tableFunctionScan.getCluster(),
      tableFunctionScan.getTraitSet().replace(BeamLogicalConvention.INSTANCE),
      inputs,
      tableFunctionScan.getCall(),
      null,
      tableFunctionScan.getCall().getType(),
      Collections.EMPTY_SET);
}
 
Example 2
@Override
public int doStaticUpdates(TopicMapIF topicmap, Map arguments)
  throws InvalidQueryException {
  if (funcname == null)
    return doLitListDeletes(true, arguments);
  else {
    // in order to avoid duplicating code we produce a "fake" matches
    // object here, so that in effect we're simulating a one-row zero-column
    // result set
    QueryContext context = new QueryContext(null, null, arguments, null);
    Collection columns = arguments == null ? Collections.EMPTY_SET :
                                             arguments.values();
    QueryMatches matches =
      QueryMatchesUtils.createInitialMatches(context, columns);
    return doFunctionUpdates(matches);
  }
}
 
Example 3
@Test
public void doGetTableLayout()
        throws Exception
{
    GetTableLayoutRequest req = new GetTableLayoutRequest(IDENTITY,
            QUERY_ID,
            DEFAULT_CATALOG,
            TABLE_NAME,
            new Constraints(new HashMap<>()),
            SchemaBuilder.newBuilder().build(),
            Collections.EMPTY_SET);

    GetTableLayoutResponse res = handler.doGetTableLayout(allocator, req);

    logger.info("doGetTableLayout - {}", res);
    Block partitions = res.getPartitions();
    for (int row = 0; row < partitions.getRowCount() && row < 10; row++) {
        logger.info("doGetTableLayout:{} {}", row, BlockUtils.rowToString(partitions, row));
    }

    assertTrue(partitions.getRowCount() > 0);
}
 
Example 4
public NativeSQLQuerySpecification(
		String queryString,
        NativeSQLQueryReturn[] queryReturns,
        Collection querySpaces) {
	this.queryString = queryString;
	this.queryReturns = queryReturns;
	if ( querySpaces == null ) {
		this.querySpaces = Collections.EMPTY_SET;
	}
	else {
		Set tmp = new HashSet();
		tmp.addAll( querySpaces );
		this.querySpaces = Collections.unmodifiableSet( tmp );
	}

	// pre-determine and cache the hashcode
	int hashCode = queryString.hashCode();
	hashCode = 29 * hashCode + this.querySpaces.hashCode();
	if ( this.queryReturns != null ) {
		hashCode = 29 * hashCode + ArrayHelper.toList( this.queryReturns ).hashCode();
	}
	this.hashCode = hashCode;
}
 
Example 5
Source Project: components   File: JDBCOutputProperties.java    License: Apache License 2.0 5 votes vote down vote up
@Override
protected Set<PropertyPathConnector> getAllSchemaPropertiesConnectors(boolean isOutputConnection) {
    HashSet<PropertyPathConnector> connectors = new HashSet<>();
    if (isOutputConnection) {
        return Collections.EMPTY_SET;
    } else {
        connectors.add(MAIN_CONNECTOR);
    }
    return connectors;
}
 
Example 6
private Subject createSubject(final AMQPSession<?, ?> session)
{
    SessionPrincipal sessionPrincipal = new SessionPrincipal(session);
    return new Subject(true,
                       Collections.singleton(sessionPrincipal),
                       Collections.EMPTY_SET,
                       Collections.EMPTY_SET);
}
 
Example 7
private static Set<String> extractShardingColumns(final ShardingStrategyConfiguration shardingStrategy) {
    if (shardingStrategy instanceof StandardShardingStrategyConfiguration) {
        return Sets.newHashSet(((StandardShardingStrategyConfiguration) shardingStrategy).getShardingColumn());
    }
    if (shardingStrategy instanceof ComplexShardingStrategyConfiguration) {
        return Sets.newHashSet(((ComplexShardingStrategyConfiguration) shardingStrategy).getShardingColumns().split(","));
    }
    return Collections.EMPTY_SET;
}
 
Example 8
Source Project: webcurator   File: TargetDAOImpl.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public Set<Long> getAncestorOids(final Long childOid) {
   	if(childOid == null) { 
   		return Collections.EMPTY_SET;
   	}
   	else {
    	Set<Long> parentOids = new HashSet<Long>();
    	
    	List<Long> immediateParents = getHibernateTemplate().executeFind(new HibernateCallback() {

			public Object doInHibernate(Session aSession) throws HibernateException, SQLException {
				//Criteria q = aSession.createCriteria("new java.lang.Long(oid) FROM TargetGroup").createCriteria("children").add(Restrictions.eq("oid", childOid));
				Query q = aSession.createQuery("SELECT new java.lang.Long(gm.parent.oid) FROM GroupMember gm where gm.child.oid = :childOid");
				q.setLong("childOid", childOid);
				return q.list();
			}
    		
    	});
    	
    	for(Long parentOid: immediateParents) {
    		parentOids.add(parentOid);
    		parentOids.addAll(getAncestorOids(parentOid));
    	}
    	
    	return parentOids;
   	}
   }
 
Example 9
Source Project: tomee   File: InterceptorData.java    License: Apache License 2.0 5 votes vote down vote up
public Set<Method> getMethods(final Operation operation) {
    switch (operation) {
        case BUSINESS:
            return getAroundInvoke();
        case BUSINESS_WS:
            return getAroundInvoke();
        case REMOVE:
            return getAroundInvoke();
        case POST_CONSTRUCT:
            return getPostConstruct();
        case PRE_DESTROY:
            return getPreDestroy();
        case ACTIVATE:
            return getPostActivate();
        case PASSIVATE:
            return getPrePassivate();
        case AFTER_BEGIN:
            return getAfterBegin();
        case AFTER_COMPLETION:
            return getAfterCompletion();
        case BEFORE_COMPLETION:
            return getBeforeCompletion();
        case TIMEOUT:
            return getAroundTimeout();
    }
    return Collections.EMPTY_SET;
}
 
Example 10
Source Project: litchi   File: RedisSortedSet.java    License: Apache License 2.0 5 votes vote down vote up
public Set<Tuple> revrangeWithScores(String key, long start, long stop) {
  	try {
  		return jedis.zrevrangeWithScores(key, start, stop);
} catch (Exception e) {
	LOGGER.error("", e);
} finally {
	if (autoClose) {
		close();
	}
}
  	return Collections.EMPTY_SET;
  }
 
Example 11
public static void main(String[] args) throws Exception {
    System.out.println("---RMIConnectorInternalMapTest starting...");

    JMXConnectorServer connectorServer = null;
    JMXConnector connectorClient = null;

    try {
        MBeanServer mserver = ManagementFactory.getPlatformMBeanServer();
        JMXServiceURL serverURL = new JMXServiceURL("rmi", "localhost", 0);
        connectorServer = JMXConnectorServerFactory.newJMXConnectorServer(serverURL, null, mserver);
        connectorServer.start();

        JMXServiceURL serverAddr = connectorServer.getAddress();
        connectorClient = JMXConnectorFactory.connect(serverAddr, null);
        connectorClient.connect();

        Field rmbscMapField = RMIConnector.class.getDeclaredField("rmbscMap");
        rmbscMapField.setAccessible(true);
        Map<Subject, WeakReference<MBeanServerConnection>> map =
                (Map<Subject, WeakReference<MBeanServerConnection>>) rmbscMapField.get(connectorClient);
        if (map != null && !map.isEmpty()) { // failed
            throw new RuntimeException("RMIConnector's rmbscMap must be empty at the initial time.");
        }

        Subject delegationSubject =
                new Subject(true,
                Collections.singleton(new JMXPrincipal("delegate")),
                Collections.EMPTY_SET,
                Collections.EMPTY_SET);
        MBeanServerConnection mbsc1 =
                connectorClient.getMBeanServerConnection(delegationSubject);
        MBeanServerConnection mbsc2 =
                connectorClient.getMBeanServerConnection(delegationSubject);

        if (mbsc1 == null) {
            throw new RuntimeException("Got null connection.");
        }
        if (mbsc1 != mbsc2) {
            throw new RuntimeException("Not got same connection with a same subject.");
        }

        map = (Map<Subject, WeakReference<MBeanServerConnection>>) rmbscMapField.get(connectorClient);
        if (map == null || map.isEmpty()) { // failed
            throw new RuntimeException("RMIConnector's rmbscMap has wrong size "
                    + "after creating a delegated connection.");
        }

        delegationSubject = null;
        mbsc1 = null;
        mbsc2 = null;

        int i = 0;
        while (!map.isEmpty() && i++ < 60) {
            System.gc();
            Thread.sleep(100);
        }
        System.out.println("---GC times: " + i);

        if (!map.isEmpty()) {
            throw new RuntimeException("Failed to clean RMIConnector's rmbscMap");
        } else {
            System.out.println("---RMIConnectorInternalMapTest: PASSED!");
        }
    } finally {
        try {
            connectorClient.close();
            connectorServer.stop();
        } catch (Exception e) {
        }
    }
}
 
Example 12
Source Project: sis   File: StateChanger.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Returns the given object, or a copy of the given object, with its state changed.
 * This method performs the following heuristic tests:
 *
 * <ul>
 *   <li>If the specified object is an instance of {@code ModifiableMetadata}, then
 *       {@link ModifiableMetadata#transitionTo(ModifiableMetadata.State)} is invoked on that object.</li>
 *   <li>Otherwise, if the object is a {@linkplain Collection collection}, then the
 *       content is copied into a new collection of similar type, with values replaced
 *       by their unmodifiable variant.</li>
 *   <li>Otherwise, if the object implements the {@link Cloneable} interface,
 *       then a clone is returned.</li>
 *   <li>Otherwise, the object is assumed immutable and returned unchanged.</li>
 * </ul>
 *
 * @param  object  the object to transition to a different state.
 * @return the given object or a copy of the given object with its state changed.
 */
private Object applyTo(final Object object) throws CloneNotSupportedException {
    /*
     * CASE 1 - The object is an org.apache.sis.metadata.* implementation.
     *          It may have its own algorithm for changing its state.
     */
    if (object instanceof ModifiableMetadata) {
        ((ModifiableMetadata) object).transitionTo(target);
        return object;
    }
    if (object instanceof DefaultRepresentativeFraction) {
        ((DefaultRepresentativeFraction) object).freeze();
        return object;
    }
    /*
     * CASE 2 - The object is a collection. All elements are replaced by their
     *          unmodifiable variant and stored in a new collection of similar
     *          type.
     */
    if (object instanceof Collection<?>) {
        Collection<?> collection = (Collection<?>) object;
        final boolean isSet = (collection instanceof Set<?>);
        final Object[] array = collection.toArray();
        switch (array.length) {
            case 0: {
                collection = isSet ? Collections.EMPTY_SET
                                   : Collections.EMPTY_LIST;
                break;
            }
            case 1: {
                final Object value = applyTo(array[0]);
                collection = isSet ? Collections.singleton(value)
                                   : Collections.singletonList(value);
                break;
            }
            default: {
                if (isSet) {
                    if (collection instanceof EnumSet<?>) {
                        collection = Collections.unmodifiableSet(((EnumSet<?>) collection).clone());
                    } else if (collection instanceof CodeListSet<?>) {
                        collection = Collections.unmodifiableSet(((CodeListSet<?>) collection).clone());
                    } else {
                        applyToAll(array);
                        collection = CollectionsExt.immutableSet(false, array);
                    }
                } else {
                    /*
                     * Do not use the SIS Checked* classes since we don't need type checking anymore.
                     * Conservatively assumes a List if we are not sure to have a Set since the list
                     * is less destructive (no removal of duplicated values).
                     */
                    applyToAll(array);
                    collection = UnmodifiableArrayList.wrap(array);
                }
                break;
            }
        }
        return collection;
    }
    /*
     * CASE 3 - The object is a map. Copies all entries in a new map and replaces all values
     *          by their unmodifiable variant. The keys are assumed already immutable.
     */
    if (object instanceof Map<?,?>) {
        final Map<Object,Object> map = new LinkedHashMap<>((Map<?,?>) object);
        for (final Map.Entry<Object,Object> entry : map.entrySet()) {
            entry.setValue(applyTo(entry.getValue()));
        }
        return CollectionsExt.unmodifiableOrCopy(map);
    }
    /*
     * CASE 4 - The object is presumed cloneable.
     */
    if (object instanceof Cloneable) {
        if (cloner == null) {
            cloner = new Cloner(false);
        }
        return cloner.clone(object);
    }
    /*
     * CASE 5 - Any other case. The object is assumed immutable and returned unchanged.
     */
    return object;
}
 
Example 13
Source Project: gemfirexd-oss   File: BucketRegion.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * perform adjunct messaging for the given operation and return a set of
 * members that should be attached to the operation's reply processor (if any)
 * @param event the event causing this messaging
 * @param cacheOpRecipients set of receiver which got cacheUpdateOperation.
 * @param adjunctRecipients recipients that must unconditionally get the event
 * @param filterRoutingInfo routing information for all members having the region
 * @param processor the reply processor, or null if there isn't one
 * @return the set of failed recipients
 */
protected Set performAdjunctMessaging(EntryEventImpl event,
    Set cacheOpRecipients, Set adjunctRecipients,
    FilterRoutingInfo filterRoutingInfo,
    DirectReplyProcessor processor,
    boolean calculateDelta,
    boolean sendDeltaWithFullValue) {
  
  Set failures = Collections.EMPTY_SET;
  PartitionMessage msg = event.getPartitionMessage();
  if (calculateDelta) {
    setDeltaIfNeeded(event);
  }
  if (msg != null) {
    // The primary bucket member which is being modified remotely by a GemFire
    // thread via a received PartitionedMessage
    //Asif: Some of the adjunct recepients include those members which 
    // are GemFireXDHub & would need old value along with news
    msg = msg.getMessageForRelayToListeners(event, adjunctRecipients);
    msg.setSender(this.partitionedRegion.getDistributionManager()
        .getDistributionManagerId());
    msg.setSendDeltaWithFullValue(sendDeltaWithFullValue);
    
    failures = msg.relayToListeners(cacheOpRecipients, adjunctRecipients,
        filterRoutingInfo, event, this.partitionedRegion, processor);
  }
  else {
    // The primary bucket is being modified locally by an application thread locally 
    Operation op = event.getOperation();
    if (op.isCreate() || op.isUpdate()) {
      // note that at this point ifNew/ifOld have been used to update the
      // local store, and the event operation should be correct
      failures = PutMessage.notifyListeners(cacheOpRecipients,
          adjunctRecipients, filterRoutingInfo, this.partitionedRegion, 
          event, op.isCreate(), !op.isCreate(), processor,
          sendDeltaWithFullValue);
    }
    else if (op.isDestroy()) {
      failures = DestroyMessage.notifyListeners(cacheOpRecipients,
          adjunctRecipients, filterRoutingInfo,
          this.partitionedRegion, event, processor);
    }
    else if (op.isInvalidate()) {
      failures = InvalidateMessage.notifyListeners(cacheOpRecipients,
          adjunctRecipients, filterRoutingInfo, 
          this.partitionedRegion, event, processor);
    }
    else {
      failures = adjunctRecipients;
    }
  }
  return failures;
}
 
Example 14
Source Project: netbeans   File: IncludeResolver.java    License: Apache License 2.0 4 votes vote down vote up
/**
     * It looks for a set of schema models, which can be visible to each others.
     * The matter is, if model A includes B, then model B model's definitions
     * is visible to A. But the oposite assertion is also correct because B
     * logically becomes a part of A after inclusion.
     *
     * The method doesn't analyze models included to current. It looks only
     * models to which current model is included! It is implied that the included
     * models's hierarchy has checked before.
     *
     * Be carefull with the following use-case:
     * If model A includes B and C includes B then it doesn't mean that declarations
     * from model C visible in A.
     *
     * The problem is described in the issue http://www.netbeans.org/issues/show_bug.cgi?id=122836
     *
     * The task of the method is to find a set of schema models, which
     * can be visible to the current model. The parameter is used as a hint
     * to exclude the models from other namespace.
     *
     * @param soughtNs
     * @return
     */
    static Set<SchemaModelImpl> getMegaIncludedModels(
            SchemaModelImpl sModel, String soughtNs, ResolveSession session) {
        //
//        if (true) {
//            // For optimization tests only
              // Uncomment and run tests to check how often the mega-include is called. 
//            throw new RuntimeException("MEGA INCLUDE");
//        }
        //
        Schema mySchema = sModel.getSchema();
        if (mySchema == null) {
            return Collections.EMPTY_SET;
        }
        //
        // If the current model has empty target namespace, then it can be included anywhere
        // If the current model has not empty target namespace, then it can be included only
        // to models with the same target namespace.
        String myTargetNs = mySchema.getTargetNamespace();
        if (myTargetNs != null && !Util.equal(soughtNs, myTargetNs)) {
            return Collections.EMPTY_SET;
        }
        //
        // The graph is lazy initialized in session and can be reused during
        // the resolve session.
        BidirectionalGraph<SchemaModelImpl> graph = 
                session.getInclusionGraph(sModel, soughtNs);
        //
        // Now there is forward and back inclusion graphs.
        if (graph.isEmpty()) {
            return Collections.EMPTY_SET;
        }
        //
        // Look for the roots of inclusion.
        // Root s the top schema model, which includes current schema recursively,
        // but isn't included anywhere itself.
        Set<SchemaModelImpl> inclusionRoots = graph.getRoots(sModel, false);
        //
        HashSet<SchemaModelImpl> result = new HashSet<SchemaModelImpl>();
        for (SchemaModelImpl root : inclusionRoots) {
            // The namespace of the inclusion root has to be exectly the same
            // as required.
            if (Util.equal(root.getSchema().getTargetNamespace(), soughtNs)) {
                MultivalueMap.Utils.populateAllSubItems(graph, root, sModel, result);
            }
        }
        //
        result.remove(sModel);
        //
        return result;
    }
 
Example 15
/**
 * Returns Collections.EMPTY_SET
 *
 * @return Collections.EMPTY_SET
 */
@Override
@SuppressWarnings("unchecked" )
public Set<T> visit(IntConstant intConst) {
    return Collections.EMPTY_SET;
}
 
Example 16
Source Project: tajo   File: JdbcMetadataProviderBase.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Collection<String> getSchemas() {
  return Collections.EMPTY_SET;
}
 
Example 17
public Set<String> getUnicodeLocaleAttributes() {
    if (attributes == Collections.EMPTY_SET) {
        return attributes;
    }
    return Collections.unmodifiableSet(attributes);
}
 
Example 18
Source Project: gemfirexd-oss   File: PutMessage.java    License: Apache License 2.0 3 votes vote down vote up
/**
 * send a notification-only message to a set of listeners.  The processor
 * id is passed with the message for reply message processing.  This method
 * does not wait on the processor.
 *
 * @param cacheOpReceivers receivers of associated bucket CacheOperationMessage
 * @param adjunctRecipients receivers that must get the event
 * @param filterInfo all client routing information
 * @param r the region affected by the event
 * @param event the event that prompted this action
 * @param ifNew
 * @param ifOld
 * @param processor the processor to reply to
 * @return members that could not be notified
 */
public static Set<?> notifyListeners(Set<?> cacheOpReceivers,
    Set<?> adjunctRecipients, FilterRoutingInfo filterInfo,
    PartitionedRegion r, EntryEventImpl event, boolean ifNew, boolean ifOld,
    DirectReplyProcessor processor, boolean sendDeltaWithFullValue) {
  final PutMessage msg = new PutMessage(Collections.EMPTY_SET, true,
      r.getPRId(), processor, event, event.getTXState(r), 0, ifNew, ifOld,
      null, false, true);
  msg.setInternalDs(r.getSystem());
  msg.versionTag = event.getVersionTag();
  msg.setSendDeltaWithFullValue(sendDeltaWithFullValue);
  return msg.relayToListeners(cacheOpReceivers, adjunctRecipients,
      filterInfo, event, r, processor);
}
 
Example 19
Source Project: nifi   File: NiFiUserDetails.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Returns the authorities that this NiFi user has.
 *
 * @return authorities
 */
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
    return Collections.EMPTY_SET;
}
 
Example 20
/**
 * Creates an instance of {@code CollectionCertStoreParameters} with
 * the default parameter values (an empty and immutable
 * {@code Collection}).
 */
public CollectionCertStoreParameters() {
    coll = Collections.EMPTY_SET;
}