
com.hazelcast.query.impl.BaseIndexStore Maven / Gradle / Ivy
/*
* Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved.
*
* 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.hazelcast.query.impl;
import com.hazelcast.nio.serialization.Data;
import com.hazelcast.query.impl.getters.MultiResult;
import java.util.List;
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
* Base class for concrete index store implementations
*/
public abstract class BaseIndexStore implements IndexStore {
protected static final float LOAD_FACTOR = 0.75F;
protected ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
protected ReentrantReadWriteLock.ReadLock readLock = lock.readLock();
protected ReentrantReadWriteLock.WriteLock writeLock = lock.writeLock();
private boolean multiResultHasToDetectDuplicates;
abstract void newIndexInternal(Comparable newValue, QueryableEntry record);
abstract void removeIndexInternal(Comparable oldValue, Data indexKey);
@Override
public final void newIndex(Object newValue, QueryableEntry record) {
takeWriteLock();
try {
unwrapAndAddToIndex(newValue, record);
} finally {
releaseWriteLock();
}
}
private void unwrapAndAddToIndex(Object newValue, QueryableEntry record) {
if (newValue instanceof MultiResult) {
multiResultHasToDetectDuplicates = true;
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy