use of edu.uci.ics.texera.api.schema.Schema in project textdb by TextDB.
the class FileSourceOperatorTest method test1.
/*
* Test FileSourceOperator with a single "txt" file.
* Optional parameters are all set to default.
*/
@Test
public void test1() throws Exception {
String attrName = "content";
Schema schema = new Schema(new Attribute(attrName, AttributeType.TEXT));
FileSourcePredicate predicate = new FileSourcePredicate(tempFile1Path.toString(), attrName);
FileSourceOperator fileSource = new FileSourceOperator(predicate);
Tuple tuple;
ArrayList<Tuple> exactResults = new ArrayList<>();
fileSource.open();
while ((tuple = fileSource.getNextTuple()) != null) {
exactResults.add(tuple);
}
fileSource.close();
List<Tuple> expectedResults = Arrays.asList(new Tuple(schema, new TextField(tempFile1String)));
Assert.assertTrue(TestUtils.equals(expectedResults, exactResults));
}
use of edu.uci.ics.texera.api.schema.Schema in project textdb by TextDB.
the class FileSourceOperatorTest method test3.
/*
* Test FileSourceOperator with a Directory with recursive = true and maxDepth = null.
*
* All the files under the recursive sub-directories will be read.
*
* expected results: test1.txt, test2.txt, test4.txt and test5.txt will be included
*/
@Test
public void test3() throws Exception {
String attrName = "content";
Schema schema = new Schema(new Attribute(attrName, AttributeType.TEXT));
FileSourcePredicate predicate = new FileSourcePredicate(tempFolderPath.toString(), attrName, true, null);
FileSourceOperator fileSource = new FileSourceOperator(predicate);
Tuple tuple;
ArrayList<Tuple> exactResults = new ArrayList<>();
fileSource.open();
while ((tuple = fileSource.getNextTuple()) != null) {
exactResults.add(tuple);
}
fileSource.close();
List<Tuple> expectedResults = Arrays.asList(new Tuple(schema, new TextField(tempFile1String)), new Tuple(schema, new TextField(tempFile2String)), new Tuple(schema, new TextField(tempFile4String)), new Tuple(schema, new TextField(tempFile5String)));
Assert.assertTrue(TestUtils.equals(expectedResults, exactResults));
}
use of edu.uci.ics.texera.api.schema.Schema in project textdb by TextDB.
the class FileSourceOperatorTest method test2.
/*
* Test FileSourceOperator with a Directory.
* Optional parameters are all set to default. (only list files directly in this folder)
*
* Only the files directly under this directory will be used.
*
* expected results: test1.txt and test2.txt will be included.
*/
@Test
public void test2() throws Exception {
String attrName = "content";
Schema schema = new Schema(new Attribute(attrName, AttributeType.TEXT));
FileSourcePredicate predicate = new FileSourcePredicate(tempFolderPath.toString(), attrName);
FileSourceOperator fileSource = new FileSourceOperator(predicate);
Tuple tuple;
ArrayList<Tuple> exactResults = new ArrayList<>();
fileSource.open();
while ((tuple = fileSource.getNextTuple()) != null) {
exactResults.add(tuple);
}
fileSource.close();
List<Tuple> expectedResults = Arrays.asList(new Tuple(schema, new TextField(tempFile1String)), new Tuple(schema, new TextField(tempFile2String)));
Assert.assertTrue(TestUtils.equals(expectedResults, exactResults));
}
use of edu.uci.ics.texera.api.schema.Schema in project textdb by TextDB.
the class TupleSourceOperatorTest method test1.
@Test
public void test1() throws TexeraException {
TupleSourceOperator tupleSource = new TupleSourceOperator(TestConstants.getSamplePeopleTuples(), TestConstants.SCHEMA_PEOPLE);
tupleSource.open();
Tuple tuple;
List<Tuple> results = new ArrayList<>();
Schema outputSchema = tupleSource.getOutputSchema();
while ((tuple = tupleSource.getNextTuple()) != null) {
results.add(tuple);
}
tupleSource.close();
// assert result is equal to input
Assert.assertTrue(TestUtils.equals(TestConstants.getSamplePeopleTuples(), results));
// assert _id is added to schema
Assert.assertTrue(outputSchema.equals(new Schema.Builder().add(SchemaConstants._ID_ATTRIBUTE).add(TestConstants.SCHEMA_PEOPLE).build()));
// assert all tuples contain _id field
for (Tuple resultTuple : results) {
Assert.assertTrue(resultTuple.getField(SchemaConstants._ID).getClass().equals(IDField.class));
}
}
use of edu.uci.ics.texera.api.schema.Schema in project textdb by TextDB.
the class RelationManager method getTableDataStore.
/**
* Gets the DataStore(directory and schema) of a table.
*
* @param tableName, the name of the table, case insensitive
* @return
* @throws StorageException
*/
public DataStore getTableDataStore(String tableName) throws StorageException {
String tableDirectory = getTableDirectory(tableName);
Schema tableSchema = getTableSchema(tableName);
return new DataStore(tableDirectory, tableSchema);
}
Aggregations