001: /*
002: * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
003: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
004: */
005:
006: package com.sun.portal.search.db;
007:
008: import com.sun.portal.search.soif.*;
009: import com.sun.portal.search.rdm.*;
010:
011: import java.util.*;
012:
013: /**
014: *
015: * SOIF Database API
016: *
017: * <p>- handles SOIF db i/o
018: * <p>- provides a template for similar, non-SOIF layers, eg, XML, etc.
019: * <p>- hides db implementation details (eg, db might not really contain SOIF)
020: * <p>- hides the mechanics of P/NP data
021: */
022: public interface RDMDb {
023:
024: /**
025: * Database constants
026: */
027:
028: /* BDB dependency */
029: public static final int DB_NEXT = com.sleepycat.db.Db.DB_NEXT;
030:
031: /* BDB dependency */
032: public static final int DB_NOTFOUND = com.sleepycat.db.Db.DB_NOTFOUND;
033:
034: /**
035: * open flags
036: *
037: * READER open db read only
038: * WRITER open db read/write
039: * WRCREAT open db read/write/create
040: *
041: * access function flags - search(), fetch(), store(), etc
042: *
043: * PONLY handle persistent data (P) only (default is a merge with P covering NP)
044: * NPONLY handle non-persistent data (NP) only
045: * NOMERGE don't do P/NP merge for indexing
046: * NOSTATS skip stats/plugins
047: * NOINDEX skip search engine indexing
048: * NOSTORE skip database insertion (index only)
049: */
050: public static final int READER = 0x00000001;
051: public static final int WRITER = 0x00000002;
052: public static final int WRCREAT = 0x00000004;
053: public static final int PONLY = 0x01000000;
054: public static final int NPONLY = 0x02000000;
055: public static final int NOMERGE = 0x04000000;
056: public static final int NOSTATS = 0x08000000;
057: public static final int NOINDEX = 0x10000000;
058: public static final int NOSTORE = 0x20000000;
059:
060: /**
061: * Submit the query to the search engine
062: * @param st Token for search
063: * @param qry Search query
064: * @param numHits Number of hits
065: * @param view Set of attributes to be retrieved
066: * @param sortOrder Order for sorting the results
067: * @param t RDM transaction handle
068: * @return RDMResultSet
069: * @throws RDMException
070: */
071: public RDMResultSet search(SToken st, String qry, int numHits,
072: Set View, String sortOrder, RDMTransaction t)
073: throws RDMException;
074:
075: /**
076: * Retrieve a SOIF from database, filtered by view
077: * @param st Token for search
078: * @param url URL string
079: * @param view Set of Attributes
080: * @param flags Options
081: * @param t RDM transaction
082: * @throws RDMException
083: */
084: public SOIF fetch(SToken st, String url, Set view, int flags,
085: RDMTransaction t) throws RDMException;
086:
087: /**
088: * Store a SOIF- creates a transaction for atomic indexing, if none supplied.
089: * @param st Token for search
090: * @param soif SOIF document
091: * @param view Set of Attributes
092: * @param flags Options
093: * @param t RDM transaction
094: * @throws RDMException
095: */
096: public void store(SToken st, SOIF soif, Set view, int flags,
097: RDMTransaction t) throws RDMException;
098:
099: /**
100: * Update a SOIF with attributes set in View
101: * @param st Token for search
102: * @param soif SOIF document
103: * @param view Set of Attributes
104: * @param flags Options
105: * @param t RDM transaction
106: * @throws RDMException
107: */
108: public void update(SToken st, SOIF soif, Set view, int flags,
109: RDMTransaction t) throws RDMException;
110:
111: /**
112: * Delete a SOIF from database
113: * @param st Token for search
114: * @param soif SOIF document
115: * @param view Set of attributes
116: * @param flags Options
117: * @param t RDM transaction handle
118: * @throws RDMException
119: */
120: public void delete(SToken st, SOIF soif, Set view, int flags,
121: RDMTransaction t) throws RDMException;
122:
123: /**
124: * Number of documents in the search result
125: * @param st Token for search
126: * @param t RDM transaction handle
127: * @return search count
128: * @throws RDMException
129: */
130: public int count(SToken st, RDMTransaction t) throws RDMException;
131:
132: /**
133: * Empty the database
134: * @param st Token for search
135: * @param t RDM transaction handle
136: * @throws RDMException
137: */
138: public int purge(SToken st, RDMTransaction t) throws RDMException;
139:
140: /**
141: * Optimize the db
142: * @param st Token for search
143: * @throws RDMException
144: */
145: public void optimize(SToken st) throws RDMException;
146:
147: /**
148: * Recover the db - must be run stand alone (ie, no one else has the db open)
149: * @param st Token for search
150: * @param dbhome Database home dir
151: * @param fatal Option
152: * @throws RDMException
153: */
154: public void recover(SToken st, String dbhome, boolean fatal)
155: throws RDMException;
156:
157: /**
158: * Open a database
159: * @param st Token for search
160: * @param rootdir Database home dir
161: * @param dbname Name of database from root database
162: * @param rw RDMDb.WRITER or RDMDb.WRCREAT or RDMDb.READER
163: * @param mode Unix mode
164: * @throws RDMException
165: */
166: public void open(SToken st, String rootdir, String dbname, int rw,
167: int mode) throws RDMException;
168:
169: /**
170: * Close database and index extents
171: * @param st Token for search
172: * @throws RDMException
173: */
174: public void close(SToken st) throws RDMException;
175:
176: /**
177: * Batch Index, should be part of db config, perhaps with a progress callback
178: * @param st Token for search
179: * @throws RDMException
180: */
181: public void indexBatch(SToken st) throws RDMException;
182:
183: }
|