use of edu.uci.ics.textdb.api.field.IField in project textdb by TextDB.
the class ComparableMatcherTest method testDoubleMatching5.
/**
* Verifies the behavior of ComparableMatcher<Double> with matching type EQUAL_TO
*
* @throws Exception
*/
@Test
public void testDoubleMatching5() throws Exception {
// Prepare the query
double threshold = 6.10;
Attribute attribute = TestConstants.HEIGHT_ATTR;
String attributeName = attribute.getAttributeName();
ComparisonType matchingType = ComparisonType.EQUAL_TO;
// Perform the query
List<Tuple> returnedResults = getDoubleQueryResults(attributeName, matchingType, threshold);
IField[] fields1 = { new StringField("brad lie angelina"), new StringField("pitt"), new IntegerField(44), new DoubleField(6.10), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-12-1972")), new TextField("White Angry") };
List<Tuple> expectedResults = new ArrayList<>();
expectedResults.add(new Tuple(TestConstants.SCHEMA_PEOPLE, fields1));
// check the results
Assert.assertEquals(1, returnedResults.size());
Assert.assertTrue(TestUtils.equals(expectedResults, returnedResults));
}
use of edu.uci.ics.textdb.api.field.IField in project textdb by TextDB.
the class ComparableMatcherTest method testIntegerMatching2.
/**
* Verifies the behavior of ComparableMatcher<Integer> with matching type GREATER_THAN
*
* @throws Exception
*/
@Test
public void testIntegerMatching2() throws Exception {
// Prepare the query
int threshold = 45;
Attribute attribute = TestConstants.AGE_ATTR;
String attributeName = attribute.getAttributeName();
ComparisonType matchingType = ComparisonType.GREATER_THAN;
// Perform the query
List<Tuple> returnedResults = getIntegerQueryResults(attributeName, matchingType, threshold);
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") };
List<Tuple> expectedResults = new ArrayList<>();
expectedResults.add(new Tuple(TestConstants.SCHEMA_PEOPLE, fields1));
// check the results
Assert.assertEquals(1, returnedResults.size());
Assert.assertTrue(TestUtils.equals(expectedResults, returnedResults));
}
use of edu.uci.ics.textdb.api.field.IField in project textdb by TextDB.
the class ComparableMatcherTest method testIntegerMatching4.
/**
* Verifies the behavior of ComparableMatcher<Integer> with matching type LESS_THAN_OR_EQAUL_TO
*
* @throws Exception
*/
@Test
public void testIntegerMatching4() throws Exception {
// Prepare the query
int threshold = 43;
Attribute attribute = TestConstants.AGE_ATTR;
String attributeName = attribute.getAttributeName();
ComparisonType matchingType = ComparisonType.LESS_THAN_OR_EQUAL_TO;
// Perform the query
List<Tuple> returnedResults = getIntegerQueryResults(attributeName, matchingType, threshold);
IField[] fields1 = { new StringField("george lin lin"), new StringField("lin clooney"), new IntegerField(43), new DoubleField(6.06), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1973")), new TextField("Lin Clooney is Short and lin clooney is Angry") };
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") };
IField[] fields3 = { new StringField("Mary brown"), new StringField("Lake Forest"), new IntegerField(42), new DoubleField(5.99), new DateField(new SimpleDateFormat("MM-dd-yyyy").parse("01-13-1974")), new TextField("Short angry") };
List<Tuple> expectedResults = new ArrayList<>();
expectedResults.add(new Tuple(TestConstants.SCHEMA_PEOPLE, fields1));
expectedResults.add(new Tuple(TestConstants.SCHEMA_PEOPLE, fields2));
expectedResults.add(new Tuple(TestConstants.SCHEMA_PEOPLE, fields3));
// check the results
Assert.assertEquals(3, returnedResults.size());
Assert.assertTrue(TestUtils.equals(expectedResults, returnedResults));
}
use of edu.uci.ics.textdb.api.field.IField in project textdb by TextDB.
the class RelationManager method getTableAnalyzerString.
/**
* Gets the Lucene analyzer string of a table.
*
* @param tableName, the name of the table, case insensitive
* @return
* @throws StorageException
*/
public String getTableAnalyzerString(String tableName) throws StorageException {
// get the tuples with tableName from the table catalog
Tuple tableCatalogTuple = getTableCatalogTuple(tableName);
// if the tuple is not found, then the table name is not found
if (tableCatalogTuple == null) {
throw new StorageException(String.format("The analyzer for table %s is not found.", tableName));
}
// get the lucene analyzer string
IField analyzerField = tableCatalogTuple.getField(CatalogConstants.TABLE_LUCENE_ANALYZER);
String analyzerString = analyzerField.getValue().toString();
return analyzerString;
}
use of edu.uci.ics.textdb.api.field.IField in project textdb by TextDB.
the class DataReader method documentToFields.
private ArrayList<IField> documentToFields(Document luceneDocument) throws ParseException {
ArrayList<IField> fields = new ArrayList<>();
for (Attribute attr : inputSchema.getAttributes()) {
AttributeType attributeType = attr.getAttributeType();
String fieldValue = luceneDocument.get(attr.getAttributeName());
fields.add(StorageUtils.getField(attributeType, fieldValue));
}
return fields;
}
Aggregations