use of edu.uci.ics.texera.api.field.StringField in project textdb by TextDB.
the class MysqlSinkTest method test2TupleInsertion.
/**
* Create two tuples, insert into mysql
* @throws ParseException
*/
public void test2TupleInsertion() throws Exception {
ArrayList<String> attributeNames = new ArrayList<>();
attributeNames.add(TestConstants.FIRST_NAME);
attributeNames.add(TestConstants.LAST_NAME);
attributeNames.add(TestConstants.DESCRIPTION);
// Prepare the expected result list
List<Span> list = new ArrayList<>();
Span span1 = new Span("firstName", 0, 5, "bruce", "bruce");
Span span2 = new Span("lastnName", 0, 5, "jacki", "jacki");
list.add(span1);
list.add(span2);
Attribute[] schemaAttributes = new Attribute[TestConstants.ATTRIBUTES_PEOPLE.length + 1];
for (int count = 0; count < schemaAttributes.length - 1; count++) {
schemaAttributes[count] = TestConstants.ATTRIBUTES_PEOPLE[count];
}
schemaAttributes[schemaAttributes.length - 1] = SchemaConstants.SPAN_LIST_ATTRIBUTE;
IField[] fields1 = { new StringField("bruce"), new StringField("john Lee"), new IntegerField(46), new DoubleField(5.50), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-14-1970")), new TextField("Tall Angry"), new ListField<>(list) };
IField[] fields2 = { new StringField("test"), new StringField("jackie chan"), new IntegerField(0), new DoubleField(6.0), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("09-18-1994")), new TextField("Angry Bird"), new ListField<>(list) };
Tuple tuple1 = new Tuple(new Schema(schemaAttributes), fields1);
Tuple tuple2 = new Tuple(new Schema(schemaAttributes), fields2);
IOperator localInputOperator = Mockito.mock(IOperator.class);
Mockito.when(localInputOperator.getOutputSchema()).thenReturn(new Schema(schemaAttributes)).thenReturn(null);
Mockito.when(localInputOperator.getNextTuple()).thenReturn(tuple1).thenReturn(tuple2).thenReturn(null);
mysqlSink.setInputOperator(localInputOperator);
mysqlSink.open();
mysqlSink.processTuples();
mysqlSink.close();
}
use of edu.uci.ics.texera.api.field.StringField in project textdb by TextDB.
the class BarChartSinkTestConstants method getTuples.
public static List<Tuple> getTuples() {
IField[] fields1 = { new IntegerField(1), new StringField("Tom"), new IntegerField(90), new StringField("M") };
IField[] fields2 = { new IntegerField(2), new StringField("Jerry"), new IntegerField(80), new StringField("M") };
IField[] fields3 = { new IntegerField(3), new StringField("Bob"), new IntegerField(70), new StringField("M") };
Tuple tuple1 = new Tuple(BAR_SCHEMA, fields1);
Tuple tuple2 = new Tuple(BAR_SCHEMA, fields2);
Tuple tuple3 = new Tuple(BAR_SCHEMA, fields3);
return Arrays.asList(tuple1, tuple2, tuple3);
}
use of edu.uci.ics.texera.api.field.StringField in project textdb by TextDB.
the class LineChartSinkTestConstants method getResultTuples.
public static List<Tuple> getResultTuples() {
IField[] fields1 = { new StringField("Tom"), new IntegerField(90) };
IField[] fields2 = { new StringField("Jerry"), new IntegerField(80) };
IField[] fields3 = { new StringField("Bob"), new IntegerField(70) };
Tuple tuple1 = new Tuple(BAR_RESULT_SCHEMA, fields1);
Tuple tuple2 = new Tuple(BAR_RESULT_SCHEMA, fields2);
Tuple tuple3 = new Tuple(BAR_RESULT_SCHEMA, fields3);
return Arrays.asList(tuple1, tuple2, tuple3);
}
use of edu.uci.ics.texera.api.field.StringField in project textdb by TextDB.
the class DictionaryMatcherTest method testSingleWordQueryInTextFieldUsingKeyword.
/**
* Scenario: verifies GetNextTuple of DictionaryMatcher and single word
* queries in Text Field using KEYWORD OPERATOR
*/
@Test
public void testSingleWordQueryInTextFieldUsingKeyword() throws Exception {
ArrayList<String> names = new ArrayList<String>(Arrays.asList("tall"));
Dictionary dictionary = new Dictionary(names);
// create a data tuple first
List<Span> list = new ArrayList<Span>();
Span span = new Span("description", 0, 4, "tall", "Tall", 0);
list.add(span);
Attribute[] schemaAttributes = new Attribute[TestConstants.ATTRIBUTES_PEOPLE.length + 1];
for (int count = 0; count < schemaAttributes.length - 1; count++) {
schemaAttributes[count] = TestConstants.ATTRIBUTES_PEOPLE[count];
}
schemaAttributes[schemaAttributes.length - 1] = RESULTS_ATTRIBUTE;
IField[] fields1 = { new StringField("bruce"), new StringField("john Lee"), new IntegerField(46), new DoubleField(5.50), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-14-1970")), new TextField("Tall Angry"), new ListField<Span>(list) };
IField[] fields2 = { new StringField("christian john wayne"), new StringField("rock bale"), new IntegerField(42), new DoubleField(5.99), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1974")), new TextField("Tall Fair"), new ListField<Span>(list) };
Tuple tuple1 = new Tuple(new Schema(schemaAttributes), fields1);
Tuple tuple2 = new Tuple(new Schema(schemaAttributes), fields2);
List<Tuple> expectedResults = new ArrayList<Tuple>();
expectedResults.add(tuple1);
expectedResults.add(tuple2);
List<String> attributeNames = Arrays.asList(TestConstants.FIRST_NAME, TestConstants.LAST_NAME, TestConstants.DESCRIPTION);
List<Tuple> returnedResults = DictionaryMatcherTestHelper.getQueryResults(PEOPLE_TABLE, dictionary, attributeNames, KeywordMatchingType.CONJUNCTION_INDEXBASED);
boolean contains = TestUtils.equals(expectedResults, returnedResults);
Assert.assertTrue(contains);
}
use of edu.uci.ics.texera.api.field.StringField in project textdb by TextDB.
the class DictionaryMatcherTest method testMultipleWordsQueryUsingKeywordChinese.
/**
* Scenario: verifies ITuple returned by DictionaryMatcher and multiple
* word queries using KEYWORD OPERATOR
*/
@Test
public void testMultipleWordsQueryUsingKeywordChinese() throws Exception {
ArrayList<String> names = new ArrayList<String>(Arrays.asList("洛克贝尔"));
Dictionary dictionary = new Dictionary(names);
// create a data tuple first
List<Span> list = new ArrayList<Span>();
Span span = new Span("lastName", 0, 4, "洛克贝尔", "洛克贝尔");
;
list.add(span);
Attribute[] schemaAttributes = new Attribute[TestConstantsChinese.ATTRIBUTES_PEOPLE.length + 1];
for (int count = 0; count < schemaAttributes.length - 1; count++) {
schemaAttributes[count] = TestConstantsChinese.ATTRIBUTES_PEOPLE[count];
}
schemaAttributes[schemaAttributes.length - 1] = RESULTS_ATTRIBUTE;
IField[] fields1 = { new StringField("孔明"), new StringField("洛克贝尔"), new IntegerField(42), new DoubleField(5.99), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1974")), new TextField("北京大学计算机学院"), new ListField<Span>(list) };
Tuple tuple1 = new Tuple(new Schema(schemaAttributes), fields1);
List<Tuple> expectedResults = new ArrayList<Tuple>();
expectedResults.add(tuple1);
List<String> attributeNames = Arrays.asList(TestConstantsChinese.FIRST_NAME, TestConstantsChinese.LAST_NAME, TestConstantsChinese.DESCRIPTION);
List<Tuple> returnedResults = DictionaryMatcherTestHelper.getQueryResults(CHINESE_TABLE, dictionary, attributeNames, KeywordMatchingType.CONJUNCTION_INDEXBASED);
boolean contains = TestUtils.equals(expectedResults, returnedResults);
Assert.assertTrue(contains);
}
Aggregations