use of edu.uci.ics.textdb.api.field.DoubleField in project textdb by TextDB.
the class DictionaryMatcherTest method testSingleWordQueryInStringFieldUsingPhrase.
/**
* Scenario: verifies GetNextTuple of DictionaryMatcher and multiple word
* queries in String Field using PHRASEOPERATOR
*/
@Test
public void testSingleWordQueryInStringFieldUsingPhrase() throws Exception {
ArrayList<String> names = new ArrayList<String>(Arrays.asList("john Lee", "bruce"));
Dictionary dictionary = new Dictionary(names);
// create a data tuple first
List<Span> list1 = new ArrayList<Span>();
List<Span> list2 = new ArrayList<Span>();
Span span1 = new Span("lastName", 0, 8, "john Lee", "john Lee");
Span span2 = new Span("firstName", 0, 5, "bruce", "bruce");
list1.add(span1);
list2.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] = 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>(list1) };
Tuple tuple1 = new Tuple(new Schema(schemaAttributes), fields1);
IField[] fields2 = { 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>(list2) };
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.PHRASE_INDEXBASED);
boolean contains = TestUtils.equals(expectedResults, returnedResults);
Assert.assertTrue(contains);
}
use of edu.uci.ics.textdb.api.field.DoubleField in project textdb by TextDB.
the class TestConstantsRegexSplit method constructSamplePeopleTuples.
public static List<Tuple> constructSamplePeopleTuples() {
try {
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("banana") };
IField[] fields2 = { new StringField("tom hanks"), new StringField("cruise"), new IntegerField(45), new DoubleField(5.95), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1971")), new TextField("mississippi") };
Tuple tuple1 = new Tuple(SCHEMA_PEOPLE, fields1);
Tuple tuple2 = new Tuple(SCHEMA_PEOPLE, fields2);
return Arrays.asList(tuple1, tuple2);
} catch (ParseException e) {
// exception should not happen because we know the data is correct
e.printStackTrace();
return Arrays.asList();
}
}
use of edu.uci.ics.textdb.api.field.DoubleField in project textdb by TextDB.
the class SpanTupleTest method testGetters.
@Test
public void testGetters() throws ParseException {
// create data tuple first
Attribute[] attributes = new Attribute[TestConstants.ATTRIBUTES_PEOPLE.length + 1];
for (int count = 0; count < attributes.length - 1; count++) {
attributes[count] = TestConstants.ATTRIBUTES_PEOPLE[count];
}
attributes[attributes.length - 1] = SchemaConstants.SPAN_LIST_ATTRIBUTE;
List<IField> fields = new ArrayList<IField>(Arrays.asList(new IField[] { new StringField("bruce"), new StringField("lee"), new IntegerField(46), new DoubleField(5.50), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-14-1970")), new TextField("bruce was born in new york city and was grown up in los angeles") }));
IField spanField = createSpanListField();
fields.add(spanField);
spanTuple = new Tuple(new Schema(attributes), fields.toArray(new IField[fields.size()]));
IField spanFieldRetrieved = spanTuple.getField(SchemaConstants.SPAN_LIST);
Assert.assertTrue(spanFieldRetrieved instanceof ListField);
Assert.assertSame(spanField, spanFieldRetrieved);
}
use of edu.uci.ics.textdb.api.field.DoubleField in project textdb by TextDB.
the class JsonSerializationTest method testDoubleField.
@Test
public void testDoubleField() {
DoubleField doubleField = new DoubleField(11.11);
JsonNode jsonNode = TestUtils.testJsonSerialization(doubleField);
Assert.assertTrue(jsonNode.get(JsonConstants.FIELD_VALUE).isFloatingPointNumber());
}
Aggregations