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

com.googlecode.cqengine.index.disk.DiskIndex Maven / Gradle / Ivy

Go to download

Collection Query Engine: NoSQL indexing and query engine for Java collections with ultra-low latency

There is a newer version: 3.6.0
Show newest version
/**
 * Copyright 2012-2015 Niall Gallagher
 *
 * 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.googlecode.cqengine.index.disk;

import com.googlecode.cqengine.attribute.Attribute;
import com.googlecode.cqengine.attribute.SimpleAttribute;
import com.googlecode.cqengine.index.sqlite.SimplifiedSQLiteIndex;
import com.googlecode.cqengine.persistence.Persistence;
import com.googlecode.cqengine.persistence.disk.DiskPersistence;

/**
 * An index persisted in a file on disk.
 * 

* This index is similar to the on-heap {@link com.googlecode.cqengine.index.navigable.NavigableIndex} and supports * the same types of queries. *

* The current implementation of this index is based on {@link com.googlecode.cqengine.index.sqlite.SQLiteIndex}. * * @author niall.gallagher */ public class DiskIndex, O, K extends Comparable> extends SimplifiedSQLiteIndex { DiskIndex(DiskPersistence persistence, Attribute attribute, SimpleAttribute foreignKeyAttribute) { super(attribute, persistence, foreignKeyAttribute); } DiskIndex(Class> persistenceType, Attribute attribute) { super(persistenceType, attribute); } // ---------- Static factory methods to create OffHeapIndex ---------- /** * Creates a new {@link DiskIndex} which uses a persistence strategy configured explicitly (which may be * different from how the IndexedCollection is persisted). * * @param attribute The {@link Attribute} on which the index will be built. * @param persistence Specifies how and where the index should be persisted. * @param foreignKeyAttribute A {@link SimpleAttribute} which can resolve a foreign key read from the index back * into an object. * @param The type of the attribute to be indexed. * @param The type of the object containing the attribute. * @param The type of the foreign key. * @return A {@link DiskIndex} on the given attribute. */ public static , O, K extends Comparable> DiskIndex onAttribute(final Attribute attribute, final DiskPersistence persistence, final SimpleAttribute foreignKeyAttribute) { return new DiskIndex(persistence, attribute, foreignKeyAttribute); } /** * Creates a new {@link DiskIndex} which uses the same persistence strategy as the IndexedCollection. * * @param attribute The {@link Attribute} on which the index will be built. * @param The type of the attribute to be indexed. * @param The type of the object containing the attribute. * @return A {@link DiskIndex} on the given attribute. */ @SuppressWarnings("unchecked") // unchecked, because type K will be provided by SQLitePersistentSet in the init() method public static , O> DiskIndex> onAttribute(final Attribute attribute) { return new DiskIndex(DiskPersistence.class, attribute); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy