use of edu.uci.ics.texera.storage.RelationManager in project textdb by TextDB.
the class JoinTestHelper method insertToTable.
public static void insertToTable(String tableName, List<Tuple> tuples) throws StorageException {
RelationManager relationManager = RelationManager.getInstance();
DataWriter outerDataWriter = relationManager.getTableDataWriter(tableName);
outerDataWriter.open();
for (Tuple tuple : tuples) {
outerDataWriter.insertTuple(tuple);
}
outerDataWriter.close();
}
use of edu.uci.ics.texera.storage.RelationManager in project textdb by TextDB.
the class JoinTestHelper method createTestTables.
public static void createTestTables() throws TexeraException {
RelationManager relationManager = RelationManager.getInstance();
// create the book table
relationManager.createTable(BOOK_TABLE, TestUtils.getDefaultTestIndex().resolve(BOOK_TABLE), JoinTestConstants.BOOK_SCHEMA, LuceneAnalyzerConstants.standardAnalyzerString());
// data for the book table are written in each test cases
// create the news table
relationManager.createTable(NEWS_TABLE_OUTER, TestUtils.getDefaultTestIndex().resolve(NEWS_TABLE_OUTER), JoinTestConstants.NEWS_SCHEMA, LuceneAnalyzerConstants.standardAnalyzerString());
relationManager.createTable(NEWS_TABLE_INNER, TestUtils.getDefaultTestIndex().resolve(NEWS_TABLE_INNER), JoinTestConstants.NEWS_SCHEMA, LuceneAnalyzerConstants.standardAnalyzerString());
}
use of edu.uci.ics.texera.storage.RelationManager in project textdb by TextDB.
the class SamplerTest method setUp.
@BeforeClass
public static void setUp() throws TexeraException {
RelationManager relationManager = RelationManager.getInstance();
// Create the people table and write tuples
RelationManager.getInstance().deleteTable(SAMPLER_TABLE);
relationManager.createTable(SAMPLER_TABLE, TestUtils.getDefaultTestIndex().resolve(SAMPLER_TABLE), TestConstants.SCHEMA_PEOPLE, LuceneAnalyzerConstants.standardAnalyzerString());
DataWriter dataWriter = relationManager.getTableDataWriter(SAMPLER_TABLE);
dataWriter.open();
indexSize = 0;
for (Tuple tuple : TestConstants.getSamplePeopleTuples()) {
dataWriter.insertTuple(tuple);
indexSize++;
}
dataWriter.close();
}
use of edu.uci.ics.texera.storage.RelationManager in project textdb by TextDB.
the class WordCountTest method setUp.
@BeforeClass
public static void setUp() throws TexeraException {
cleanUp();
RelationManager relationManager = RelationManager.getInstance();
// Create the people table and write tuples
relationManager.createTable(COUNT_TABLE, TestUtils.getDefaultTestIndex().resolve(COUNT_TABLE), TestConstants.SCHEMA_PEOPLE, LuceneAnalyzerConstants.standardAnalyzerString());
DataWriter dataWriter = relationManager.getTableDataWriter(COUNT_TABLE);
dataWriter.open();
for (Tuple tuple : TestConstants.getSamplePeopleTuples()) {
dataWriter.insertTuple(tuple);
}
dataWriter.close();
expectedResult = computeExpectedResult(TestConstants.getSamplePeopleTuples(), TestConstants.DESCRIPTION, LuceneAnalyzerConstants.getStandardAnalyzer());
relationManager.createTable(COUNT_CHINESE_TABLE, TestUtils.getDefaultTestIndex().resolve(COUNT_CHINESE_TABLE), TestConstantsChineseWordCount.SCHEMA_PEOPLE, LuceneAnalyzerConstants.chineseAnalyzerString());
DataWriter dataWriterChinese = relationManager.getTableDataWriter(COUNT_CHINESE_TABLE);
dataWriterChinese.open();
for (Tuple tuple : TestConstantsChineseWordCount.getSamplePeopleTuples()) {
dataWriterChinese.insertTuple(tuple);
}
dataWriterChinese.close();
expectedResultChinese = computeExpectedResult(TestConstantsChineseWordCount.getSamplePeopleTuples(), TestConstantsChineseWordCount.DESCRIPTION, LuceneAnalyzerConstants.getLuceneAnalyzer(LuceneAnalyzerConstants.chineseAnalyzerString()));
}
use of edu.uci.ics.texera.storage.RelationManager in project textdb by TextDB.
the class PerfTestUtils method writeIndex.
/**
* Writes a data file into an index
*
* @param fileName,
* data file
* @param luceneAnalyzer
* @param indexType,
* indicates the types of index, trigram or standard
* @throws Exception
*/
public static void writeIndex(String fileName, Analyzer luceneAnalyzer, String indexType) throws Exception {
RelationManager relationManager = RelationManager.getInstance();
String tableName = fileName.replace(".txt", "");
if (indexType.equalsIgnoreCase("trigram")) {
tableName = tableName + "_trigram";
relationManager.deleteTable(tableName);
relationManager.createTable(tableName, getTrigramIndexPath(tableName), MedlineIndexWriter.SCHEMA_MEDLINE, LuceneAnalyzerConstants.nGramAnalyzerString(3));
MedlineIndexWriter.writeMedlineIndex(Paths.get(fileFolder, fileName), tableName);
} else if (indexType.equalsIgnoreCase("standard")) {
relationManager.deleteTable(tableName);
relationManager.createTable(tableName, getIndexPath(tableName), MedlineIndexWriter.SCHEMA_MEDLINE, LuceneAnalyzerConstants.standardAnalyzerString());
MedlineIndexWriter.writeMedlineIndex(Paths.get(fileFolder, fileName), tableName);
} else {
System.out.println("Index is not successfully written.");
System.out.println("IndexType has to be either \"standard\" or \"trigram\" ");
}
}
Aggregations