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

com.infomaximum.database.domainobject.iterator.IntervalIndexIterator Maven / Gradle / Ivy

The newest version!
package com.infomaximum.database.domainobject.iterator;

import com.infomaximum.database.domainobject.DataEnumerable;
import com.infomaximum.database.domainobject.DomainObject;
import com.infomaximum.database.domainobject.filter.IntervalFilter;
import com.infomaximum.database.exception.DatabaseException;
import com.infomaximum.database.provider.DBIterator;
import com.infomaximum.database.provider.KeyPattern;
import com.infomaximum.database.provider.KeyValue;
import com.infomaximum.database.schema.BaseIntervalIndex;
import com.infomaximum.database.schema.StructEntity;
import com.infomaximum.database.utils.key.IntervalIndexKey;

import java.util.*;

public class IntervalIndexIterator extends BaseIntervalIndexIterator {

    public IntervalIndexIterator(DataEnumerable dataEnumerable, Class clazz, Set loadingFields, IntervalFilter filter) throws DatabaseException {
        super(dataEnumerable, clazz, loadingFields, filter.getSortDirection(), filter);
    }

    @Override
    BaseIntervalIndex getIndex(IntervalFilter filter, StructEntity entity) {
        return entity.getIntervalIndex(filter.getHashedValues().keySet(), filter.getIndexedFieldId());
    }

    @Override
    KeyValue seek(DBIterator indexIterator, KeyPattern pattern) throws DatabaseException {
        return indexIterator.seek(pattern);
    }

    @Override
    int matchKey(long id, byte[] key) {
        long indexedBeginValue = IntervalIndexKey.unpackIndexedValue(key);
        if (indexedBeginValue < filterBeginValue || indexedBeginValue > filterEndValue) {
            return KeyPattern.MATCH_RESULT_UNSUCCESS;
        }
        return KeyPattern.MATCH_RESULT_SUCCESS;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy