Search in sources :

Example 81 with IntegerField

use of edu.uci.ics.texera.api.field.IntegerField in project textdb by TextDB.

the class WordCloudSinkTestConstants method getResultTuples.

public static List<Tuple> getResultTuples() {
    IField[] fields1 = { new StringField("foo"), new IntegerField(200) };
    IField[] fields2 = { new StringField("amy"), new IntegerField(100) };
    IField[] fields3 = { new StringField("bob"), new IntegerField(50) };
    Tuple tuple1 = new Tuple(WORD_CLOUD_RESULT_SCHEMA, fields1);
    Tuple tuple2 = new Tuple(WORD_CLOUD_RESULT_SCHEMA, fields2);
    Tuple tuple3 = new Tuple(WORD_CLOUD_RESULT_SCHEMA, fields3);
    return Arrays.asList(tuple1, tuple2, tuple3);
}
Also used : StringField(edu.uci.ics.texera.api.field.StringField) IntegerField(edu.uci.ics.texera.api.field.IntegerField) IField(edu.uci.ics.texera.api.field.IField) Tuple(edu.uci.ics.texera.api.tuple.Tuple)

Example 82 with IntegerField

use of edu.uci.ics.texera.api.field.IntegerField in project textdb by TextDB.

the class WordCloudSinkTestConstants method getTuples.

public static List<Tuple> getTuples() {
    IField[] fields1 = { new TextField("foo foo"), new IntegerField(2000) };
    IField[] fields2 = { new TextField("foo foo"), new IntegerField(1200) };
    IField[] fields3 = { new TextField("amy amy"), new IntegerField(1000) };
    IField[] fields4 = { new TextField("bob the a in into this"), new IntegerField(500) };
    Tuple tuple1 = new Tuple(WORD_CLOUD_SCHEMA, fields1);
    Tuple tuple2 = new Tuple(WORD_CLOUD_SCHEMA, fields2);
    Tuple tuple3 = new Tuple(WORD_CLOUD_SCHEMA, fields3);
    Tuple tuple4 = new Tuple(WORD_CLOUD_SCHEMA, fields4);
    return Arrays.asList(tuple1, tuple2, tuple3, tuple4);
}
Also used : TextField(edu.uci.ics.texera.api.field.TextField) IntegerField(edu.uci.ics.texera.api.field.IntegerField) IField(edu.uci.ics.texera.api.field.IField) Tuple(edu.uci.ics.texera.api.tuple.Tuple)

Example 83 with IntegerField

use of edu.uci.ics.texera.api.field.IntegerField in project textdb by TextDB.

the class CatalogConstants method getSchemaCatalogTuples.

/**
 * Gets the tuples to be inserted to the schema catalog.
 *
 * @param tableName
 * @param tableDirectory
 * @param luceneAnalyzerStr
 * @return
 * @throws StorageException
 */
public static List<Tuple> getSchemaCatalogTuples(String tableName, Schema tableSchema) {
    List<Tuple> schemaCatalogTuples = new ArrayList<>();
    for (int i = 0; i < tableSchema.getAttributes().size(); i++) {
        Attribute attr = tableSchema.getAttributes().get(i);
        Tuple schemaTuple = new Tuple(SCHEMA_CATALOG_SCHEMA, new StringField(tableName), new StringField(attr.getName()), new StringField(attr.getType().toString().toLowerCase()), new IntegerField(i));
        schemaCatalogTuples.add(schemaTuple);
    }
    return schemaCatalogTuples;
}
Also used : Attribute(edu.uci.ics.texera.api.schema.Attribute) StringField(edu.uci.ics.texera.api.field.StringField) ArrayList(java.util.ArrayList) IntegerField(edu.uci.ics.texera.api.field.IntegerField) Tuple(edu.uci.ics.texera.api.tuple.Tuple)

Example 84 with IntegerField

use of edu.uci.ics.texera.api.field.IntegerField in project textdb by TextDB.

the class WordCountIndexSource method computeNextMatchingTuple.

private Tuple computeNextMatchingTuple() throws TexeraException {
    if (sortedWordCountMap == null) {
        computeWordCount();
    }
    if (wordCountIterator.hasNext()) {
        Entry<String, Integer> entry = wordCountIterator.next();
        List<IField> tupleFieldList = new ArrayList<>();
        // Generate the new UUID.
        tupleFieldList.add(IDField.newRandomID());
        tupleFieldList.add(new StringField(entry.getKey()));
        tupleFieldList.add(new IntegerField(entry.getValue()));
        cursor++;
        return new Tuple(SCHEMA_WORD_COUNT, tupleFieldList);
    }
    return null;
}
Also used : StringField(edu.uci.ics.texera.api.field.StringField) ArrayList(java.util.ArrayList) IntegerField(edu.uci.ics.texera.api.field.IntegerField) IField(edu.uci.ics.texera.api.field.IField) Tuple(edu.uci.ics.texera.api.tuple.Tuple)

Example 85 with IntegerField

use of edu.uci.ics.texera.api.field.IntegerField in project textdb by TextDB.

the class AggregatorTest method testCountHeightAggregation.

// TEST 4: Find count in height column
@Test
public void testCountHeightAggregation() throws Exception {
    Attribute attribute = TestConstants.HEIGHT_ATTR;
    String attributeName = attribute.getName();
    AggregationType aggType = AggregationType.COUNT;
    String resultAttributeName = AggregatorTestConstants.COUNT_HEIGHT_RESULT_ATTR_NAME;
    AggregationAttributeAndResult aggEntity = new AggregationAttributeAndResult(attributeName, aggType, resultAttributeName);
    List<AggregationAttributeAndResult> aggEntitiesList = new ArrayList<>();
    aggEntitiesList.add(aggEntity);
    IField[] row1 = { new IntegerField(6) };
    Schema schema = new Schema(new Attribute(resultAttributeName, AttributeType.INTEGER));
    List<Tuple> expectedResults = new ArrayList<>();
    expectedResults.add(new Tuple(schema, row1));
    List<Tuple> returnedResults = getQueryResults(aggEntitiesList);
    Assert.assertEquals(1, returnedResults.size());
    Assert.assertTrue(TestUtils.equals(expectedResults, returnedResults));
}
Also used : Attribute(edu.uci.ics.texera.api.schema.Attribute) Schema(edu.uci.ics.texera.api.schema.Schema) ArrayList(java.util.ArrayList) IntegerField(edu.uci.ics.texera.api.field.IntegerField) IField(edu.uci.ics.texera.api.field.IField) Tuple(edu.uci.ics.texera.api.tuple.Tuple) Test(org.junit.Test)

Aggregations

IntegerField (edu.uci.ics.texera.api.field.IntegerField)98 Tuple (edu.uci.ics.texera.api.tuple.Tuple)90 IField (edu.uci.ics.texera.api.field.IField)88 StringField (edu.uci.ics.texera.api.field.StringField)87 TextField (edu.uci.ics.texera.api.field.TextField)79 ArrayList (java.util.ArrayList)75 Schema (edu.uci.ics.texera.api.schema.Schema)72 Test (org.junit.Test)70 Span (edu.uci.ics.texera.api.span.Span)66 DoubleField (edu.uci.ics.texera.api.field.DoubleField)65 DateField (edu.uci.ics.texera.api.field.DateField)59 SimpleDateFormat (java.text.SimpleDateFormat)57 Attribute (edu.uci.ics.texera.api.schema.Attribute)56 Dictionary (edu.uci.ics.texera.dataflow.dictionarymatcher.Dictionary)29 JoinDistancePredicate (edu.uci.ics.texera.dataflow.join.JoinDistancePredicate)9 KeywordMatcherSourceOperator (edu.uci.ics.texera.dataflow.keywordmatcher.KeywordMatcherSourceOperator)9 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 IOperator (edu.uci.ics.texera.api.dataflow.IOperator)4 DateTimeField (edu.uci.ics.texera.api.field.DateTimeField)3