Java Code Examples for java.util.Set

The following examples show how to use java.util.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: MyVirtualDirectory   Source File: SchemaInterceptor.java    License: Apache License 2.0 7 votes vote down vote up
/**
 * Checks to see if an attribute is required by as determined from an entry's
 * set of objectClass attribute values.
 *
 * @return true if the objectClass values require the attribute, false otherwise
 * @throws Exception if the attribute is not recognized
 */
private void assertAllAttributesAllowed( Dn dn, Entry entry, Set<String> allowed ) throws LdapException
{
    // Never check the attributes if the extensibleObject objectClass is
    // declared for this entry
    Attribute objectClass = entry.get( OBJECT_CLASS_AT );

    if ( objectClass.contains( SchemaConstants.EXTENSIBLE_OBJECT_OC ) )
    {
        return;
    }

    for ( Attribute attribute : entry )
    {
        String attrOid = attribute.getAttributeType().getOid();

        AttributeType attributeType = attribute.getAttributeType();

        if ( !attributeType.isCollective() && ( attributeType.getUsage() == UsageEnum.USER_APPLICATIONS )
            && !allowed.contains( attrOid ) )
        {
            throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION, I18n.err( I18n.ERR_277,
                attribute.getUpId(), dn.getName() ) );
        }
    }
}
 
Example 2
Source Project: portals-pluto   Source File: WebContextProducer.java    License: Apache License 2.0 6 votes vote down vote up
public CDIPortletWebContext(BeanManager beanManager, VariableValidator variableInspector, Models models,
	String lifecyclePhase, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
	ServletContext servletContext, Locale locale) {

	super(httpServletRequest, httpServletResponse, servletContext, locale);
	this.beanManager = beanManager;
	this.models = models;
	this.beanNames = new HashSet<>();

	boolean headerPhase = lifecyclePhase.equals(PortletRequest.HEADER_PHASE);
	boolean renderPhase = lifecyclePhase.equals(PortletRequest.RENDER_PHASE);
	boolean resourcePhase = lifecyclePhase.equals(PortletRequest.RESOURCE_PHASE);

	Set<Bean<?>> beans = beanManager.getBeans(Object.class, new AnnotationLiteral<Any>() {
			});

	for (Bean<?> bean : beans) {
		String beanName = bean.getName();

		if ((beanName != null) &&
				variableInspector.isValidName(beanName, headerPhase, renderPhase, resourcePhase)) {
			this.beanNames.add(beanName);
		}
	}
}
 
Example 3
@Test
// @T gmt> 10,2,5 +一段时间 gmt< 10,2,6号中一个时间的
public void test39() throws Exception {

    btc = gand(gcomp(getDate(110, 02, 5, 0, 0, 1), GreaterThan),
        gcomp(getDate(110, 02, 6, 23, 59, 59), TestUtils.LessThanOrEqual));
    Set<Object> s = e.getEnumeratedValue(btc, 7, 1, needMergeValueInCloseRange);
    TestUtils.testSetDate(new Date[] { getDate(110, 02, 5, 0, 0, 1), getDate(110, 02, 6, 0, 0, 1),
            getDate(110, 02, 6, 23, 59, 59) },
        s);

    s = e.getEnumeratedValue(btc, 7, 1, needMergeValueInCloseRange);
    TestUtils.testSetDate(new Date[] { getDate(110, 02, 5, 0, 0, 1), getDate(110, 02, 6, 0, 0, 1),
            getDate(110, 02, 6, 23, 59, 59) },
        s);
}
 
Example 4
@Test
public void testTypeAddAllNullInList()
{
	T t1 = getObject();
	T t2 = getObject();
	List<T> pct = new ArrayList<>();
	pct.add(t1);
	pct.add(null);
	pct.add(t2);
	Object source1 = new Object();
	assertThrows(NullPointerException.class,
			() -> getFacet().addAll(id, pct, source1)
	);
	/*
	 * TODO This should be zero, one or two???
	 */
	assertEquals(1, getFacet().getCount(id));
	assertFalse(getFacet().isEmpty(id));
	Set<T> setoftwo = getFacet().getSet(id);
	assertNotNull(setoftwo);
	assertEquals(1, setoftwo.size());
	assertTrue(setoftwo.contains(t1));
	assertEventCount(1, 0);
}
 
Example 5
@Test
public void testClassListsAreComplete() throws Exception {
    // Use reflection to get hold of the internal Map
    Class<?> clazz = ImportHandler.class;
    Field f = clazz.getDeclaredField("standardPackages");
    f.setAccessible(true);
    Object obj = f.get(null);

    Assert.assertTrue("Not Map", obj instanceof Map);

    @SuppressWarnings("unchecked")
    Map<String,Set<String>> standardPackageName = (Map<String, Set<String>>) obj;

    for (Map.Entry<String,Set<String>> entry : standardPackageName.entrySet()) {
        checkPackageClassList(entry.getKey(), entry.getValue());
    }
}
 
Example 6
Source Project: netbeans   Source File: WebKitBreakpointManager.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void add() {
    Set<String> events = eb.getEvents();
    bps = new HashMap<String, org.netbeans.modules.web.webkit.debugging.api.debugger.Breakpoint>(events.size());
    for (String event : events) {
        org.netbeans.modules.web.webkit.debugging.api.debugger.Breakpoint b;
        if (eb.isInstrumentationEvent(event)) {
            b = d.addInstrumentationBreakpoint(event);
        } else {
            b = d.addEventBreakpoint(event);
        }
        if (b != null) {
            bps.put(event, b);
        }
    }
    
}
 
Example 7
Source Project: spring-analysis-note   Source File: CallbacksSecurityTests.java    License: MIT License 6 votes vote down vote up
private static String getCurrentSubjectName() {
	final AccessControlContext acc = AccessController.getContext();

	return AccessController.doPrivileged(new PrivilegedAction<String>() {

		@Override
		public String run() {
			Subject subject = Subject.getSubject(acc);
			if (subject == null) {
				return null;
			}

			Set<Principal> principals = subject.getPrincipals();

			if (principals == null) {
				return null;
			}
			for (Principal p : principals) {
				return p.getName();
			}
			return null;
		}
	});
}
 
Example 8
Source Project: pentaho-kettle   Source File: SetValueFieldDialog.java    License: Apache License 2.0 6 votes vote down vote up
protected void setComboBoxes() {
  // Something was changed in the row.
  //
  final Map<String, Integer> fields = new HashMap<String, Integer>();

  // Add the currentMeta fields...
  fields.putAll( inputFields );

  Set<String> keySet = fields.keySet();
  List<String> entries = new ArrayList<String>( keySet );

  String[] fieldNames = entries.toArray( new String[entries.size()] );

  Const.sortStrings( fieldNames );
  colinf[0].setComboValues( fieldNames );
  colinf[1].setComboValues( fieldNames );
}
 
Example 9
Source Project: ndbc   Source File: Config.java    License: Apache License 2.0 6 votes vote down vote up
private Config(final String dataSourceSupplierClass, final String host, final int port, final String user,
    final Charset charset, final ScheduledExecutorService scheduler, final Optional<String> password,
    final Optional<String> database, final Optional<Integer> poolMaxSize, final Optional<Integer> poolMaxWaiters,
    final Optional<Duration> connectionTimeout, final Optional<Duration> queryTimeout,
    final Optional<Duration> poolValidationInterval, final Optional<Set<String>> encodingClasses,
    final Optional<Integer> nioThreads, final Optional<SSL> ssl, final Optional<Embedded> embeddedDatabase) {
  this.dataSourceSupplierClass = dataSourceSupplierClass;
  this.charset = charset;
  this.scheduler = scheduler;
  this.user = user;
  this.password = password;
  this.database = database;
  this.host = host;
  this.port = port;
  this.poolMaxSize = poolMaxSize;
  this.poolMaxWaiters = poolMaxWaiters;
  this.connectionTimeout = connectionTimeout;
  this.queryTimeout = queryTimeout;
  this.poolValidationInterval = poolValidationInterval;
  this.encodingClasses = encodingClasses.map(Collections::unmodifiableSet);
  this.nioThreads = nioThreads;
  this.ssl = ssl;
  this.embedded = embeddedDatabase;
}
 
Example 10
Source Project: openjdk-8   Source File: Bind.java    License: GNU General Public License v2.0 6 votes vote down vote up
SctpChannel connectChannel(SctpChannel channel)
    throws IOException {
    debug("connecting channel...");
    try {
        SctpServerChannel ssc = SctpServerChannel.open();
        ssc.bind(null);
        Set<SocketAddress> addrs = ssc.getAllLocalAddresses();
        Iterator<SocketAddress> iterator = addrs.iterator();
        SocketAddress addr = iterator.next();
        debug("using " + addr + "...");
        channel.connect(addr);
        SctpChannel peerChannel = ssc.accept();
        ssc.close();
        debug("connected");
        return peerChannel;
    } catch (IOException ioe) {
        debug("Cannot connect channel");
        unexpected(ioe);
        throw ioe;
    }
}
 
Example 11
Source Project: apiman   Source File: JpaStorage.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @see io.apiman.manager.api.core.IStorageQuery#getUserMemberships(java.lang.String, java.lang.String)
 */
@Override
public Set<RoleMembershipBean> getUserMemberships(String userId, String organizationId) throws StorageException {
    Set<RoleMembershipBean> memberships = new HashSet<>();
    beginTx();
    try {
        EntityManager entityManager = getActiveEntityManager();
        CriteriaBuilder builder = entityManager.getCriteriaBuilder();
        CriteriaQuery<RoleMembershipBean> criteriaQuery = builder.createQuery(RoleMembershipBean.class);
        Root<RoleMembershipBean> from = criteriaQuery.from(RoleMembershipBean.class);
        criteriaQuery.where(
                builder.equal(from.get("userId"), userId),
                builder.equal(from.get("organizationId"), organizationId) );
        TypedQuery<RoleMembershipBean> typedQuery = entityManager.createQuery(criteriaQuery);
        List<RoleMembershipBean> resultList = typedQuery.getResultList();
        memberships.addAll(resultList);
        return memberships;
    } catch (Throwable t) {
        logger.error(t.getMessage(), t);
        throw new StorageException(t);
    } finally {
        rollbackTx();
    }
}
 
Example 12
private Set<String> getJcloudsLocationIds(final Collection<? extends String> jcloudsApiIds) {
    Set<String> openstackNovaProviders = FluentIterable.from(Providers.all())
            .filter(new Predicate<ProviderMetadata>() {
        @Override
        public boolean apply(ProviderMetadata providerMetadata) {
            return jcloudsApiIds.contains(providerMetadata.getApiMetadata().getId());
        }
    }).transform(new Function<ProviderMetadata, String>() {
        @Nullable
        @Override
        public String apply(ProviderMetadata input) {
            return input.getId();
        }
    }).toSet();

    return new ImmutableSet.Builder<String>()
            .addAll(openstackNovaProviders)
            .addAll(jcloudsApiIds)
            .build();
}
 
Example 13
Source Project: javaide   Source File: Project.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns the transitive closure of the library projects for this project
 *
 * @return the transitive closure of the library projects for this project
 */
@NonNull
public List<Project> getAllLibraries() {
    if (mAllLibraries == null) {
        if (mDirectLibraries.isEmpty()) {
            return mDirectLibraries;
        }

        List<Project> all = new ArrayList<Project>();
        Set<Project> seen = Sets.newHashSet();
        Set<Project> path = Sets.newHashSet();
        seen.add(this);
        path.add(this);
        addLibraryProjects(all, seen, path);
        mAllLibraries = all;
    }

    return mAllLibraries;
}
 
Example 14
@Override
public Set<String> setServletSecurity(ServletSecurityElement constraint) {
    if (constraint == null) {
        throw new IllegalArgumentException(sm.getString(
                "applicationServletRegistration.setServletSecurity.iae",
                getName(), context.getName()));
    }

    if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
        throw new IllegalStateException(sm.getString(
                "applicationServletRegistration.setServletSecurity.ise",
                getName(), context.getName()));
    }

    this.constraint = constraint;
    return context.addServletSecurity(this, constraint);
}
 
Example 15
Source Project: nano-framework   Source File: PluginLoader.java    License: Apache License 2.0 6 votes vote down vote up
private void initModules() throws Throwable {
    final Set<String> moduleNames = SPILoader.spiNames(Module.class);
    if (!CollectionUtils.isEmpty(moduleNames)) {
        final Injector injector = Globals.get(Injector.class);
        final Map<Integer, List<Module>> modules = Maps.newHashMap();
        for (final String moduleName : moduleNames) {
            final Module module = injector.getInstance(Key.get(Module.class, Names.named(moduleName)));
            final Level level = module.getClass().getAnnotation(Level.class);
            if (level != null) {
                addModules(modules, level.value(), module);
            } else {
                addModules(modules, 0, module);
            }
        }

        loadModules(modules);
    }
}
 
Example 16
Source Project: atomix   Source File: AbstractAtomicMultimapService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Collection<? extends byte[]> putAll(String key, Collection<? extends byte[]> values) {
  Set<byte[]> addedValues = Sets.newHashSet();
  for (byte[] value : values) {
    if (valueSet.add(value)) {
      addedValues.add(value);
    }
  }

  if (!addedValues.isEmpty()) {
    version = getCurrentIndex();
    return addedValues;
  }
  return null;
}
 
Example 17
Source Project: onos   Source File: XconnectCodecTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testEncodeLb() throws Exception {
    Set<XconnectEndpoint> endpoints1 = Sets.newHashSet(EP1, EP3);
    XconnectDesc desc1 = new XconnectDesc(KEY, endpoints1);

    ObjectMapper mapper = new ObjectMapper();
    InputStream jsonStream1 = XconnectCodecTest.class.getResourceAsStream("/xconnect2.json");
    JsonNode expected = mapper.readTree(jsonStream1);

    JsonNode actual = codec.encode(desc1, context);

    assertEquals(expected.get(XconnectCodec.DEVICE_ID), actual.get(XconnectCodec.DEVICE_ID));
    assertEquals(expected.get(XconnectCodec.VLAN_ID).asInt(), actual.get(XconnectCodec.VLAN_ID).asInt());
    assertEquals(expected.get(XconnectCodec.ENDPOINTS), actual.get(XconnectCodec.ENDPOINTS));
}
 
Example 18
@Override
protected void runPass() {
  Map<String, GssFunction> functionMap = new DefaultGssFunctionMapProvider()
      .get();
  final boolean allowUnknownFunctions = false;
  final Set<String> allowedNonStandardFunctions = ImmutableSet.of();
  new ResolveCustomFunctionNodes(
      tree.getMutatingVisitController(), errorManager, functionMap,
      allowUnknownFunctions, allowedNonStandardFunctions).runPass();
}
 
Example 19
Source Project: ranger   Source File: RangerSolrAuthorizer.java    License: Apache License 2.0 5 votes vote down vote up
private String getConjunctiveFilterQueryStr(Set<String> roles) {
	StringBuilder filterQuery = new StringBuilder();
	filterQuery
			.append(" {!").append(qParserName)
			.append(" set_field=\"").append(authField).append("\"")
			.append(" set_value=\"").append(Joiner.on(',').join(roles.iterator())).append("\"")
			.append(" count_field=\"").append(tokenCountField).append("\"");
	if (allRolesToken != null && !allRolesToken.equals("")) {
		filterQuery.append(" wildcard_token=\"").append(allRolesToken).append("\"");
	}
	filterQuery.append(" allow_missing_val=").append(allowMissingValue).append(" }");

	return filterQuery.toString();
}
 
Example 20
Source Project: Openfire   Source File: PubSubModule.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void entityCapabilitiesChanged( @Nonnull final JID entity,
                                       @Nonnull final EntityCapabilities updatedEntityCapabilities,
                                       @Nonnull final Set<String> featuresAdded,
                                       @Nonnull final Set<String> featuresRemoved,
                                       @Nonnull final Set<String> identitiesAdded,
                                       @Nonnull final Set<String> identitiesRemoved )
{
    // Look for new +notify features. Those are the nodes that the entity is now interested in.
    final Set<String> nodeIDs = featuresAdded.stream()
        .filter(feature -> feature.endsWith("+notify"))
        .map(feature -> feature.substring(0, feature.length() - "+notify".length()))
        .collect(Collectors.toSet());

    if ( !nodeIDs.isEmpty() )
    {
        Log.debug( "Entity '{}' expressed new interest in receiving notifications for nodes '{}'", entity, String.join( ", ", nodeIDs ) );
        nodes.values().stream()
            .filter( Node::isSendItemSubscribe )
            .filter( node -> nodeIDs.contains( node.getUniqueIdentifier().getNodeId()) )
            .forEach( node -> {
                final NodeSubscription subscription = node.getSubscription(entity);
                if (subscription != null && subscription.isActive()) {
                    PublishedItem lastItem = node.getLastPublishedItem();
                    if (lastItem != null) {
                        subscription.sendLastPublishedItem(lastItem);
                    }
                }
            });
    }
}
 
Example 21
Source Project: pinpoint   Source File: HbaseSchemaMapper.java    License: Apache License 2.0 5 votes vote down vote up
private Set<String> mapIncludeFiles(List<HbaseSchema.Include> schemaIncludes) {
    if (CollectionUtils.isEmpty(schemaIncludes)) {
        return Collections.emptySet();
    }
    Set<String> includeFiles = new LinkedHashSet<>();
    for (HbaseSchema.Include schemaInclude : schemaIncludes) {
        String includeFile = schemaInclude.getFile();
        if (includeFiles.contains(includeFile)) {
            throw new InvalidHbaseSchemaException("Duplicate include file : " + includeFile);
        }
        includeFiles.add(includeFile);
    }
    return includeFiles;
}
 
Example 22
Source Project: modeldb   Source File: BlobDAORdbImpl.java    License: Apache License 2.0 5 votes vote down vote up
private Map<String, Set<BlobExpanded>> getCollectToMap(
    Map<String, Entry<BlobExpanded, String>> locationBlobsMapCommit) {
  return locationBlobsMapCommit.values().stream()
      .collect(
          Collectors.toMap(
              Entry::getValue,
              entry -> new LinkedHashSet<>(Collections.singletonList(entry.getKey())),
              (m1, m2) -> {
                LinkedHashSet<BlobExpanded> newHash = new LinkedHashSet<>(m1);
                newHash.addAll(m2);
                return newHash;
              },
              LinkedHashMap::new));
}
 
Example 23
Source Project: alibaba-rsocket-broker   Source File: AppDetailPanel.java    License: Apache License 2.0 5 votes vote down vote up
public void setConsumedServices(Set<String> consumedServices) {
    if (consumedServices != null && !consumedServices.isEmpty()) {
        this.consumedServicesHeader.setVisible(true);
        this.consumedServices.setVisible(true);
        this.consumedServices.setText(String.join("\r\n", consumedServices));
    } else {
        this.consumedServicesHeader.setVisible(false);
        this.consumedServices.setVisible(false);
        this.consumedServices.setText("");
    }
}
 
Example 24
Source Project: datawave   Source File: LuceneQueryParser.java    License: Apache License 2.0 5 votes vote down vote up
private void extractFilters(datawave.query.language.tree.QueryNode node, Set<FieldedTerm> filters) {
    if (node instanceof FunctionNode) {
        throw new IllegalArgumentException("Insufficient terms to evaluate");
    } else if (!(node instanceof SelectorNode)) {
        Set<FieldedTerm> alwaysFilterTerms = new HashSet<>();
        List<datawave.query.language.tree.QueryNode> childrenList = node.getChildren();
        extractAlwaysFilterNodes(alwaysFilterTerms, childrenList);
        filters.addAll(alwaysFilterTerms);
        node.setChildren(childrenList);
    }
    
    if (node instanceof SoftAndNode || node instanceof HardAndNode) {
        List<datawave.query.language.tree.QueryNode> evaluateNodes = new ArrayList<>();
        evaluateNodes.addAll(node.getChildren());
        Set<FieldedTerm> possibleFilters = extractFilters(evaluateNodes);
        
        if (!evaluateNodes.isEmpty()) {
            filters.addAll(possibleFilters);
            
            for (datawave.query.language.tree.QueryNode n : evaluateNodes) {
                extractFilters(n, filters);
            }
            node.setChildren(evaluateNodes);
        }
        
    } else if (node instanceof NotNode) {
        List<datawave.query.language.tree.QueryNode> children = node.getChildren();
        
        // If the first child of a NOT node might have filterable fields in it
        datawave.query.language.tree.QueryNode positiveNode = children.get(0);
        extractFilters(positiveNode, filters);
    }
}
 
Example 25
/**
 * Iterates through policy vocabulary and extracts set of namespaces used in
 * the policy expression.
 *
 * @return collection of used namespaces within given policy instance
 * @throws PolicyException Thrown if internal processing failed.
 */
private Collection<String> getUsedNamespaces() throws PolicyException {
    final Set<String> namespaces = new HashSet<String>();
    namespaces.add(getNamespaceVersion().toString());

    if (this.policyId != null) {
        namespaces.add(PolicyConstants.WSU_NAMESPACE_URI);
    }

    final Queue<ModelNode> nodesToBeProcessed = new LinkedList<ModelNode>();
    nodesToBeProcessed.add(rootNode);

    ModelNode processedNode;
    while ((processedNode = nodesToBeProcessed.poll()) != null) {
        for (ModelNode child : processedNode.getChildren()) {
            if (child.hasChildren()) {
                if (!nodesToBeProcessed.offer(child)) {
                    throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0081_UNABLE_TO_INSERT_CHILD(nodesToBeProcessed, child)));
                }
            }

            if (child.isDomainSpecific()) {
                final AssertionData nodeData = child.getNodeData();
                namespaces.add(nodeData.getName().getNamespaceURI());
                if (nodeData.isPrivateAttributeSet()) {
                    namespaces.add(PolicyConstants.SUN_POLICY_NAMESPACE_URI);
                }

                for (Entry<QName, String> attribute : nodeData.getAttributesSet()) {
                    namespaces.add(attribute.getKey().getNamespaceURI());
                }
            }
        }
    }

    return namespaces;
}
 
Example 26
Source Project: n4js   Source File: Tracer.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void unsetOriginalASTNode_internal(EObject elementInIntermediateModel) {
	final EObject oldOriginalASTNode = im2ast.get(elementInIntermediateModel);
	if (oldOriginalASTNode != null) {
		final Set<EObject> lOld = ast2im.get(oldOriginalASTNode);
		if (lOld != null)
			lOld.remove(elementInIntermediateModel);
	}
}
 
Example 27
Source Project: datawave   Source File: DiscoveryLogic.java    License: Apache License 2.0 5 votes vote down vote up
public static BatchScanner configureBatchScannerForDiscovery(DiscoveryQueryConfiguration config, ScannerFactory scannerFactory, String tableName,
                Collection<Range> seekRanges, Set<Text> columnFamilies, Multimap<String,String> literals, Multimap<String,String> patterns,
                Multimap<String,LiteralRange<String>> ranges, boolean reverseIndex) throws TableNotFoundException {
    
    // if we have no ranges, then nothing to scan
    if (seekRanges.isEmpty()) {
        return null;
    }
    
    BatchScanner bs = scannerFactory.newScanner(tableName, config.getAuthorizations(), config.getNumQueryThreads(), config.getQuery());
    bs.setRanges(seekRanges);
    if (!columnFamilies.isEmpty()) {
        for (Text family : columnFamilies) {
            bs.fetchColumnFamily(family);
        }
    }
    
    // The begin date from the query may be down to the second, for doing lookups in the index we want to use the day because
    // the times in the index table have been truncated to the day.
    Date begin = DateUtils.truncate(config.getBeginDate(), Calendar.DAY_OF_MONTH);
    // we don't need to bump up the end date any more because it's not apart of the range set on the scanner
    Date end = config.getEndDate();
    
    LongRange dateRange = new LongRange(begin.getTime(), end.getTime());
    
    ShardIndexQueryTableStaticMethods.configureGlobalIndexDateRangeFilter(config, bs, dateRange);
    ShardIndexQueryTableStaticMethods.configureGlobalIndexDataTypeFilter(config, bs, config.getDatatypeFilter());
    
    configureIndexMatchingIterator(config, bs, literals, patterns, ranges, reverseIndex);
    
    IteratorSetting discoveryIteratorSetting = new IteratorSetting(config.getBaseIteratorPriority() + 50, DiscoveryIterator.class);
    discoveryIteratorSetting.addOption(REVERSE_INDEX, Boolean.toString(reverseIndex));
    discoveryIteratorSetting.addOption(SEPARATE_COUNTS_BY_COLVIS, config.getSeparateCountsByColVis().toString());
    if (config.getShowReferenceCount()) {
        discoveryIteratorSetting.addOption(SHOW_REFERENCE_COUNT, config.getShowReferenceCount().toString());
    }
    bs.addScanIterator(discoveryIteratorSetting);
    
    return bs;
}
 
Example 28
/**
 * Gets all primary keys within the specified table in the form of an iterator. Only one key is loaded at any point
 * in this. No select governor limits apply on this function.
 *
 * @param app The application id of the application
 * @param table The table name of the table who's records are to be selected
 * @return An <code>Iterator<String></code> which iterates over primary keys of all records in the table.
 */
public Iterator<String> selectAllKeysAsStream(final String app, final String table) throws IOException {

    String tableName = app + "." + table;
    try {
        if (MemoryTableStore.exists(tableName)) {
            Set<String> allKeys = MemoryTableStore.getTable(tableName).getAllKeysAsString();
            return allKeys.iterator();
        }
    } catch (Exception e) {
        throw new IOException("selectAllKeysAsStream Error");
    }
    return null;
}
 
Example 29
Source Project: ontopia   Source File: CollectionUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * INTERNAL: Compares two collections to see if they contain the same
 * elements.
 *
 * @since 1.4.1
 */
public static <T> boolean equalsUnorderedSet(Collection<T> coll1, Collection<T> coll2) {
  
  // Take care of nulls
  if (coll1 == null)
    if (coll2 == null)
      // 1: null 2: null
      return true;
    else
      // 1: null 2: not null
      return false;
  else
    if (coll2 == null)
      // 1: not null 2: null
      return false;
  
  // Compare set size
  int size1 = coll1.size();
  int size2 = coll2.size();    
  if (size1 != size2)
    return false;
  
  // If both have 1 element compare first element
  if (size1 == 1) {      
    return Objects.equals(coll1.iterator().next(), coll2.iterator().next());
  }
  
  // Compare collections as sets
  if (coll1 instanceof Set)
    if (coll2 instanceof Set)
      return coll1.equals(coll2);
    else
      return coll1.equals(new HashSet<T>(coll2));
  else if (coll2 instanceof Set)
    return coll2.equals(new HashSet<T>(coll1));
  else
    return new HashSet<T>(coll2).equals(new HashSet<T>(coll1));
}
 
Example 30
@Override
public Set<LabelledPermission> getPermissionsForObject(
    ObjectIdentity objectIdentity, Set<Sid> sids, boolean isReturnInheritedPermissions) {
  checkTypeExists(objectIdentity.getType());
  entityHelper.checkEntityExists(objectIdentity);
  Acl acl = mutableAclService.readAclById(objectIdentity);
  return getPermissionResponses(acl, isReturnInheritedPermissions, sids);
}