org.eclipse.collections.impl.map.mutable.UnifiedMap Java Examples

The following examples show how to use org.eclipse.collections.impl.map.mutable.UnifiedMap. 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: MithraCacheLoaderRuntimeConfigTestUtil.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private Map<String, MithraObjectConfigurationType> getAllDefinedClasses(FileInputStream runtimeConfigFile)
{
    final Map<String, MithraObjectConfigurationType> allDefinedClasses = UnifiedMap.newMap();

    MithraRuntimeType mithraRuntimeType = new MithraConfigurationManager().parseConfiguration(runtimeConfigFile);

    for (ConnectionManagerType connectionManagerType : mithraRuntimeType.getConnectionManagers())
    {
        for (SchemaType schemaType : connectionManagerType.getSchemas())
        {
            this.addToAllDefinedClasses(allDefinedClasses, schemaType.getMithraObjectConfigurations());
        }
        this.addToAllDefinedClasses(allDefinedClasses, connectionManagerType.getMithraObjectConfigurations());
    }
    return allDefinedClasses;
}
 
Example #2
Source File: AsOfEqualityChecker.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private void addToInsert(ObjectWithMapperStack asOfAttributeWithMapperStack, AtomicOperation asOfOperation)
{
    if (asOfOperation == null) return;
    InternalList value;
    if (asOfAttributeWithMapperStackToInsert == null)
    {
        asOfAttributeWithMapperStackToInsert = new UnifiedMap<MapperStack, InternalList>(4);
        value = new InternalList(2);
        asOfAttributeWithMapperStackToInsert.put(asOfAttributeWithMapperStack.getMapperStack(), value);
    }
    else
    {
        value = asOfAttributeWithMapperStackToInsert.get(asOfAttributeWithMapperStack.getMapperStack());
        if (value == null)
        {
            value = new InternalList(2);
            asOfAttributeWithMapperStackToInsert.put(asOfAttributeWithMapperStack.getMapperStack(), value);
        }
    }
    value.add(new ObjectWithMapperStackAndAsOfOperation(asOfAttributeWithMapperStack, asOfOperation));
}
 
Example #3
Source File: SingleLinkDeepFetchStrategy.java    From reladomo with Apache License 2.0 6 votes vote down vote up
protected SingleLinkDeepFetchStrategy(Mapper mapper, OrderBy orderBy, Mapper alternateMapper, int chainPosition)
{
    this.mapper = mapper;
    this.alternateMapper = alternateMapper;
    this.parentMapper = mapper.getParentMapper();
    this.orderBy = orderBy;
    this.defaultAsOfOperation = mapper.getDefaultAsOfOperation(ListFactory.EMPTY_LIST);
    this.chainPosition = chainPosition;
    Operation op = null;
    if (defaultAsOfOperation != null)
    {
        op = defaultAsOfOperation[0];
        for(int i=1;i<defaultAsOfOperation.length;i++)
        {
            op = op.and(defaultAsOfOperation[i]);
        }
    }
    defaultAsOfOperationAsSingleOp = op;
    Map<Attribute, Object> tempOperationPool = new UnifiedMap();
    Operation cacheOp = this.mapper.getPrototypeOperation(tempOperationPool);
    cacheOp = addDefaultAsOfOp(cacheOp);
    this.isResolvableInCache = cacheOp.usesUniqueIndex() && cacheOp.zEstimateMaxReturnSize() <= 1;
}
 
Example #4
Source File: RemoteExtractListDatabaseIdentifiersResult.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
    int dbIdSize = in.readInt();
    databaseIdentifierMap = new UnifiedMap(dbIdSize);
    for(int i = 0; i < dbIdSize; i++)
    {
        String finderClassname = (String)in.readObject();
        RelatedFinder finderClass = instantiateRelatedFinder(finderClassname);
        Object sourceAttributeValue = in.readObject();
        String databaseIdentifier = (String) in.readObject();

        MithraDatabaseIdentifierExtractor.DatabaseIdentifierKey key =
                new MithraDatabaseIdentifierExtractor.DatabaseIdentifierKey(sourceAttributeValue, finderClass);
        databaseIdentifierMap.put(key, databaseIdentifier);
    }

}
 
Example #5
Source File: MithraLocalTransaction.java    From reladomo with Apache License 2.0 6 votes vote down vote up
@Override
public MithraPerformanceData getTransactionPerformanceDataFor(MithraObjectPortal mithraObjectPortal)
{
    if(this.performanceDataByPortal == null)
    {
        this.performanceDataByPortal = new UnifiedMap<MithraObjectPortal, MithraPerformanceData>();
    }

    MithraPerformanceData performanceData = this.performanceDataByPortal.get(mithraObjectPortal);

    if(performanceData == null)
    {
        performanceData = new MithraPerformanceData(mithraObjectPortal);
        this.performanceDataByPortal.put(mithraObjectPortal, performanceData);
    }

    return performanceData;
}
 
Example #6
Source File: MithraLocalTransaction.java    From reladomo with Apache License 2.0 6 votes vote down vote up
@Override
public PerPortalTemporalContainer getPerPortalTemporalContainer(MithraObjectPortal portal, AsOfAttribute processingAsOfAttribute)
{
    PerPortalTemporalContainer result = null;
    if (this.perPortalTemporalContainerMap == null)
    {
        this.perPortalTemporalContainerMap = new UnifiedMap<MithraObjectPortal, PerPortalTemporalContainer>();
    }
    else
    {
        result = this.perPortalTemporalContainerMap.get(portal);
    }
    if (result == null)
    {
        result = new PerPortalTemporalContainer(this, portal, processingAsOfAttribute);
        this.perPortalTemporalContainerMap.put(portal, result);
    }
    return result;
}
 
Example #7
Source File: ExercisesAdvancedFinder.java    From reladomo-kata with Apache License 2.0 6 votes vote down vote up
@Test
public void testQ18()
{
    AllTypes allTypes = new AllTypes();

    // Test no changes
    this.applyChanges(allTypes, UnifiedMap.<Integer, Object>newMap());

    Assert.assertEquals(0, allTypes.getIntValue());
    Assert.assertNull(allTypes.getStringValue());
    Assert.assertFalse(allTypes.isBooleanValue());
    Assert.assertEquals(0.0, allTypes.getDoubleValue(), 0.0);

    MutableMap<Integer, Object> changes = UnifiedMap.newMapWith(
            Tuples.<Integer, Object>pair(124, 65536),  // int
            Tuples.<Integer, Object>pair(237, "Charlie Croker"), // String
            Tuples.<Integer, Object>pair(874, true),  // boolean
            Tuples.<Integer, Object>pair(765, 1.2358));  // double
    this.applyChanges(allTypes, changes);

    Assert.assertEquals(65536, allTypes.getIntValue());
    Assert.assertEquals("Charlie Croker", allTypes.getStringValue());
    Assert.assertTrue(allTypes.isBooleanValue());
    Assert.assertEquals(1.2358, allTypes.getDoubleValue(), 0.0);
}
 
Example #8
Source File: RemoteBatchInsertResult.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
    this.readRemoteTransactionId(in);
    int dbIdSize = in.readInt();
    databaseIdentifierMap = new UnifiedMap(dbIdSize);
    for(int i = 0; i < dbIdSize; i++)
    {
        String finderClassname = (String)in.readObject();
        RelatedFinder finderClass = this.instantiateRelatedFinder(finderClassname);
        Object sourceAttributeValue = in.readObject();
        String databaseIdentifier = (String) in.readObject();

        MithraDatabaseIdentifierExtractor.DatabaseIdentifierKey key =
                new MithraDatabaseIdentifierExtractor.DatabaseIdentifierKey(sourceAttributeValue, finderClass);
        databaseIdentifierMap.put(key, databaseIdentifier);
    }
}
 
Example #9
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 #10
Source File: RemoteInsertResult.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
{
    this.readRemoteTransactionId(in);
    int dbIdSize = in.readInt();
    this.databaseIdentifierMap = new UnifiedMap<MithraDatabaseIdentifierExtractor.DatabaseIdentifierKey, String>(dbIdSize);
    for(int i = 0; i < dbIdSize; i++)
    {
        String finderClassname = (String)in.readObject();
        RelatedFinder finderClass = this.instantiateRelatedFinder(finderClassname);
        Object sourceAttributeValue = in.readObject();
        String databaseIdentifier = (String) in.readObject();

        MithraDatabaseIdentifierExtractor.DatabaseIdentifierKey key =
                new MithraDatabaseIdentifierExtractor.DatabaseIdentifierKey(sourceAttributeValue, finderClass);
        this.databaseIdentifierMap.put(key, databaseIdentifier);
    }
}
 
Example #11
Source File: MithraDatabaseIdentifierExtractor.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void setSourceOperation(SourceOperation op)
{
    if (copySourceOnSet && this.sourceOperationMap != null && this.sourceOperationMapCopy == null)
    {
        this.sourceOperationMapCopy = new UnifiedMap(this.sourceOperationMap);
    }
    SourceOperation so = (SourceOperation) this.getSourceOperationMap().get(this.mapperStackImpl);
    if (so == null)
    {
        this.getSourceOperationMap().put(this.mapperStackImpl.clone(), op);
        if (this.mapperStackImpl.isAtContainerBoundry())
        {
            MapperStackImpl copy = (MapperStackImpl) this.mapperStackImpl.clone();
            while(copy.isAtContainerBoundry()) copy.popMapperContainer();
            this.getSourceOperationMap().put(copy, op);
        }
    }
    else
    {
        if (!so.equals(op)) throw new MithraBusinessException("can't have multiple source id operations");
    }
}
 
Example #12
Source File: OffHeapFreeThread.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void queue(long base)
{
    Map<Thread, StackTraceElement[]> allStackTraces = UnifiedMap.newMap(Thread.getAllStackTraces());
    allStackTraces.remove(Thread.currentThread());
    for (Iterator<Thread> it = allStackTraces.keySet().iterator(); it.hasNext(); )
    {
        Thread thread = it.next();
        if (!isBusy(thread, allStackTraces.get(thread)))
        {
            it.remove();
        }
    }
    logger.debug("Queuing "+base+" to free later");
    synchronized (newToFree)
    {
        newToFree.add(new OffHeapThreadSnapShot(base, allStackTraces));
    }
}
 
Example #13
Source File: TableColumnInfo.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public TableColumnInfo(String catalog, String schema, String name, ColumnInfo[] columns)
{
    this.catalog = catalog;
    this.schema = schema;
    this.name = name;

    // Sort the columns by the ordinal position
    this.columns = new ColumnInfo[columns.length];
    System.arraycopy(columns, 0, this.columns, 0, columns.length);

    Arrays.sort(this.columns, new Comparator()
    {
        public int compare(Object o1, Object o2)
        {
            return ((ColumnInfo) o1).getOrdinalPosition() - ((ColumnInfo) o2).getOrdinalPosition();
        }
    });

    // Also index the columns by name
    this.columnsByName = new UnifiedMap(this.columns.length);
    for (int i = 0; i < columns.length; i++)
    {
        ColumnInfo column = columns[i];
        this.columnsByName.put(column.getName(), column);
    }
}
 
Example #14
Source File: OffHeapFreeThread.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private Map<Thread, StackTraceElement[]> getStackTracesForRelevantThreads()
{
    UnifiedMap<Thread, StackTraceElement[]> result = UnifiedMap.newMap();
    for (int i = 0; i < toFree.size(); i++)
    {
        OffHeapThreadSnapShot snapShot = toFree.get(i);
        for (Iterator<Thread> it = snapShot.activeThreads.keySet().iterator(); it.hasNext(); )
        {
            Thread thread = it.next();
            if (!thread.getState().equals(State.RUNNABLE))
            {
                it.remove();
            }
            else if (!result.containsKey(thread))
            {
                result.put(thread, thread.getStackTrace());
            }
        }
    }
    return result;
}
 
Example #15
Source File: MithraObjectGraphExtractor.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private void writeToFiles(ExecutorService executor, Map<Pair<RelatedFinder, Object>, List<MithraDataObject>> extract)
{
    UnifiedMap<File, UnifiedMap<RelatedFinder, List<MithraDataObject>>> dataByFile = UnifiedMap.newMap();
    for (Pair<RelatedFinder, Object> key : extract.keySet())
    {
        File outputFile = this.outputStrategy.getOutputFile(key.getOne(), key.getTwo());
        if (outputFile != null)
        {
            dataByFile.getIfAbsentPut(outputFile, UnifiedMap.<RelatedFinder, List<MithraDataObject>>newMap()).put(key.getOne(), extract.get(key));
        }
    }
    for (File file : dataByFile.keySet())
    {
        executor.submit(new FileWriterTask(file, dataByFile.get(file)));
    }
}
 
Example #16
Source File: ForEachPatternUnitTest.java    From tutorials with MIT License 6 votes vote down vote up
@SuppressWarnings("unchecked")
@Test
public void whenInstantiateAndChangeValues_thenCorrect() {
    Pair<Integer, String> pair1 = Tuples.pair(1, "One");
    Pair<Integer, String> pair2 = Tuples.pair(2, "Two");
    Pair<Integer, String> pair3 = Tuples.pair(3, "Three");

    UnifiedMap<Integer, String> map = UnifiedMap.newMapWith(pair1, pair2, pair3);

    for (int i = 0; i < map.size(); i++) {
        map.put(i + 1, "New Value");
    }

    for (int i = 0; i < map.size(); i++) {
        Assert.assertEquals("New Value", map.get(i + 1));
    }
}
 
Example #17
Source File: DbExtractor.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private Map<RelatedFinder, NonUniqueIndex> getExistingData()
{
    if (!this.overwrite)
    {
        if (this.saveMergedDataInMemory)
        {
            LOGGER.info("Loading merged data from memory. Size size of the list is " + this.mergedData.size());
            return this.loadData(this.mergedData);
        }
        else if (new File(this.fileName).exists())
        {
            LOGGER.info("Loading existing data from " + this.fileName);
            return this.loadDataFromFile(this.fileName);
        }
    }
    return UnifiedMap.newMap();
}
 
Example #18
Source File: CacheLoaderManagerTest.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void testLimitedLoad()
{
    assertCacheEmpty();

    CacheLoaderManagerImpl cacheLoaderManager = new CacheLoaderManagerImpl();
    cacheLoaderManager.loadConfiguration(createStringInputStream(NYK_TEST_CONFIG));

    UnifiedMap<String, AdditionalOperationBuilder> withAdditionalOperations = UnifiedMap.newWithKeysValues(LewContract.class.getName(), null);
    cacheLoaderManager.runQualifiedLoad(FastList.newListWith(BUSINESS_DATE), withAdditionalOperations, false, new CacheLoaderMonitor());

    assertEquals(3, LewContractFinder.findMany(LewContractFinder.businessDate().equalsEdgePoint().and(LewContractFinder.processingDate().equalsEdgePoint())).size());
    assertEquals(0, LewTransactionFinder.findMany(allTransactionsOperation()).size());

    withAdditionalOperations = UnifiedMap.newWithKeysValues(LewTransaction.class.getName(), null);
    cacheLoaderManager.runQualifiedLoad(FastList.newListWith(BUSINESS_DATE), withAdditionalOperations, false, new CacheLoaderMonitor());

    assertEquals(3, LewContractFinder.findMany(LewContractFinder.businessDate().equalsEdgePoint().and(LewContractFinder.processingDate().equalsEdgePoint())).size());
    assertEquals(5, LewTransactionFinder.findMany(allTransactionsOperation()).size());
}
 
Example #19
Source File: MithraTestResource.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private void setUpPortals()
{
    Map<String, MithraObjectPortal> allPortals = UnifiedMap.newMap();
    for (MithraRuntimeConfig config : this.mithraRuntimeList)
    {
        for (MithraObjectPortal portal : config.getObjectPortals())
        {
            String key = portal.getFinder().getFinderClassName();
            MithraObjectPortal existingPortal = allPortals.get(key);
            if (this.validateConnectionManagers && (existingPortal != null && !portalsHaveSameConnectionManager(portal, existingPortal)))
            {
                throw new IllegalStateException(key + " must use same connection managers in all configurations");
            }
            allPortals.put(key, portal);
        }
    }
    this.portals = FastList.newList(allPortals.values());
}
 
Example #20
Source File: ExtractResult.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public Map<Pair<RelatedFinder, Object>, List<MithraDataObject>> getDataObjectsByFinderAndSource()
{
    UnifiedMap<Pair<RelatedFinder, Object>, List<MithraDataObject>> result = UnifiedMap.newMap(this.dataObjectsByFinder.size());
    for (MithraObject key : this.dataObjectsByFinder.keySet())
    {
        FullUniqueIndex mithraObjects = this.dataObjectsByFinder.get(key);
        RelatedFinder finder = finder(key);
        Object source = source(key);
        List<MithraDataObject> mithraDataObjects = FastList.newList(mithraObjects.size());
        for (Object mithraObject : mithraObjects.getAll())
        {
            mithraDataObjects.add(((MithraObject) mithraObject).zGetCurrentData());
        }
        result.put(Pair.of(finder, source), mithraDataObjects);
    }
    return result;
}
 
Example #21
Source File: TestOperationSourceAttributeExtractor.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void testDbIdExtractionWithMultipleSourceAttributes()
{
    Map expectedDbidMap = new UnifiedMap();
    MithraDatabaseIdentifierExtractor.DatabaseIdentifierKey key = new MithraDatabaseIdentifierExtractor.DatabaseIdentifierKey("A", PlayerFinder.getFinderInstance());
    expectedDbidMap.put(key, "localhost:A");
    key = new MithraDatabaseIdentifierExtractor.DatabaseIdentifierKey("B", PlayerFinder.getFinderInstance());
    expectedDbidMap.put(key, "localhost:B");

    Set sourceAttributeSet = new UnifiedSet();
    sourceAttributeSet.add("A");
    sourceAttributeSet.add("B");

    Operation op = PlayerFinder.sourceId().in(sourceAttributeSet).and(PlayerFinder.name().eq("Rafael"));
    MithraDatabaseIdentifierExtractor dbidExtractor = new MithraDatabaseIdentifierExtractor();
    Map dbidMap = dbidExtractor.extractDatabaseIdentifierMap(op);
    assertEquals(expectedDbidMap, dbidMap);
}
 
Example #22
Source File: DeserializableMethodCache.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private Map<String, Method> findMethods(Class clazz)
{
    Method[] allMethods = clazz.getMethods();
    Map<String, Method> result = UnifiedMap.newMap();
    for(Method method: allMethods)
    {
        ReladomoDeserialize annotation = method.getAnnotation(ReladomoDeserialize.class);
        if (annotation != null)
        {
            if (method.getParameterTypes().length == 1)
            {
                result.put(method.getName(), method);
            }
            else
            {
                logger.warn("Incorrect method annotation in class " + clazz.getName() + " method " + method.getName() + " @ReladomoSerialize can only be used with methods that have no parameters");
            }
        }
    }
    return result;
}
 
Example #23
Source File: TestOperationSourceAttributeExtractor.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void testDbIdExtractionWithRelationshipAndMultipleSourceAttributes()
{
    Map expectedDbidMap = new UnifiedMap();
    MithraDatabaseIdentifierExtractor.DatabaseIdentifierKey key = new MithraDatabaseIdentifierExtractor.DatabaseIdentifierKey("A", PlayerFinder.getFinderInstance());
    expectedDbidMap.put(key, "localhost:A");
    key = new MithraDatabaseIdentifierExtractor.DatabaseIdentifierKey("A",TeamFinder.getFinderInstance());
    expectedDbidMap.put(key, "localhost:A");
    key = new MithraDatabaseIdentifierExtractor.DatabaseIdentifierKey("B", PlayerFinder.getFinderInstance());
    expectedDbidMap.put(key, "localhost:B");
    key = new MithraDatabaseIdentifierExtractor.DatabaseIdentifierKey("B", TeamFinder.getFinderInstance());
    expectedDbidMap.put(key, "localhost:B");

    Set sourceAttributeSet = new UnifiedSet();
    sourceAttributeSet.add("A");
    sourceAttributeSet.add("B");
    Operation op = TeamFinder.sourceId().in(sourceAttributeSet).and(TeamFinder.players().name().eq("Rafael"));
    MithraDatabaseIdentifierExtractor dbidExtractor = new MithraDatabaseIdentifierExtractor();
    Map dbidMap = dbidExtractor.extractDatabaseIdentifierMap(op);
    assertEquals(expectedDbidMap, dbidMap);
}
 
Example #24
Source File: MultiEqualityOperation.java    From reladomo with Apache License 2.0 5 votes vote down vote up
private ShapeMatchResult complexShapeMatch(MultiEqualityOperation existingOp)
{
    UnifiedMap<Attribute, AtomicOperation> attrOpMap = new UnifiedMap(existingOp.getEqualityOpCount());
    for(AtomicOperation ao: existingOp.atomicOperations)
    {
        attrOpMap.put(ao.getAttribute(), ao);
    }
    int lookupCount = 0;
    AtomicOperation[] forLookup = new AtomicOperation[this.getEqualityOpCount()];
    for(AtomicOperation eo: this.atomicOperations)
    {
        AtomicOperation matching = attrOpMap.get(eo.getAttribute());
        if (matching != null)
        {
            ShapeMatchResult shapeMatchResult = eo.zShapeMatch(matching);
            if (shapeMatchResult.isExactMatch())
            {
                forLookup[lookupCount++] = eo;
            }
            else if (shapeMatchResult.isSuperMatch())
            {
                forLookup[lookupCount++] = (AtomicOperation) ((SuperMatchSmr)shapeMatchResult).getLookUpOperation();
            }
            else //NoMatch
            {
                return shapeMatchResult;
            }
        }
        else
        {
            return NoMatchSmr.INSTANCE;
        }
    }
    return new SuperMatchSmr(existingOp, this, new MultiEqualityOperation(forLookup), this); // todo: can optimize filterOperation

}
 
Example #25
Source File: CacheLoaderManagerTest.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testLimitedLoadOfDependent()
{
    assertCacheEmpty();

    CacheLoaderManagerImpl cacheLoaderManager = new CacheLoaderManagerImpl();
    cacheLoaderManager.loadConfiguration(createStringInputStream(NYK_TEST_CONFIG));

    UnifiedMap<String, AdditionalOperationBuilder> withAdditionalOperations =
            UnifiedMap.newWithKeysValues(LewContract.class.getName(), null);
    cacheLoaderManager.runQualifiedLoad(FastList.newListWith(BUSINESS_DATE), withAdditionalOperations, false, new CacheLoaderMonitor());

    assertEquals(3, LewContractFinder.findMany(allContractsOperation()).size());
    assertEquals(0, LewTransactionFinder.findMany(allTransactionsOperation()).size());

    AdditionalOperationBuilder operationBuilder = new AdditionalOperationBuilder()
    {
        public Operation buildOperation(Timestamp businessDate, RelatedFinder relatedFinder)
        {
            return LewTransactionFinder.instrumentId().eq(2);
        }

        @Override
        public boolean isBusinessDateInvariant()
        {
            return true;
        }
    };
    withAdditionalOperations = UnifiedMap.newWithKeysValues(LewTransaction.class.getName(), operationBuilder);
    cacheLoaderManager.runQualifiedLoad(FastList.newListWith(BUSINESS_DATE), withAdditionalOperations, true, new CacheLoaderMonitor());

    assertEquals(3, LewContractFinder.findMany(allContractsOperation()).size());
    assertEquals(2, LewTransactionFinder.findMany(allTransactionsOperation()).size());
}
 
Example #26
Source File: CacheLoaderManagerTest.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public void testLimitedLoadWithAdditionalOperation()
{
    assertCacheEmpty();

    CacheLoaderManagerImpl cacheLoaderManager = new CacheLoaderManagerImpl();
    cacheLoaderManager.loadConfiguration(createStringInputStream(NYK_TEST_CONFIG));

    AdditionalOperationBuilder operationBuilder = new LewContractFilter();
    UnifiedMap<String, AdditionalOperationBuilder> withAdditionalOperations =
            UnifiedMap.newWithKeysValues(LewContract.class.getName(), operationBuilder);
    cacheLoaderManager.runQualifiedLoad(FastList.newListWith(BUSINESS_DATE), withAdditionalOperations, true, new CacheLoaderMonitor());

    assertEquals(1, LewContractFinder.findMany(allContractsOperation()).size());
    assertEquals(2, LewTransactionFinder.findMany(allTransactionsOperation()).size());
}
 
Example #27
Source File: TupleTempContext.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public Map<Attribute, Attribute> getPrototypeToTupleAttributeMap()
{
    Map<Attribute, Attribute> result = new UnifiedMap<Attribute, Attribute>(this.persistentTupleAttributes.length);
    Attribute prototypeSourceAttribute = prototypeAttributes[0].getSourceAttribute();
    int pos = 0;
    for(Attribute protoAttr: prototypeAttributes)
    {
        if (!protoAttr.equals(prototypeSourceAttribute))
        {
            result.put(protoAttr, (Attribute)persistentTupleAttributes[pos++]);
        }
    }
    return result;
}
 
Example #28
Source File: MithraNotificationEventManagerImpl.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public synchronized Map<String, List<MithraNotificationEvent>> getNotificationsToSend()
{
    Map<String, List<MithraNotificationEvent>> result = mithraNoTxNotificationEvents;
    if (result.isEmpty())
    {
        result = Collections.EMPTY_MAP;
    }
    else
    {
        mithraNoTxNotificationEvents = UnifiedMap.newMap();
    }
    return result;
}
 
Example #29
Source File: MithraDatabaseIdentifierExtractor.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public Map extractDatabaseIdentifierMap(RelatedFinder finder, Set sourceAttributeValueSet)
{
    this.databaseIdentifierMap = new UnifiedMap();
    for(Iterator it = sourceAttributeValueSet.iterator(); it.hasNext();)
    {
       this.createDatabaseIdentifier(finder.getMithraObjectPortal(), it.next());
    }
    return databaseIdentifierMap;
}
 
Example #30
Source File: GsObjMapTest.java    From hashmapTest with The Unlicense 5 votes vote down vote up
@Override
public int test() {
    final Map<Integer, Integer> m_map = new UnifiedMap<>( m_keys.length, m_fillFactor );
    for ( int i = 0; i < m_keys.length; ++i )
       m_map.put( m_keys[ i ],m_keys[ i ] );
    for ( int i = 0; i < m_keys2.length; ++i )
       m_map.put( m_keys2[ i ],m_keys2[ i ] );
    return m_map.size();
}