001 /* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at 010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE 011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE. 012 * See the License for the specific language governing permissions 013 * and limitations under the License. 014 * 015 * When distributing Covered Code, include this CDDL HEADER in each 016 * file and include the License file at 017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable, 018 * add the following below this CDDL HEADER, with the fields enclosed 019 * by brackets "[]" replaced with your own identifying information: 020 * Portions Copyright [yyyy] [name of copyright owner] 021 * 022 * CDDL HEADER END 023 * 024 * 025 * Copyright 2006-2008 Sun Microsystems, Inc. 026 */ 027 package org.opends.server.backends.jeb; 028 029 import org.opends.server.types.Entry; 030 import org.opends.server.types.Modification; 031 import com.sleepycat.je.DatabaseException; 032 033 import java.util.Comparator; 034 import java.util.Set; 035 import java.util.List; 036 import java.util.Map; 037 038 /** 039 * This class attempts to abstract the generation and comparison of keys 040 * for an index. It is subclassed for the specific type of indexing. 041 */ 042 public abstract class Indexer 043 { 044 /** 045 * Get the comparator that must be used to compare index keys 046 * generated by this class. 047 * 048 * @return A byte array comparator. 049 */ 050 public abstract Comparator<byte[]> getComparator(); 051 052 /** 053 * Generate the set of index keys for an entry. 054 * 055 * @param entry The entry. 056 * @param keys The set into which the generated keys will be inserted. 057 * @throws DatabaseException If an error occurs in the JE database. 058 */ 059 public abstract void indexEntry(Entry entry, Set<byte[]> keys) 060 throws DatabaseException; 061 062 /** 063 * Generate the set of index keys to be added and the set of index keys 064 * to be deleted for an entry that has been replaced. 065 * 066 * @param oldEntry The original entry contents. 067 * @param newEntry The new entry contents. 068 * @param modifiedKeys The map into which the modified keys will be inserted. 069 * @throws DatabaseException If an error occurs in the JE database. 070 */ 071 public abstract void replaceEntry(Entry oldEntry, Entry newEntry, 072 Map<byte[], Boolean> modifiedKeys) 073 throws DatabaseException; 074 075 /** 076 * Generate the set of index keys to be added and the set of index keys 077 * to be deleted for an entry that was modified. 078 * 079 * @param oldEntry The original entry contents. 080 * @param newEntry The new entry contents. 081 * @param mods The set of modifications that were applied to the entry. 082 * @param modifiedKeys The map into which the modified keys will be inserted. 083 * @throws DatabaseException If an error occurs in the JE database. 084 */ 085 public abstract void modifyEntry(Entry oldEntry, Entry newEntry, 086 List<Modification> mods, 087 Map<byte[], Boolean> modifiedKeys) 088 throws DatabaseException; 089 }