com.datatorrent.lib.streamquery.AbstractSqlStreamOperator Maven / Gradle / Ivy
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.datatorrent.lib.streamquery;
import java.util.ArrayList;
import java.util.HashMap;
import com.datatorrent.api.DefaultInputPort;
import com.datatorrent.api.DefaultOutputPort;
import com.datatorrent.api.annotation.InputPortFieldAnnotation;
import com.datatorrent.api.annotation.OutputPortFieldAnnotation;
import com.datatorrent.common.util.BaseOperator;
/**
* A base implementation of a BaseOperator that is a sql stream operator. Subclasses should provide the
implementation of how to process the tuples.
*
* Abstract sql db input operator.
*
* @displayName Abstract Sql Stream
* @category Stream Manipulators
* @tags sql operator
* @since 0.3.2
*/
public abstract class AbstractSqlStreamOperator extends BaseOperator
{
public static class InputSchema
{
public static class ColumnInfo
{
public String type;
public int bindIndex = 0;
public boolean isColumnIndex = false;
}
/**
* the name of the input "table"
*/
public String name;
/**
* key is the name of the column, and value is the SQL type
*/
public HashMap columnInfoMap = new HashMap();
public InputSchema()
{
}
public InputSchema(String name)
{
this.name = name;
}
public void setColumnInfo(String columnName, String columnType, boolean isColumnIndex)
{
ColumnInfo t = new ColumnInfo();
t.type = columnType;
t.isColumnIndex = isColumnIndex;
columnInfoMap.put(columnName, t);
}
}
protected String statement;
protected ArrayList inputSchemas = new ArrayList(5);
protected transient ArrayList