[
https://issues.apache.org/jira/browse/TAJO-1730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14730471#comment-14730471
]
ASF GitHub Bot commented on TAJO-1730:
--------------------------------------
Github user hyunsik commented on a diff in the pull request:
https://github.com/apache/tajo/pull/719#discussion_r38728599
--- Diff:
tajo-storage/tajo-storage-jdbc/src/main/java/org/apache/tajo/storage/jdbc/JdbcScanner.java
---
@@ -0,0 +1,313 @@
+/**
+ * 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 org.apache.tajo.storage.jdbc;
+
+import com.google.common.base.Preconditions;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.catalog.Schema;
+import org.apache.tajo.catalog.TableMeta;
+import org.apache.tajo.catalog.statistics.TableStats;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.TimeDatum;
+import org.apache.tajo.exception.TajoInternalError;
+import org.apache.tajo.exception.TajoRuntimeException;
+import org.apache.tajo.exception.UnsupportedDataTypeException;
+import org.apache.tajo.exception.UnsupportedException;
+import org.apache.tajo.plan.expr.EvalNode;
+import org.apache.tajo.plan.logical.LogicalNode;
+import org.apache.tajo.storage.Scanner;
+import org.apache.tajo.storage.Tuple;
+import org.apache.tajo.storage.VTuple;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.sql.*;
+import java.util.Iterator;
+
+public abstract class JdbcScanner implements Scanner {
+ private static final Log LOG = LogFactory.getLog(JdbcScanner.class);
+
+ protected final DatabaseMetaData dbMetaData;
+ protected final String tableName;
+ protected final Schema schema;
+ protected final TableMeta tableMeta;
+ protected final JdbcFragment fragment;
+ protected final TableStats stats;
+ protected final SQLBuilder builder;
+
+ protected Column [] targets;
+ protected EvalNode filter;
+ protected Long limit;
+ protected LogicalNode planPart;
+ protected VTuple outTuple;
+ protected String generatedSql;
+ protected ResultSetIterator iter;
+
+ public JdbcScanner(final DatabaseMetaData dbMetaData,
+ final Schema tableSchema,
+ final TableMeta tableMeta,
+ final JdbcFragment fragment) {
+
+ Preconditions.checkNotNull(dbMetaData);
+ Preconditions.checkNotNull(tableSchema);
+ Preconditions.checkNotNull(tableMeta);
+ Preconditions.checkNotNull(fragment);
+
+ this.dbMetaData = dbMetaData;
+ this.tableName = ConnectionInfo.fromURI(fragment.getUri()).tableName;
+ this.schema = tableSchema;
+ this.tableMeta = tableMeta;
+ this.fragment = fragment;
+ this.stats = new TableStats();
+ builder = getSQLBuilder(getSQLExprBuilder());
+ }
+
+ @Override
+ public void init() throws IOException {
+ if (targets == null) {
+ targets = schema.toArray();
+ }
+ outTuple = new VTuple(targets.length);
+
+ if (planPart == null) {
+ generatedSql = builder.build(tableName, targets, filter, limit);
+ } else {
+ generatedSql = builder.build(planPart);
+ }
+ }
+
+ @Override
+ public Tuple next() throws IOException {
+ if (iter == null) {
+ iter = executeQueryAndGetIter();
+ }
+
+ if (iter.hasNext()) {
+ return iter.next();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void reset() throws IOException {
+ if (iter != null) {
+ iter.rewind();
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (iter != null) {
+ iter.close();
+ }
+ }
+
+ @Override
+ public void pushOperators(LogicalNode planPart) {
+ this.planPart = planPart;
+ }
+
+
+ @Override
+ public boolean isProjectable() {
+ return true;
+ }
+
+ @Override
+ public void setTarget(Column [] targets) {
+ this.targets = targets;
+ }
+
+ @Override
+ public boolean isSelectable() {
+ return true;
+ }
+
+ @Override
+ public void setFilter(EvalNode filter) {
+ this.filter = filter;
+ }
+
+ @Override
+ public void setLimit(long num) {
+ this.limit = num;
+ }
+
+ @Override
+ public boolean isSplittable() {
+ return false;
+ }
+
+ @Override
+ public float getProgress() {
+ return 0;
+ }
+
+ @Override
+ public TableStats getInputStats() {
+ return stats;
+ }
+
+ @Override
+ public Schema getSchema() {
+ return schema;
+ }
+
+ protected SQLBuilder getSQLBuilder(SQLExpressionGenerator exprBuilder) {
+ return new SQLBuilder(dbMetaData, getSQLExprBuilder());
--- End diff --
Thanks!
> JDBC Tablespace support
> -----------------------
>
> Key: TAJO-1730
> URL: https://issues.apache.org/jira/browse/TAJO-1730
> Project: Tajo
> Issue Type: Improvement
> Components: Storage
> Reporter: Hyunsik Choi
> Assignee: Hyunsik Choi
> Fix For: 0.11.0
>
> Attachments: TAJO-1730.patch, TAJO-1730_2.patch, TAJO-1730_3.patch
>
>
> The main objective of this issue is to implement JDBC-based storage and its
> Tablespace implementation.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)