All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gs.fw.common.mithra.cache.TransactionalSemiUniqueDatedIndex Maven / Gradle / Ivy

There is a newer version: 18.1.0
Show newest version
/*
 Copyright 2016 Goldman Sachs.
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 */

package com.gs.fw.common.mithra.cache;

import com.gs.collections.impl.list.mutable.FastList;
import com.gs.fw.common.mithra.MithraManagerProvider;
import com.gs.fw.common.mithra.MithraTransaction;
import com.gs.fw.common.mithra.attribute.AsOfAttribute;
import com.gs.fw.common.mithra.attribute.TimestampAttribute;
import com.gs.fw.common.mithra.behavior.TemporalContainer;
import com.gs.fw.common.mithra.cache.offheap.OffHeapDataStorage;
import com.gs.fw.common.mithra.extractor.Extractor;
import com.gs.fw.common.mithra.extractor.RelationshipHashStrategy;
import com.gs.fw.common.mithra.finder.asofop.AsOfExtractor;
import com.gs.fw.common.mithra.transaction.TransactionLocal;
import com.gs.fw.common.mithra.util.DoProcedure;
import com.gs.fw.common.mithra.util.DoUntilProcedure;
import com.gs.fw.common.mithra.util.Filter;
import com.gs.fw.common.mithra.util.Filter2;
import org.slf4j.Logger;

import java.sql.Timestamp;
import java.util.List;



public abstract class TransactionalSemiUniqueDatedIndex implements TransactionalIndex, SemiUniqueDatedIndex
{

    private ExtractorBasedHashStrategy pkHashStrategy;
    private Extractor[] semiUniqueExtractors;
    private Extractor[] pkExtractors;
    private AsOfAttribute[] asOfAttributes;
    private ExtractorBasedHashStrategy hashStrategy;
    private SemiUniqueDatedIndex mainIndex;
    private TransactionLocal perTransactionStorage = new TransactionLocal();
    private final FastList preparedIndices = new FastList();
    private final boolean offHeap;

    public TransactionalSemiUniqueDatedIndex(String indexName, Extractor[] extractors, AsOfAttribute[] asOfAttributes,
            long timeToLive, long relationshipTimeToLive)
    {
        this(indexName, extractors, asOfAttributes, timeToLive, relationshipTimeToLive, null);
    }

    public TransactionalSemiUniqueDatedIndex(String indexName, Extractor[] extractors, AsOfAttribute[] asOfAttributes,
            long timeToLive, long relationshipTimeToLive, OffHeapDataStorage dataStorage)
    {
        this.semiUniqueExtractors = extractors;
        this.asOfAttributes = asOfAttributes;
        this.hashStrategy = ExtractorBasedHashStrategy.create(this.semiUniqueExtractors);
        TimestampAttribute[] datedAttributes = new TimestampAttribute[this.asOfAttributes.length];
        for(int i=0;i collectMilestoningOverlaps()
    {
        return this.getMainIndex().collectMilestoningOverlaps();
    }

    protected FullUniqueIndex getPerThreadDeletedIndex(TransactionLocalStorage txStorage)
    {
        return txStorage == null ? null : txStorage.deleted;
    }

    private Object checkDeletedIndex(Object result, TransactionLocalStorage txStorage)
    {
        if (result != null)
        {
            FullUniqueIndex perThreadDeletedIndex = this.getPerThreadDeletedIndex(txStorage);
            if (perThreadDeletedIndex != null)
            {
                if (result instanceof List)
                {
                    List list = (List) result;
                    List resultList = new FastList(list.size());
                    for (int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy