use of edu.uci.ics.textdb.storage.RelationManager in project textdb by TextDB.
the class ScanBasedSourceOperatorTest method setUp.
@BeforeClass
public static void setUp() throws TextDBException {
RelationManager relationManager = RelationManager.getRelationManager();
// create the people table and write tuples
relationManager.createTable(PEOPLE_TABLE, "../index/test_tables/" + PEOPLE_TABLE, TestConstants.SCHEMA_PEOPLE, LuceneAnalyzerConstants.standardAnalyzerString());
DataWriter peopleDataWriter = relationManager.getTableDataWriter(PEOPLE_TABLE);
peopleDataWriter.open();
for (Tuple tuple : TestConstants.getSamplePeopleTuples()) {
peopleDataWriter.insertTuple(tuple);
}
peopleDataWriter.close();
}
use of edu.uci.ics.textdb.storage.RelationManager in project textdb by TextDB.
the class SampleExtraction method writeSampleIndex.
public static void writeSampleIndex() throws Exception {
// parse the original file
File sourceFileFolder = new File(promedFilesDirectory);
ArrayList<Tuple> fileTuples = new ArrayList<>();
for (File htmlFile : sourceFileFolder.listFiles()) {
StringBuilder sb = new StringBuilder();
Scanner scanner = new Scanner(htmlFile);
while (scanner.hasNext()) {
sb.append(scanner.nextLine());
}
scanner.close();
Tuple tuple = parsePromedHTML(htmlFile.getName(), sb.toString());
if (tuple != null) {
fileTuples.add(tuple);
}
}
// write tuples into the table
RelationManager relationManager = RelationManager.getRelationManager();
relationManager.deleteTable(PROMED_SAMPLE_TABLE);
relationManager.createTable(PROMED_SAMPLE_TABLE, promedIndexDirectory, PromedSchema.PROMED_SCHEMA, LuceneAnalyzerConstants.standardAnalyzerString());
DataWriter dataWriter = relationManager.getTableDataWriter(PROMED_SAMPLE_TABLE);
dataWriter.open();
for (Tuple tuple : fileTuples) {
dataWriter.insertTuple(tuple);
}
dataWriter.close();
}
use of edu.uci.ics.textdb.storage.RelationManager in project textdb by TextDB.
the class KeywordTestHelper method deleteTestTables.
public static void deleteTestTables() throws TextDBException {
RelationManager relationManager = RelationManager.getRelationManager();
relationManager.deleteTable(PEOPLE_TABLE);
relationManager.deleteTable(MEDLINE_TABLE);
relationManager.deleteTable(CHINESE_TABLE);
}
use of edu.uci.ics.textdb.storage.RelationManager in project textdb by TextDB.
the class KeywordTestHelper method writeTestTables.
public static void writeTestTables() throws TextDBException {
RelationManager relationManager = RelationManager.getRelationManager();
// create the people table and write tuples
relationManager.createTable(PEOPLE_TABLE, "../index/test_tables/" + PEOPLE_TABLE, TestConstants.SCHEMA_PEOPLE, LuceneAnalyzerConstants.standardAnalyzerString());
DataWriter peopleDataWriter = relationManager.getTableDataWriter(PEOPLE_TABLE);
peopleDataWriter.open();
for (Tuple tuple : TestConstants.getSamplePeopleTuples()) {
peopleDataWriter.insertTuple(tuple);
}
peopleDataWriter.close();
// create the medline table and write tuples
relationManager.createTable(MEDLINE_TABLE, "../index/test_tables/" + MEDLINE_TABLE, keywordTestConstants.SCHEMA_MEDLINE, LuceneAnalyzerConstants.standardAnalyzerString());
DataWriter medDataWriter = relationManager.getTableDataWriter(MEDLINE_TABLE);
medDataWriter.open();
for (Tuple tuple : keywordTestConstants.getSampleMedlineRecord()) {
medDataWriter.insertTuple(tuple);
}
medDataWriter.close();
// create the people table and write tuples in Chinese
relationManager.createTable(CHINESE_TABLE, "../index/test_tables/" + CHINESE_TABLE, TestConstantsChinese.SCHEMA_PEOPLE, LuceneAnalyzerConstants.chineseAnalyzerString());
DataWriter chineseDataWriter = relationManager.getTableDataWriter(CHINESE_TABLE);
chineseDataWriter.open();
for (Tuple tuple : TestConstantsChinese.getSamplePeopleTuples()) {
chineseDataWriter.insertTuple(tuple);
}
chineseDataWriter.close();
}
use of edu.uci.ics.textdb.storage.RelationManager in project textdb by TextDB.
the class KeywordTestHelper method getScanSourceResults.
public static List<Tuple> getScanSourceResults(String tableName, String keywordQuery, List<String> attributeNames, KeywordMatchingType matchingType, int limit, int offset) throws TextDBException {
RelationManager relationManager = RelationManager.getRelationManager();
ScanBasedSourceOperator scanSource = new ScanBasedSourceOperator(new ScanSourcePredicate(tableName));
KeywordPredicate keywordPredicate = new KeywordPredicate(keywordQuery, attributeNames, relationManager.getTableAnalyzerString(tableName), matchingType, RESULTS, limit, offset);
KeywordMatcher keywordMatcher = new KeywordMatcher(keywordPredicate);
keywordMatcher.setInputOperator(scanSource);
Tuple tuple;
List<Tuple> results = new ArrayList<>();
keywordMatcher.open();
while ((tuple = keywordMatcher.getNextTuple()) != null) {
results.add(tuple);
}
keywordMatcher.close();
return results;
}
Aggregations