com.gs.fw.common.mithra.finder.RelatedFinder Java Examples

The following examples show how to use com.gs.fw.common.mithra.finder.RelatedFinder. 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: SingleColumnCharAttribute.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public static SingleColumnCharAttribute generate(String columnName, String uniqueAlias, String attributeName,
        String busClassNameWithDots, String busClassName, boolean isNullablePrimitive,
        boolean hasBusDate, RelatedFinder relatedFinder, Map<String, Object> properties,
        boolean isTransactional, boolean isOptimistic, int offHeapFieldOffset, int offHeapNullBitsOffset, int offHeapNullBitsPosition, boolean hasShadowAttribute)
{
    SingleColumnCharAttribute e = generateInternal(columnName, uniqueAlias, attributeName, busClassNameWithDots,
            busClassName, isNullablePrimitive, hasBusDate, relatedFinder, properties, isTransactional,
            isOptimistic, offHeapFieldOffset, offHeapNullBitsOffset, offHeapNullBitsPosition, false);
    if (hasShadowAttribute)
    {
        SingleColumnCharAttribute shadow = generateInternal(columnName, uniqueAlias, attributeName, busClassNameWithDots,
                busClassName, isNullablePrimitive, hasBusDate, relatedFinder, properties, isTransactional,
                isOptimistic, offHeapFieldOffset, offHeapNullBitsOffset, offHeapNullBitsPosition, true);
        e.setShadowAttribute(shadow);
    }
    return e;

}
 
Example #2
Source File: TransactionOperation.java    From reladomo with Apache License 2.0 6 votes vote down vote up
protected FullUniqueIndex createFullUniqueIndex(List objects)
{
    RelatedFinder finder = this.getPortal().getFinder();
    Extractor[] extractors = IdentityExtractor.getArrayInstance();
    UnderlyingObjectGetter getter = null;
    if (finder.getAsOfAttributes() != null)
    {
        extractors = getObjectSamenessKeyAttributes(finder);
        getter = new TransactionalUnderlyingObjectGetter();
    }
    FullUniqueIndex index = new FullUniqueIndex(extractors, objects.size());
    if (getter != null)
    {
        index.setUnderlyingObjectGetter(getter);
    }
    for(int i=0;i<objects.size();i++)
    {
        index.put(objects.get(i));
    }
    return index;
}
 
Example #3
Source File: ReladomoDeserializer.java    From reladomo with Apache License 2.0 6 votes vote down vote up
protected void setToManyRelationship(String name, DeserializationClassMetaData metaData, PartialDeserialized partialDeserialized) throws IllegalAccessException, InvocationTargetException
{
    RelatedFinder related = metaData.getRelationshipFinderByName(name);
    AbstractRelatedFinder abstractRelatedFinder = (AbstractRelatedFinder) related;
    Object o = partialDeserialized.partialRelationships.get(name);
    MithraList relatedList = abstractRelatedFinder.constructEmptyList();
    if (o == null)
    {
        //do nothing
    }
    else if (o instanceof ReladomoDeserializer.PartialDeserialized)
    {
        filterObjectForToManyRelationship(relatedList, ((PartialDeserialized)o));
    }
    else // a List<PartialDeserialzied)
    {
        for(PartialDeserialized p: (List<PartialDeserialized>) o)
        {
            filterObjectForToManyRelationship(relatedList, p);
        }
        List existing = (List) abstractRelatedFinder.valueOf(partialDeserialized.deserialized);
        reconcileToMany(abstractRelatedFinder, existing, relatedList);
    }
    metaData.getRelationshipSetter(name).invoke(partialDeserialized.deserialized, relatedList);
}
 
Example #4
Source File: DefaultLoadOperationProvider.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public List<Operation> getOperationsForFullCacheLoad(RelatedFinder finder)
{
    if (finder.getSourceAttribute() != null)
    {
        throw new RuntimeException("for full cache load of objects with source attribute, configure a loadOperationProvider in the runtime xml");
    }
    AsOfAttribute[] asOfAttributes = finder.getAsOfAttributes();
    if (asOfAttributes != null)
    {
        Operation op = asOfAttributes[0].equalsEdgePoint();
        if (asOfAttributes.length > 1)
        {
            op = op.and(asOfAttributes[1].equalsEdgePoint());
        }
        return ListFactory.create(op);
    }
    else
    {
        return ListFactory.create(finder.all());
    }
}
 
Example #5
Source File: TestSubQueryCache.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public void testAllWithMax()
{
    if (!OrderFinder.getMithraObjectPortal().isFullyCached())
    {
        Operation op = OrderFinder.all();
        Operation subOp = OrderFinder.userId().eq(2);
        RelatedFinder finderInstance = OrderFinder.getFinderInstance();
        MithraList many = finderInstance.findMany(op);
        many.setMaxObjectsToRetrieve(1);
        assertTrue(!many.isEmpty());

        int retrievalCount = this.getRetrievalCount();
        List subList = finderInstance.findMany(subOp);
        int subSize = subList.size();
        assertTrue(subSize > 0);
        assertEquals(retrievalCount + 1, this.getRetrievalCount());

        assertEquals(subSize, finderInstance.findManyBypassCache(subOp).size());
    }
}
 
Example #6
Source File: FastUnsafeOffHeapDataStorage.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private void populateStringAttributes(RelatedFinder finder)
{
    Attribute[] persistentAttributes = finder.getPersistentAttributes();
    List<OffHeapStringExtractor> tmp = MithraFastList.newList();
    Attribute sourceAttribute = finder.getSourceAttribute();
    if (sourceAttribute != null && sourceAttribute instanceof SingleColumnStringAttribute)
    {
        tmp.add((OffHeapStringExtractor) sourceAttribute.zCreateOffHeapExtractor());
    }
    for(Attribute a: persistentAttributes)
    {
        if (a instanceof SingleColumnStringAttribute)
        {
            tmp.add((OffHeapStringExtractor) a.zCreateOffHeapExtractor());
        }
    }
    stringAttributes = tmp.toArray(new OffHeapStringExtractor[tmp.size()]);
}
 
Example #7
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 #8
Source File: DbExtractor.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private void addClassToMap(List data, RelatedFinder finder, Map<RelatedFinder, List<MithraDataObject>> map)
{
    if (!data.isEmpty())
    {
        List<MithraDataObject> existing = map.get(finder);
        if (existing == null)
        {
            existing = FastList.newList(data.size());
            map.put(finder, existing);
        }
        for (int i = 0; i < data.size(); i++)
        {
            existing.add(MithraObject.class.cast(data.get(i)).zGetCurrentData());
        }
    }
}
 
Example #9
Source File: AsOfAttribute.java    From reladomo with Apache License 2.0 6 votes vote down vote up
protected AsOfAttribute(String attributeName, String busClassNameWithDots, String busClassName, boolean isNullable,
        boolean hasBusDate, RelatedFinder relatedFinder, Map<String, Object> properties, boolean transactional, boolean isOptimistic,
        TimestampAttribute fromAttribute, TimestampAttribute toAttribute, Timestamp infinityDate,
        boolean futureExpiringRowsExist, boolean toIsInclusive, Timestamp defaultDate, boolean isProcessingDate)
{
    this.fromAttribute = fromAttribute;
    this.toAttribute = toAttribute;
    this.infinityDate = infinityDate;
    this.infinityTime = infinityDate.getTime();
    this.futureExpiringRowsExist = futureExpiringRowsExist;
    this.toIsInclusive = toIsInclusive;
    this.defaultDate = defaultDate;
    this.attributeName = attributeName;
    this.isProcessingDate = isProcessingDate;
    this.setAll(attributeName, busClassNameWithDots, busClassName, isNullable, relatedFinder, properties, transactional);
}
 
Example #10
Source File: ReladomoDeserializer.java    From reladomo with Apache License 2.0 6 votes vote down vote up
protected void wireRelationshipsForInMemory(DeserializationClassMetaData metaData, PartialDeserialized partialDeserialized) throws DeserializationException
{
    for (String name : partialDeserialized.partialRelationships.keySet())
    {
        RelatedFinder relationshipFinderByName = metaData.getRelationshipFinderByName(name);
        try
        {
            if (((AbstractRelatedFinder) relationshipFinderByName).isToOne())
            {
                Object o = partialDeserialized.partialRelationships.get(name);
                setToOneRelationship(name, metaData, partialDeserialized, decodeToOne(name, partialDeserialized, o));
            }
            else
            {
                setToManyRelationship(name, metaData, partialDeserialized);
            }
        }
        catch (Exception e)
        {
            throw new DeserializationException("Could not set to-one relationship on " + partialDeserialized.dataObject.zGetPrintablePrimaryKey() + " for " + name);
        }
    }
}
 
Example #11
Source File: SingleColumnByteAttribute.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private static SingleColumnByteAttribute generateInternal(String columnName, String uniqueAlias, String attributeName, String busClassNameWithDots,
        String busClassName, boolean isNullablePrimitive, boolean hasBusDate, RelatedFinder relatedFinder, Map<String, Object> properties,
        boolean isTransactional, boolean isOptimistic, int offHeapFieldOffset, int offHeapNullBitsOffset, int offHeapNullBitsPosition, boolean hasShadowAttribute)
{
    SingleColumnByteAttribute e;
    try
    {
        e = (SingleColumnByteAttribute) extractorWriter.createClass(attributeName, isNullablePrimitive, hasBusDate, busClassNameWithDots,
                busClassName, isOptimistic, offHeapFieldOffset, offHeapNullBitsOffset, offHeapNullBitsPosition,
                "com/gs/fw/common/mithra/attribute/SingleColumnByteAttribute", false, hasShadowAttribute).newInstance();
    }
    catch (Exception excp)
    {
        throw new RuntimeException("could not create class for "+attributeName+" in "+busClassName, excp);
    }
    e.columnName = columnName;
    e.uniqueAlias = uniqueAlias;
    e.setAll(attributeName, busClassNameWithDots, busClassName, isNullablePrimitive, relatedFinder, properties, isTransactional);
    e.setOffHeapOffsets(offHeapFieldOffset, offHeapNullBitsOffset, offHeapNullBitsPosition);
    return e;
}
 
Example #12
Source File: MultiQueueExecutor.java    From reladomo with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor.
 * @param numberOfQueues      Total number of queues. There is one thread  for every queue, so this is also the number of threads.
 * @param hashBucketExtractor Hashing algorithm for the object. You can use a Mithra attribute, for example ProductFinder.cusip()
 * @param batchSize           Number of objects to put in each batch.
 * @param finder              An instance of the finder class. For example, ProductFinder.getFinderInstance()
 *
 */
public MultiQueueExecutor(int numberOfQueues, HashableValueSelector hashBucketExtractor,
                          int batchSize, RelatedFinder finder)
{
    this.batchSize = batchSize;
    this.finder = finder;
    AsOfAttribute[] asOfAttributes = finder.getAsOfAttributes();
    isDated = asOfAttributes != null;
    hasOptimisticLocking = asOfAttributes != null && (asOfAttributes.length == 2 || asOfAttributes[0].isProcessingDate());
    this.numberOfQueues = numberOfQueues;
    executors = new ThreadPoolExecutor[numberOfQueues];
    for (int i = 0; i < numberOfQueues; i++)
    {
        executors[i] = createExecutor();
    }
    this.hashBucketExtractor = hashBucketExtractor;
    terminateLists = allocateLists();
    insertLists = allocateLists();
    dbUpdateLists = allocateLists();
    fileUpdateLists = allocateLists();
    lastLogTime = System.currentTimeMillis();
}
 
Example #13
Source File: SingleColumnCharAttribute.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private static SingleColumnCharAttribute generateInternal(String columnName, String uniqueAlias, String attributeName, String busClassNameWithDots,
        String busClassName, boolean isNullablePrimitive, boolean hasBusDate, RelatedFinder relatedFinder, Map<String, Object> properties,
        boolean isTransactional, boolean isOptimistic, int offHeapFieldOffset, int offHeapNullBitsOffset, int offHeapNullBitsPosition, boolean hasShadowAttribute)
{
    SingleColumnCharAttribute e;
    try
    {
        e = (SingleColumnCharAttribute) extractorWriter.createClass(attributeName, isNullablePrimitive, hasBusDate, busClassNameWithDots,
                busClassName, isOptimistic, offHeapFieldOffset, offHeapNullBitsOffset, offHeapNullBitsPosition, "com/gs/fw/common/mithra/attribute/SingleColumnCharAttribute", false, hasShadowAttribute).newInstance();
    }
    catch (Exception excp)
    {
        throw new RuntimeException("could not create class for "+attributeName+" in "+busClassName, excp);
    }
    e.columnName = columnName;
    e.uniqueAlias = uniqueAlias;
    e.setAll(attributeName, busClassNameWithDots, busClassName, isNullablePrimitive, relatedFinder, properties, isTransactional);
    e.setOffHeapOffsets(offHeapFieldOffset, offHeapNullBitsOffset, offHeapNullBitsPosition);
    return e;
}
 
Example #14
Source File: DbExtractor.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private void writeToFile(Map<RelatedFinder, List<MithraDataObject>> allMergedData) throws IOException
{
    allMergedData = this.transformer.transform(allMergedData);

    LOGGER.info("Writing merged data to " + this.fileName);
    List<RelatedFinder> allRelatedFinders = FastList.newList(allMergedData.keySet());
    Collections.sort(allRelatedFinders, new Comparator<RelatedFinder>()
    {
        public int compare(RelatedFinder o1, RelatedFinder o2)
        {
            return o1.getClass().getName().compareTo(o2.getClass().getName());
        }
    });
    if (this.fileName.endsWith(".ccbf") || this.saveMergedDataInMemory)
    {
        writeColumnarFile(allMergedData, allRelatedFinders);
    }
    else
    {
        writeTextFile(allMergedData, allRelatedFinders);
    }
}
 
Example #15
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 #16
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 #17
Source File: MithraConfigurationManager.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public synchronized MithraObjectPortal initializeObject(List<String> mithraInitializationErrors)
{
    RelatedFinder relatedFinder = getRelatedFinder(className, mithraInitializationErrors);
    if (relatedFinder != null)
    {
        if (initialized)
        {
            return relatedFinder.getMithraObjectPortal();
        }
        MithraObjectDeserializer deserializer = instantiateDeserializer(className, mithraInitializationErrors);
        MithraPureObjectFactory factory = (MithraPureObjectFactory) deserializer;
        factory.setFactoryParameter(factoryParameter);

        deserializer.instantiateFullCache(this);
        MithraObjectPortal mithraObjectPortal = relatedFinder.getMithraObjectPortal();
        addToExportedConfigs(relatedFinder, MithraConfigurationManager.this);
        initialized = true;
        if (postInitializeHook != null)
        {
            postInitializeHook.callbackAfterInitialize(this.className, mithraObjectPortal, mithraInitializationErrors, false);
        }
        return mithraObjectPortal;
    }
    return null;
}
 
Example #18
Source File: MithraConfigurationManager.java    From reladomo with Apache License 2.0 6 votes vote down vote up
protected void addToExportedConfigs(RelatedFinder relatedFinder, MithraConfigurationManager configManager)
{
    if (threeTierExport)
    {
        synchronized (configManager.threeTierConfigSet)
        {
            configManager.threeTierConfigSet.add(new RemoteMithraObjectConfig(relationshipCacheSize,
                    minQueriesToKeep, className, relatedFinder.getSerialVersionId(),
                    useMultiUpdate, relatedFinder.getHierarchyDepth(), pureNotificationId,
                    this.cacheTimeToLive, this.relationshipCacheTimeToLive, this.factoryParameter, persisterId));
        }
    }
    if (isOffHeapFullCache() && relatedFinder.getAsOfAttributes() != null)
    {
        synchronized (configManager.cacheReplicableConfigSet)
        {
            configManager.cacheReplicableConfigSet.add(new RemoteMithraObjectConfig(relationshipCacheSize,
                    minQueriesToKeep, className, relatedFinder.getSerialVersionId(),
                    useMultiUpdate, relatedFinder.getHierarchyDepth(), pureNotificationId,
                    this.cacheTimeToLive, this.relationshipCacheTimeToLive, this.factoryParameter, persisterId));
        }
    }
}
 
Example #19
Source File: MithraObjectGraphExtractor.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private List<RelatedFinder> getRelationships(RelatedFinder relatedFinder, Set<RelatedFinder> toManyRelationships)
{
    List allRelationships = relatedFinder.getRelationshipFinders();
    List<RelatedFinder> interestingRelationships = FastList.newList(allRelationships.size());
    for (Object object : allRelationships)
    {
        AbstractRelatedFinder relationship = AbstractRelatedFinder.class.cast(object);
        boolean notIgnored = !ignored.contains(relationship);
        boolean isToOneOrFirstToMany = relationship.isToOne() || toManyRelationships.isEmpty();
        if (notIgnored && isToOneOrFirstToMany)
        {
            interestingRelationships.add(relationship);
        }
    }
    return interestingRelationships;
}
 
Example #20
Source File: SingleColumnByteArrayAttribute.java    From reladomo with Apache License 2.0 6 votes vote down vote up
public static SingleColumnByteArrayAttribute generate(String columnName, String uniqueAlias, String attributeName,
        String busClassNameWithDots, String busClassName, boolean isNullablePrimitive,
        boolean hasBusDate, RelatedFinder relatedFinder, Map<String, Object> properties,
        boolean isTransactional, boolean isOptimistic, int offHeapFieldOffset, int offHeapNullBitsOffset, int offHeapNullBitsPosition, int maxLength, boolean hasShadowAttribute)
{
    SingleColumnByteArrayAttribute e = generateInternal(columnName, uniqueAlias, attributeName, busClassNameWithDots,
            busClassName, isNullablePrimitive, hasBusDate, relatedFinder, properties, isTransactional, isOptimistic, offHeapFieldOffset, offHeapNullBitsOffset, offHeapNullBitsPosition,
            maxLength, false);
    if (hasShadowAttribute)
    {
        SingleColumnByteArrayAttribute shadow = generateInternal(columnName, uniqueAlias, attributeName, busClassNameWithDots,
                busClassName, isNullablePrimitive, hasBusDate, relatedFinder, properties, isTransactional, isOptimistic, offHeapFieldOffset, offHeapNullBitsOffset, offHeapNullBitsPosition,
                maxLength, true);
        e.setShadowAttribute(shadow);
    }
    return e;
}
 
Example #21
Source File: SingleColumnBigDecimalAttribute.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private static SingleColumnBigDecimalAttribute generateInternal(String columnName, String uniqueAlias, String attributeName,
        String busClassNameWithDots, String busClassName, boolean isNullablePrimitive, boolean hasBusDate, RelatedFinder relatedFinder,
        Map<String, Object> properties, boolean isTransactional, boolean isOptimistic, int offHeapFieldOffset, int offHeapNullBitsOffset, int offHeapNullBitsPosition, int precision, int scale, boolean isShadowAttribute)
{
    SingleColumnBigDecimalAttribute e;
    try
    {
        e = (SingleColumnBigDecimalAttribute) extractorWriter.createClass(attributeName, isNullablePrimitive, hasBusDate, busClassNameWithDots,
                busClassName, isOptimistic, offHeapFieldOffset, offHeapNullBitsOffset, offHeapNullBitsPosition,
                "com/gs/fw/common/mithra/attribute/SingleColumnBigDecimalAttribute", false, isShadowAttribute).newInstance();
    }
    catch (Exception excp)
    {
        throw new RuntimeException("could not create class for "+attributeName+" in "+busClassName, excp);
    }
    e.columnName = columnName;
    e.uniqueAlias = uniqueAlias;
    e.setPrecision(precision);
    e.setScale(scale);
    e.setAll(attributeName, busClassNameWithDots, busClassName, isNullablePrimitive, relatedFinder, properties, isTransactional);
    e.setOffHeapOffsets(offHeapFieldOffset, offHeapNullBitsOffset, offHeapNullBitsPosition);
    return e;
}
 
Example #22
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 #23
Source File: SingleColumnIntegerAttribute.java    From reladomo with Apache License 2.0 6 votes vote down vote up
private static SingleColumnIntegerAttribute generateInternal(String columnName, String uniqueAlias, String attributeName,
        String busClassNameWithDots, String busClassName, boolean isNullablePrimitive, boolean hasBusDate,
        RelatedFinder relatedFinder, Map<String, Object> properties, boolean isTransactional, boolean isOptimistic,
        boolean isIdentity, int offHeapFieldOffset, int offHeapNullBitsOffset, int offHeapNullBitsPosition, boolean hasSequence, boolean hasShadowAttribute)
{
    SingleColumnIntegerAttribute e;
    try
    {
        e = (SingleColumnIntegerAttribute) extractorWriter.createClass(attributeName, isNullablePrimitive, hasBusDate, busClassNameWithDots,
                busClassName, isOptimistic, offHeapFieldOffset, offHeapNullBitsOffset, offHeapNullBitsPosition,
                "com/gs/fw/common/mithra/attribute/SingleColumnIntegerAttribute", hasSequence, hasShadowAttribute).newInstance();
    }
    catch (Exception excp)
    {
        throw new RuntimeException("could not create class for "+attributeName+" in "+busClassName, excp);
    }
    e.columnName = columnName;
    e.uniqueAlias = uniqueAlias;
    e.isIdentity = isIdentity;
    e.setAll(attributeName, busClassNameWithDots, busClassName, isNullablePrimitive, relatedFinder, properties, isTransactional);
    e.setOffHeapOffsets(offHeapFieldOffset, offHeapNullBitsOffset, offHeapNullBitsPosition);
    return e;
}
 
Example #24
Source File: DelegatingList.java    From reladomo with Apache License 2.0 6 votes vote down vote up
protected List intersection(DelegatingList other)
{
    RelatedFinder finder = this.getMithraObjectPortal().getFinder();
    if (other.isOperationBased() && this.isOperationBased())
    {
        return finder.findMany(new AndOperation(this.getOperation(), other.getOperation()));
    }
    else
    {
        List result = finder.constructEmptyList();
        result.addAll(this);
        result.retainAll(other);
        return result;
    }

}
 
Example #25
Source File: TestVerboseSerializer.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public List deserialize(byte[] input, RelatedFinder finder, Class dataClass) throws IOException, ClassNotFoundException
{
    ByteArrayInputStream bis  = new ByteArrayInputStream(input);
    ObjectInputStream ois = new ObjectInputStream(bis);
    VerboseSerializer deserializer = new VerboseSerializer(finder, dataClass);

    List result = deserializer.readObjectsAsDataObjects(ois);
    ois.close();
    bis.close();
    return result;
}
 
Example #26
Source File: SingleColumnCharAttribute.java    From reladomo with Apache License 2.0 5 votes vote down vote up
protected SingleColumnCharAttribute(String columnName, String uniqueAlias, String attributeName,
        String busClassNameWithDots, String busClassName, boolean isNullablePrimitive,
        boolean hasBusDate, RelatedFinder relatedFinder, Map<String, Object> properties,
        boolean isTransactional, boolean isOptimistic)
{
    this.columnName = columnName;
    this.uniqueAlias = uniqueAlias;
    this.setAll(attributeName, busClassNameWithDots, busClassName, isNullablePrimitive, relatedFinder, properties, isTransactional);
}
 
Example #27
Source File: DatedDetachedDeletedBehavior.java    From reladomo with Apache License 2.0 5 votes vote down vote up
@Override
    public Map<RelatedFinder, StatisticCounter> addNavigatedRelationshipsStats(MithraTransactionalObject obj, RelatedFinder parentFinder, Map<RelatedFinder, StatisticCounter> navigationStats)
    {
        throw new RuntimeException("should not get here");
//        MithraObjectUtils.zAddToNavigationStats(parentFinder, true, navigationStats);
//        obj.zAddNavigatedRelationshipsStatsForDelete(parentFinder, navigationStats);
//        return navigationStats;
    }
 
Example #28
Source File: SingleColumnTimestampAttribute.java    From reladomo with Apache License 2.0 5 votes vote down vote up
protected SingleColumnTimestampAttribute(String columnName, String uniqueAlias, String attributeName,
        String busClassNameWithDots, String busClassName, boolean isNullablePrimitive,
        boolean hasBusDate, RelatedFinder relatedFinder, Map<String, Object> properties,
        boolean isTransactional, boolean isOptimistic, byte conversionType,
        boolean setAsString, boolean isAsOfAttributeTo, Timestamp infinity, byte precision)
{
    this.columnName = columnName;
    this.uniqueAlias = uniqueAlias;
    this.setTimestampProperties(conversionType, setAsString, isAsOfAttributeTo, infinity, precision);
    this.setAll(attributeName, busClassNameWithDots, busClassName, isNullablePrimitive, relatedFinder, properties, isTransactional);
}
 
Example #29
Source File: TransactionOperation.java    From reladomo with Apache License 2.0 5 votes vote down vote up
private boolean touchesSameObjectUsingIndex(TransactionOperation otherOp)
{
    int otherSize = otherOp.getAllObjects().size();
    int localSize = this.getAllObjects().size();
    TransactionOperation biggerOp;
    TransactionOperation smallerOp;
    if(localSize > otherSize)
    {
        biggerOp = this;
        smallerOp = otherOp;
    }
    else
    {
        biggerOp = otherOp;
        smallerOp = this;
    }
    RelatedFinder finder = this.getPortal().getFinder();
    if (finder.getAsOfAttributes() == null)
    {
        return indexCompare(smallerOp.getIndexedObjects(), biggerOp.getAllObjects());
    }
    //for temporal objects can't use the unique index with as-of attributes
    Extractor[] extractors = finder.getPrimaryKeyAttributes();
    List objectsFromSmallerOp = smallerOp.getAllObjects();
    FullUniqueIndex index = new FullUniqueIndex(extractors, objectsFromSmallerOp.size());
    index.setUnderlyingObjectGetter(new TransactionalUnderlyingObjectGetter());
    for (int i =0 ; i < objectsFromSmallerOp.size(); i++)
    {
        index.put(objectsFromSmallerOp.get(i));
    }
    return indexCompare(index, biggerOp.getAllObjects());
}
 
Example #30
Source File: SingleColumnBigDecimalAttribute.java    From reladomo with Apache License 2.0 5 votes vote down vote up
public static SingleColumnBigDecimalAttribute generate(String columnName, String uniqueAlias, String attributeName,
        String busClassNameWithDots, String busClassName, boolean isNullablePrimitive,
        boolean hasBusDate, RelatedFinder relatedFinder, Map<String, Object> properties,
        boolean isTransactional, boolean isOptimistic, int offHeapFieldOffset, int offHeapNullBitsOffset, int offHeapNullBitsPosition, int precision, int scale, boolean hasShadowAttribute)
{
    SingleColumnBigDecimalAttribute e = generateInternal(columnName, uniqueAlias, attributeName, busClassNameWithDots, busClassName, isNullablePrimitive,
            hasBusDate, relatedFinder, properties, isTransactional, isOptimistic, offHeapFieldOffset, offHeapNullBitsOffset, offHeapNullBitsPosition, precision, scale, false);
    if (hasShadowAttribute)
    {
        Attribute shadow = generateInternal(columnName, uniqueAlias, attributeName, busClassNameWithDots, busClassName, isNullablePrimitive,
            hasBusDate, relatedFinder, properties, isTransactional, isOptimistic, offHeapFieldOffset, offHeapNullBitsOffset, offHeapNullBitsPosition, precision, scale, true);
        e.setShadowAttribute(shadow);
    }
    return e;
}