org.eclipse.collections.impl.set.mutable.UnifiedSet Java Examples

The following examples show how to use org.eclipse.collections.impl.set.mutable.UnifiedSet. 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: OverlapFixer.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private static OrderBy getOrderOfPrecedence(RelatedFinder finder)
{
    AsOfAttribute[] asOfAttributes = finder.getAsOfAttributes();
    OrderBy orderBy = null;
    Set<String> asOfFromToAttributes = UnifiedSet.newSet(asOfAttributes.length * 2);
    for (int i = asOfAttributes.length - 1; i >= 0; i--)
    {
        OrderBy descendingFrom = asOfAttributes[i].getFromAttribute().descendingOrderBy();
        orderBy = orderBy == null ? descendingFrom : orderBy.and(descendingFrom);
        orderBy = orderBy.and(asOfAttributes[i].getToAttribute().ascendingOrderBy());

        asOfFromToAttributes.add(asOfAttributes[i].getFromAttribute().getAttributeName());
        asOfFromToAttributes.add(asOfAttributes[i].getToAttribute().getAttributeName());
    }

    for (Attribute attr : finder.getPersistentAttributes())
    {
        if (!asOfFromToAttributes.contains(attr.getAttributeName()))
        {
            OrderBy asc = attr.ascendingOrderBy();
            orderBy = orderBy == null ? asc : orderBy.and(asc);
        }
    }

    return orderBy;
}
 
Example #2
Source File: ALSServingModel.java    From oryx with Apache License 2.0 6 votes vote down vote up
void addKnownItems(String user, Collection<String> items) {
  if (!items.isEmpty()) {
    MutableSet<String> knownItemsForUser = doGetKnownItems(user);

    if (knownItemsForUser == null) {
      try (AutoLock al = knownItemsLock.autoWriteLock()) {
        // Check again
        knownItemsForUser = knownItems.computeIfAbsent(user, k -> UnifiedSet.newSet());
      }
    }

    synchronized (knownItemsForUser) {
      knownItemsForUser.addAll(items);
    }
  }
}
 
Example #3
Source File: TextMarkupDocumentReaderTest.java    From obevo with Apache License 2.0 6 votes vote down vote up
private void verifyRegular(TextMarkupDocument doc) {
    ImmutableList<TextMarkupDocumentSection> sections = doc.getSections();
    assertEquals(6, sections.size());
    this.assertSection(sections.get(0), TextMarkupDocumentReader.TAG_METADATA, null,
            UnifiedMap.<String, String>newWithKeysValues("k1", "v1", "k2", "v2"));
    this.assertSection(sections.get(1), TextMarkupDocumentReader.TAG_METADATA, null,
            UnifiedMap.<String, String>newWithKeysValues("k3", "v3"));
    // assertSection(sections.get(2), null, "blahblahblah\n", UnifiedMap.<String, String>newMap());
    this.assertSection(sections.get(2), TextMarkupDocumentReader.TAG_CHANGE, "line1\nline2/*comment to keep */\r\nline3",
            UnifiedMap.<String, String>newWithKeysValues("n", "1", "a", "2", "v", "3"));
    this.assertSection(sections.get(3), TextMarkupDocumentReader.TAG_CHANGE, null, UnifiedMap.<String, String>newWithKeysValues("n", "2"),
            UnifiedSet.newSetWith("TOGGLEACTIVE"));
    this.assertSection(sections.get(4), TextMarkupDocumentReader.TAG_CHANGE, "finalcontent",
            UnifiedMap.<String, String>newWithKeysValues("n", "3"));
    this.assertSection(sections.get(4).getSubsections().get(0),
            TextMarkupDocumentReader.TAG_ROLLBACK_IF_ALREADY_DEPLOYED, "rollback content",
            UnifiedMap.<String, String>newWithKeysValues("n", "3"));
    this.assertSection(sections.get(5), TextMarkupDocumentReader.TAG_CHANGE, null, UnifiedMap.<String, String>newWithKeysValues("n", "4"));
}
 
Example #4
Source File: TestCount.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void testAndOperationWithDifferentMappersAndCalculatedAggregateAttributeWithLinkedMapper()
{
    Set<String> zipcodeSet = new UnifiedSet(2);
    zipcodeSet.add("10001");
    zipcodeSet.add("10038");
    Operation op = SaleFinder.items().productSpecs().originalPrice().greaterThan(20.00);
    op = op.and(SaleFinder.seller().zipCode().notIn(zipcodeSet));

    com.gs.fw.common.mithra.MithraAggregateAttribute aggrAttr = SaleFinder.items().quantity().times(SaleFinder.items().productSpecs().originalPrice()).count();

    AggregateList aggregateList = new AggregateList(op);
    aggregateList.addAggregateAttribute("CountPrice", aggrAttr);
    aggregateList.addGroupBy("SellerId", SaleFinder.sellerId());
    assertEquals(1, aggregateList.size());

    AggregateData data = aggregateList.getAggregateDataAt(0);
    assertEquals(4, data.getAttributeAsInt("SellerId"));
    assertEquals(4, data.getAttributeAsDouble("CountPrice"), 0);
}
 
Example #5
Source File: TestTupleTempTableCreationFailure.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private void runListQueryAcrossTwoSources()
{
    IntHashSet intHashSet = new IntHashSet();
    for (int i=1;i>-1007;i--)
    {
        intHashSet.add(i);
    }
    Operation op = AccountTransactionFinder.transactionId().notIn(intHashSet).and(AccountTransactionFinder.deskId().in(UnifiedSet.newSetWith("A", "B")));
    AccountTransactionList list = new AccountTransactionList(op);

    // Assert not only that the SQL execution does not fail but also that the in-clause is resolved correctly (upon retry) to retrieve the correct results
    assertEquals(4, list.size());
    Collection<String> tranIds = Iterate.collect(list, new Function<AccountTransaction, String>()
    {
        @Override
        public String valueOf(AccountTransaction tran)
        {
            return tran.getDeskId() + ":" + tran.getTransactionId();
        }
    });
    assertEquals(4, tranIds.size());
    assertTrue(tranIds.contains("A:100"));
    assertTrue(tranIds.contains("A:1000"));
    assertTrue(tranIds.contains("B:10000"));
    assertTrue(tranIds.contains("B:100000"));
}
 
Example #6
Source File: TestMax.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void testAndOperationWithDifferentMappersMappedToManyAttribute()
{
    Set<String> zipcodeSet = new UnifiedSet(2);
    zipcodeSet.add("10001");
    zipcodeSet.add("10038");
    Operation op = SaleFinder.items().productSpecs().originalPrice().greaterThan(20);
    op = op.and(SaleFinder.seller().zipCode().notIn(zipcodeSet));

    MithraAggregateAttribute aggrAttr = SaleFinder.items().quantity().max();

    AggregateList aggregateList = new AggregateList(op);
    aggregateList.addAggregateAttribute("MaxItems", aggrAttr);
    aggregateList.addGroupBy("SellerId", SaleFinder.sellerId());
    assertEquals(1, aggregateList.size());

    AggregateData data = aggregateList.getAggregateDataAt(0);
    assertEquals(4, data.getAttributeAsInt("SellerId"));
    assertEquals(16, data.getAttributeAsDouble("MaxItems"), 0);

}
 
Example #7
Source File: DependentLoaderFactoryImpl.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private void validateFilter(Operation op)
{
    if (op == null)
    {
        return;
    }
    final UnifiedSet<Attribute> attributes = UnifiedSet.newSet();
    op.zAddAllLeftAttributes(attributes);
    for (Attribute each : attributes)
    {
        if (each.isAsOfAttribute())
        {
            throw new RuntimeException("CacheLoader cannot handle AsOfOperation filter (" + op + ") on the dependent relationship " + this.relationship +
                    " all Milestoning logic has to be implemented in the cache loader factory classes (i.e. PmeYtdBalanceTopLevelLoaderFactory). " +
                    "Consider creating cacheLoader-specific relationship without AsOfAttribute filtering and with specialized factory in the cacheLoader.xml.");
        }
        if (each.isSourceAttribute())
        {
            throw new RuntimeException("CacheLoader cannot handle Source attribute filter (" + op + ") on the dependent relationship " + this.relationship +
                    " the source attributes have to be explicitly set in the cacheLoader.xml sourceAttributes properties. " +
                    "Consider creating cacheLoader-specific relationship without source attribute filtering and with source attribute defined in the cacheLoader.xml.");
        }
    }
}
 
Example #8
Source File: MithraTransactionalPortal.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private boolean txParticipationRequired(MithraTransaction tx, Operation op)
{
    boolean participate = this.getTxParticipationMode(tx).mustParticipateInTxOnRead();
    if (!participate)
    {
        UnifiedSet dependentPortals = new UnifiedSet(3);
        op.addDependentPortalsToSet(dependentPortals);
        if (dependentPortals.size() > 1)
        {
            Iterator it = dependentPortals.iterator();
            while (it.hasNext() && !participate)
            {
                MithraObjectPortal depPortal = (MithraObjectPortal) it.next();
                participate = depPortal.getTxParticipationMode(tx).mustParticipateInTxOnRead();
            }
        }
    }
    return participate;
}
 
Example #9
Source File: AbstractTransactionalOperationBasedList.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void purgeAll(DelegatingList<E> delegatingList)
{
    Operation op = delegatingList.getOperation();
    UnifiedSet portals = new UnifiedSet(3);
    op.addDependentPortalsToSet(portals);
    TransactionalCommand command;
    if (portals.size() > 1)
    {
        throw new RuntimeException("Multiple portal purgeAll not implemented");
    }
    else
    {
        command = new PurgeAllTransactionalCommand(delegatingList, this);
    }
    MithraManagerProvider.getMithraManager().executeTransactionalCommand(command);
}
 
Example #10
Source File: ALSServingModel.java    From oryx with Apache License 2.0 6 votes vote down vote up
/**
 * Like {@link #retainRecentAndUserIDs(Collection)} and {@link #retainRecentAndItemIDs(Collection)}
 * but affects the known-items data structure.
 *
 * @param users users that should be retained, which are coming in the new model updates
 * @param items items that should be retained, which are coming in the new model updates
 */
void retainRecentAndKnownItems(Collection<String> users, Collection<String> items) {
  // Keep all users in the new model, or, that have been added since last model
  MutableSet<String> recentUserIDs = UnifiedSet.newSet();
  X.addAllRecentTo(recentUserIDs);
  try (AutoLock al = knownItemsLock.autoWriteLock()) {
    knownItems.keySet().removeIf(key -> !users.contains(key) && !recentUserIDs.contains(key));
  }

  // This will be easier to quickly copy the whole (smallish) set rather than
  // deal with locks below
  MutableSet<String> allRecentKnownItems = UnifiedSet.newSet();
  Y.addAllRecentTo(allRecentKnownItems);

  Predicate<String> notKeptOrRecent = value -> !items.contains(value) && !allRecentKnownItems.contains(value);
  try (AutoLock al = knownItemsLock.autoReadLock()) {
    knownItems.values().forEach(knownItemsForUser -> {
      synchronized (knownItemsForUser) {
        knownItemsForUser.removeIf(notKeptOrRecent);
      }
    });
  }
}
 
Example #11
Source File: NonPrimitiveInOperation.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
    this.readExternalForSublcass(in);
    int size = in.readInt();
    boolean isByteArray = in.readBoolean();
    if (isByteArray)
    {
        this.set = new ByteArraySet(size);
    }
    else
    {
        this.set = new UnifiedSet(size);
    }
    for(int i=0;i<size;i++)
    {
        set.add(this.readParameter(in));
    }
}
 
Example #12
Source File: TestMax.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void testToOneOperationAndMappedToManyAttribute()
{
    Set<String> zipcodeSet = new UnifiedSet(2);
    zipcodeSet.add("10001");
    zipcodeSet.add("10038");
    Operation op = SaleFinder.seller().zipCode().notIn(zipcodeSet);
    MithraAggregateAttribute aggrAttr = SaleFinder.items().quantity().max();

    AggregateList aggregateList = new AggregateList(op);
    aggregateList.addAggregateAttribute("MaxItems", aggrAttr);
    aggregateList.addGroupBy("SellerId", SaleFinder.sellerId());
    assertEquals(1, aggregateList.size());

    AggregateData data = aggregateList.getAggregateDataAt(0);
    assertEquals(4, data.getAttributeAsInt("SellerId"));
    assertEquals(16, data.getAttributeAsDouble("MaxItems"), 0);
}
 
Example #13
Source File: SimpleToOneDeepFetchStrategy.java    From reladomo with Apache License 2.0 6 votes vote down vote up
@Override
public List finishAdhocDeepFetch(DeepFetchNode node, DeepFetchResult resultSoFar)
{
    LocalInMemoryResult localResult = (LocalInMemoryResult) resultSoFar.getLocalResult();
    FastList parentList = localResult.notFound;
    MithraList simplifiedList = fetchSimplifiedJoinList(node, parentList, true);
    if (simplifiedList != null)
    {
        node.setResolvedList(localResult.fullResult.getAll(), chainPosition);
        node.addToResolvedList(simplifiedList, chainPosition);
        return populateQueryCache(parentList, simplifiedList, new CachedQueryPair(getCachedQueryFromList(simplifiedList)));
    }
    Extractor[] leftAttributesWithoutFilters = node.getRelatedFinder().zGetMapper().getLeftAttributesWithoutFilters();
    Set<Attribute> attrSet = UnifiedSet.newSet(leftAttributesWithoutFilters.length);
    for(Extractor e: leftAttributesWithoutFilters)
    {
        attrSet.add((Attribute) e);
    }
    node.createTempTableAndDeepFetchAdhoc(attrSet, node,
            parentList);
    node.addToResolvedList(localResult.fullResult.getAll(), chainPosition);
    return node.getCachedQueryList();
}
 
Example #14
Source File: TestToDatedRelationshipViaColumn.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void testThreeLevelDeepStartingFromNonDated() throws Exception
{
    Timestamp tradeDate = new Timestamp(timestampFormat.parse("2013-11-26 00:00:00").getTime());
    IntHashSet accountIdSet = IntHashSet.newSetWith(39955000);
    final Set<String> exchangeCodeSet = UnifiedSet.newSetWith("AMEX", "BOSE");

    Operation op = MagEventFinder.magellanSourceInstanceId().eq(0);
    op = op.and(MagEventFinder.eventBusinessDate().lessThanEquals(tradeDate));
    op = op.and(MagEventFinder.eventBusinessDate().greaterThanEquals(tradeDate));
    op = op.and(MagEventFinder.transaction().accountId().in(accountIdSet));
    op = op.and(MagEventFinder.transaction().reportingAttributes().exchangeCode().in(exchangeCodeSet));

    MagEventList magEvents = MagEventFinder.findMany(op);
    magEvents.deepFetch(MagEventFinder.transaction().trade().productId());
    assertEquals(2, magEvents.size());
    int retrievalCount = this.getRetrievalCount();
    for(int i=0;i<2;i++)
    {
        assertNotNull(magEvents.get(i).getTransaction().getTrade());
        assertNotNull(magEvents.get(i).getTransaction().getTrade().getProductId());
    }
    assertEquals(retrievalCount, this.getRetrievalCount());
}
 
Example #15
Source File: TestDatabaseConfiguration.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private Set<String> getSchemaNames(List<MithraDatabaseObject> databaseObjects)
{
    Set<String> schemaNames = new UnifiedSet();

    if(databaseObjects == null)
    {
        return schemaNames;
    }

    for(int i = 0; i < databaseObjects.size(); i++)
    {
        MithraDatabaseObject databaseObject = databaseObjects.get(i);
        String defaultSchema = databaseObject.getDefaultSchema();
        if(defaultSchema != null)
            schemaNames.add(defaultSchema);
    }
    return schemaNames;
}
 
Example #16
Source File: ConnectionManagerForTests.java    From reladomo with Apache License 2.0 6 votes vote down vote up
@Override
protected void ensureAllDatabasesRegisteredAndTablesExist(MithraTestResource mtr, Set<TestDatabaseConfiguration> testDbConfigs)
{
    Set<Object> nonRegisteredKeys = new UnifiedSet<Object>();

    for (TestDatabaseConfiguration testDbConfig : testDbConfigs)
    {
        Object key = testDbConfig.getConnectionManagerSourceKey(this);
        boolean keyNotRegistered = testDbConfig.addToConnectionManager(this); // it's harmless to repeat this if the source is already present

        if (keyNotRegistered || nonRegisteredKeys.contains(key))
        {
            // If the connection manager was not registered, then it was probably removed by fullyShutdown(), which means that the H2 database was shut down and all tables are gone.
            // We need to recreate the tables belonging to this config and any other config which shares the same source key.

            logger.info("Found non-registered TestDatabaseConfiguration - recreating all tables for " + testDbConfig.toString());
            testDbConfig.recreateTables(this, mtr);
            nonRegisteredKeys.add(key);
        }
    }
}
 
Example #17
Source File: TestSum.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void testAndOperationWithDifferentMappersMappedToManyAttribute()
{
    Set<String> zipcodeSet = new UnifiedSet(2);
    zipcodeSet.add("10001");
    zipcodeSet.add("10038");
    Operation op = SaleFinder.items().productSpecs().originalPrice().greaterThan(20);
    op = op.and(SaleFinder.seller().zipCode().notIn(zipcodeSet));

    com.gs.fw.common.mithra.MithraAggregateAttribute aggrAttr = SaleFinder.items().quantity().sum();

    AggregateList aggregateList = new AggregateList(op);
    aggregateList.addAggregateAttribute("TotalItems", aggrAttr);
    aggregateList.addGroupBy("SellerId", SaleFinder.sellerId());
    assertEquals(1, aggregateList.size());

    AggregateData data = aggregateList.getAggregateDataAt(0);
    assertEquals(4, data.getAttributeAsInt("SellerId"));
    assertEquals(53, data.getAttributeAsDouble("TotalItems"), 0);
}
 
Example #18
Source File: TestAvg.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void testToOneOperationAndMappedToManyAttribute()
{
    Set<String> zipcodeSet = new UnifiedSet(2);
    zipcodeSet.add("10001");
    zipcodeSet.add("10038");
    Operation op = SaleFinder.seller().zipCode().notIn(zipcodeSet);
    com.gs.fw.common.mithra.MithraAggregateAttribute aggrAttr = SaleFinder.items().quantity().avg();

    AggregateList aggregateList = new AggregateList(op);
    aggregateList.addAggregateAttribute("AvgItems", aggrAttr);
    aggregateList.addGroupBy("SellerId", SaleFinder.sellerId());
    assertEquals(1, aggregateList.size());

    AggregateData data = aggregateList.getAggregateDataAt(0);
    assertEquals(4, data.getAttributeAsInt("SellerId"));
    assertEquals(13, data.getAttributeAsDouble("AvgItems"), 0);
}
 
Example #19
Source File: SerializationNode.java    From reladomo with Apache License 2.0 5 votes vote down vote up
protected SerializationNode withLinks(SerializationNode parent)
{
    SerializationNode result = new SerializationNode(parent, this.relatedFinder);
    result.attributes = this.attributes;

    Set<String> navigatedSet = UnifiedSet.newSet();
    for(int i=0;i<children.size();i++)
    {
        navigatedSet.add(children.get(i).getRelatedFinder().getRelationshipName());
    }

    List<RelatedFinder> allRelationships = this.relatedFinder.getRelationshipFinders();

    List<SerializationNode> newLinks = FastList.newList();

    for(int i=0;i<allRelationships.size();i++)
    {
        AbstractRelatedFinder rf = (AbstractRelatedFinder) allRelationships.get(i);
        if (!navigatedSet.contains(rf.getRelationshipName()))
        {
            SerializationNode link = new SerializationNode(result, rf, true);
            newLinks.add(link);
        }
    }
    List<SerializationNode> newChildren = FastList.newList(this.children.size());
    for(int i=0;i<children.size();i++)
    {
        newChildren.add(this.children.get(i).withLinks(result));
    }
    result.children = newChildren;
    result.links = newLinks;
    return result;
}
 
Example #20
Source File: StringSourceFullCacheLoader.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public List<Operation> getOperationsForFullCacheLoad(RelatedFinder finder)
{
    UnifiedSet<String> set = new UnifiedSet<String>();
    set.add("A");
    set.add("B");
    Operation op = ((StringAttribute) finder.getSourceAttribute()).in(set);
    if (finder.getAsOfAttributes() != null)
    {
        for(AsOfAttribute a: finder.getAsOfAttributes())
        {
            op = op.and(a.equalsEdgePoint());
        }
    }
    return ListFactory.create(op);
}
 
Example #21
Source File: TestMithraAbstractDatabaseObject.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testKilledConnectionNonRetriableException()
{
    MithraAbstractDatabaseObject.addNoRetryThreadNames(UnifiedSet.newSetWith(Thread.currentThread().getName()));
    SQLException killedConnectionException = this.createKilledConnectionException();
    this.executeTest(killedConnectionException, false);
    this.executeTest(killedConnectionException, true);
}
 
Example #22
Source File: ConvertContainerToAnother.java    From tutorials with MIT License 5 votes vote down vote up
@SuppressWarnings("rawtypes")
public static List convertToList() {
    UnifiedSet<String> cars = new UnifiedSet<>();

    cars.add("Toyota");
    cars.add("Mercedes");
    cars.add("Volkswagen");

    return cars.toList();
}
 
Example #23
Source File: AnalyzedWildcardPattern.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void addEndsWith(String s)
{
    if (this.endsWith == null)
    {
        this.endsWith = UnifiedSet.newSet(); 
    }
    this.endsWith.add(s);
}
 
Example #24
Source File: ExercisesAdvancedFinder.java    From reladomo-kata with Apache License 2.0 5 votes vote down vote up
@Test
public void testQ12()
{
    final PersonList people = this.getPeopleIn(UnifiedSet.newSetWith(3, 9, 15, 99));
    Verify.assertSetsEqual(UnifiedSet.newSetWith("Yuki Suzuki", "Douglas Adams", "Jango Fett"),
            people.asEcList().collect(PersonFinder.name()).toSet());
}
 
Example #25
Source File: TransitivePropagator.java    From reladomo with Apache License 2.0 5 votes vote down vote up
private void addEquality(ObjectWithMapperStack<Attribute> left, ObjectWithMapperStack<Attribute> right)
{
    UnifiedSet<ObjectWithMapperStack<Attribute>> existing = this.getEqualityMap().get(left);
    if (existing == null)
    {
        existing = new UnifiedSet<ObjectWithMapperStack<Attribute>>(2);
        this.getEqualityMap().put(left, existing);
    }
    existing.add(right);
}
 
Example #26
Source File: TransitivePropagator.java    From reladomo with Apache License 2.0 5 votes vote down vote up
private void processEqualities()
{
    final UnifiedMap<ObjectWithMapperStack<Attribute>, UnifiedSet<ObjectWithMapperStack<Attribute>>> equalityMap = this.getEqualityMap();
    final boolean[] anyChanged = new boolean[1];
    do
    {
        anyChanged[0] = false;
        equalityMap.forEachKeyValue(new Procedure2<ObjectWithMapperStack<Attribute>, UnifiedSet<ObjectWithMapperStack<Attribute>>>()
        {
            public void value(ObjectWithMapperStack<Attribute> attribute, UnifiedSet<ObjectWithMapperStack<Attribute>> equalities)
            {
                InternalList equalityList = new InternalList(equalities);
                for (int i = 0; i < equalityList.size(); i++)
                {
                    UnifiedSet<ObjectWithMapperStack<Attribute>> setToAdd = equalityMap.get(equalityList.get(i));
                    for (Iterator<ObjectWithMapperStack<Attribute>> setIterator = setToAdd.iterator(); setIterator.hasNext(); )
                    {
                        ObjectWithMapperStack<Attribute> possibleNewEquality = setIterator.next();
                        if (!possibleNewEquality.equals(attribute) && equalities.add(possibleNewEquality))
                        {
                            anyChanged[0] = true;
                            equalityList.add(possibleNewEquality); // growing the collection that we're looping over.
                            equalities.add(possibleNewEquality);
                        }
                    }
                }
            }
        });
    } while(anyChanged[0]);
}
 
Example #27
Source File: TestDatedRelationship.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testInSource()
{
    UnifiedSet set = UnifiedSet.newSetWith("A", "B");
    Operation op = TinyBalanceFinder.acmapCode().in(set);
    op = op.and(TinyBalanceFinder.auditedBalanceByInterest().balanceId().greaterThan(12));
    op = op.and(TinyBalanceFinder.businessDate().eq(Timestamp.valueOf("2006-03-16 00:00:00")));
    TinyBalanceFinder.findMany(op).forceResolve();
}
 
Example #28
Source File: AsOfEqualityChecker.java    From reladomo with Apache License 2.0 5 votes vote down vote up
private void initRegisteredAsOfAttributesWithMapperStack()
{
    if (this.registeredAsOfAttributesWithMapperStack == null)
    {
        this.registeredAsOfAttributesWithMapperStack = new UnifiedSet<ObjectWithMapperStack<TemporalAttribute>>(8);
    }
}
 
Example #29
Source File: ArtifactEnvironmentRestrictionsTest.java    From obevo with Apache License 2.0 5 votes vote down vote up
@Test
public void testAppliesForEnvironment() throws Exception {
    this.assertTest(true, "repo", UnifiedSet.newSetWith("repo", "abc"), UnifiedSet.<String>newSetWith());
    this.assertTest(true, "repo", UnifiedSet.newSetWith("repo*", "def"), UnifiedSet.<String>newSetWith());
    this.assertTest(true, "repo12345", UnifiedSet.newSetWith("ghi", "repo*"), UnifiedSet.<String>newSetWith());
    this.assertTest(false, "repo12345", UnifiedSet.newSetWith("repo"), UnifiedSet.<String>newSetWith());
    this.assertTest(false, "repa", UnifiedSet.newSetWith("repo"), UnifiedSet.<String>newSetWith());

    this.assertTest(false, "repo", UnifiedSet.<String>newSetWith(), UnifiedSet.newSetWith("repo", "abc"));
    this.assertTest(false, "repo", UnifiedSet.<String>newSetWith(), UnifiedSet.newSetWith("repo*", "def"));
    this.assertTest(false, "repo12345", UnifiedSet.<String>newSetWith(), UnifiedSet.newSetWith("ghi", "repo*"));
    this.assertTest(true, "repo12345", UnifiedSet.<String>newSetWith(), UnifiedSet.newSetWith("repo"));
    this.assertTest(true, "repa", UnifiedSet.<String>newSetWith(), UnifiedSet.newSetWith("repo"));
}
 
Example #30
Source File: RelationshipMultiEqualityOperation.java    From reladomo with Apache License 2.0 5 votes vote down vote up
@Override
public ShapeMatchResult zShapeMatch(Operation existingOperation)
{
    // the only case we care about is when existing is another
    // equality/multi-equality with fewer terms and matching attributes
    // all other cases are too complex.
    if (existingOperation instanceof AtomicEqualityOperation)
    {
        AtomicEqualityOperation equalityOperation = (AtomicEqualityOperation) existingOperation;
        if (this.multiExtractor.getLeftAttributes().contains(equalityOperation.getAttribute()))
        {
            return MultiEqualityOperation.createSuperMatchSmr(existingOperation, this, equalityOperation, this.getOrCreateMultiEqualityOperation());
        }
    }
    else if (existingOperation instanceof MultiEqualityOperation)
    {
        MultiEqualityOperation multiEqualityOperation = (MultiEqualityOperation) existingOperation;
        int equalityOpCount = multiEqualityOperation.getEqualityOpCount();
        if (!multiEqualityOperation.hasInClause() && equalityOpCount <= this.getEqualityOpCount())
        {
            Set set = (equalityOpCount > 8) ? new UnifiedSet(equalityOpCount) : new SmallSet(equalityOpCount);
            multiEqualityOperation.addDepenedentAttributesToSet(set);
            int matched = 0;
            for(int i=0;i<this.multiExtractor.getLeftAttributes().size();i++)
            {
                if (set.contains(this.multiExtractor.getLeftAttributes().get(i)))
                {
                    matched++;
                }
            }
            if (matched == set.size())
            {
                return equalityOpCount == this.getEqualityOpCount() ? ExactMatchSmr.INSTANCE :
                        MultiEqualityOperation.createSuperMatchSmr(existingOperation, this, multiEqualityOperation, this.getOrCreateMultiEqualityOperation(), set);
            }
        }
    }
    return NoMatchSmr.INSTANCE;
}