use of edu.uci.ics.textdb.api.exception.StorageException in project textdb by TextDB.
the class MedlineIndexWriter method writeMedlineIndex.
public static void writeMedlineIndex(Path medlineFilepath, String tableName) throws IOException, StorageException, ParseException {
RelationManager relationManager = RelationManager.getRelationManager();
DataWriter dataWriter = relationManager.getTableDataWriter(tableName);
dataWriter.open();
BufferedReader reader = Files.newBufferedReader(medlineFilepath);
String line;
while ((line = reader.readLine()) != null) {
try {
dataWriter.insertTuple(recordToTuple(line));
} catch (Exception e) {
e.printStackTrace();
}
}
reader.close();
dataWriter.close();
}
use of edu.uci.ics.textdb.api.exception.StorageException in project textdb by TextDB.
the class DataReader method getNextTuple.
@Override
public Tuple getNextTuple() throws StorageException {
if (cursor == CLOSED) {
throw new StorageException(ErrorMessages.OPERATOR_NOT_OPENED);
}
Tuple resultTuple;
try {
if (cursor >= scoreDocs.length) {
return null;
}
int docID = scoreDocs[cursor].doc;
resultTuple = constructTuple(docID);
} catch (IOException | ParseException e) {
throw new StorageException(e.getMessage(), e);
}
cursor++;
return resultTuple;
}
use of edu.uci.ics.textdb.api.exception.StorageException in project textdb by TextDB.
the class DataReader method open.
@Override
public void open() throws StorageException {
if (cursor != CLOSED) {
return;
}
try {
String indexDirectoryStr = this.dataStore.getDataDirectory();
Directory indexDirectory = FSDirectory.open(Paths.get(indexDirectoryStr));
luceneIndexReader = DirectoryReader.open(indexDirectory);
luceneIndexSearcher = new IndexSearcher(luceneIndexReader);
TopDocs topDocs = luceneIndexSearcher.search(query, Integer.MAX_VALUE);
scoreDocs = topDocs.scoreDocs;
inputSchema = this.dataStore.getSchema();
if (payloadAdded) {
outputSchema = Utils.addAttributeToSchema(inputSchema, SchemaConstants.PAYLOAD_ATTRIBUTE);
} else {
outputSchema = inputSchema;
}
} catch (IOException e) {
throw new StorageException(e.getMessage(), e);
}
cursor = OPENED;
}
use of edu.uci.ics.textdb.api.exception.StorageException in project textdb by TextDB.
the class DataWriter method open.
public void open() throws StorageException {
if (this.luceneIndexWriter == null || !this.luceneIndexWriter.isOpen()) {
try {
Directory directory = FSDirectory.open(Paths.get(this.indexDirectory));
IndexWriterConfig conf = new IndexWriterConfig(analyzer);
this.luceneIndexWriter = new IndexWriter(directory, conf);
this.isOpen = true;
} catch (IOException e) {
throw new StorageException(e.getMessage(), e);
}
}
}
use of edu.uci.ics.textdb.api.exception.StorageException in project textdb by TextDB.
the class RelationManager method initializeCatalog.
/*
* Initializes the system catalog tables.
*/
private void initializeCatalog() throws StorageException {
try {
// create table catalog
writeTableInfoToCatalog(CatalogConstants.TABLE_CATALOG.toLowerCase(), new File(CatalogConstants.TABLE_CATALOG_DIRECTORY).getCanonicalPath(), CatalogConstants.TABLE_CATALOG_SCHEMA, LuceneAnalyzerConstants.standardAnalyzerString());
// create schema catalog
writeTableInfoToCatalog(CatalogConstants.SCHEMA_CATALOG.toLowerCase(), new File(CatalogConstants.SCHEMA_CATALOG_DIRECTORY).getCanonicalPath(), CatalogConstants.SCHEMA_CATALOG_SCHEMA, LuceneAnalyzerConstants.standardAnalyzerString());
} catch (IOException e) {
throw new StorageException(e);
}
}
Aggregations