Skip to content

Commit

Permalink
extending AbstractJdbcResultSet
Browse files Browse the repository at this point in the history
  • Loading branch information
prash-mi committed Sep 9, 2021
1 parent 504a750 commit e35ad7d
Showing 1 changed file with 172 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
package com.google.cloud.bigquery;

import com.google.api.services.bigquery.model.TableRow;
import java.sql.SQLException;
import java.io.InputStream;
import java.io.Reader;
import java.math.BigDecimal;
import java.sql.*;
import java.util.Map;
import java.util.concurrent.BlockingQueue;

// TODO: This implementation deals with the JSON response. We can have respective implementations
// for Apache Arrow and Avro?
public class BigQueryResultSetImpl<T> implements BigQueryResultSet<T> {
public class BigQueryResultSetImpl<T> extends AbstractJdbcResultSet
implements BigQueryResultSet<T> {

private final Schema schema;
private final long totalRows;
Expand All @@ -32,23 +35,13 @@ public class BigQueryResultSetImpl<T> implements BigQueryResultSet<T> {
private final BlockingQueue<T> buffer; // TableRow
private T cursor;

/*public BigQueryResultSetImpl(
Schema schema,
long totalRows,
ResultSet nextRow) { // TODO - Delete this constructor if required
this.schema = schema;
this.totalRows = totalRows;
this.nextRow = nextRow;
this.nameType = null;
}*/

// TODO : Implement a wrapper/struct like spanner
public BigQueryResultSetImpl(
Schema schema, long totalRows, Map<String, String> nameType, BlockingQueue<T> buffer) {
this.schema = schema;
this.totalRows = totalRows;
this.nameType = nameType;
this.buffer = buffer;
// this.nextRow = null; // TODO - Delete as required
}

@Override
Expand Down Expand Up @@ -81,7 +74,8 @@ public boolean next() throws SQLException {
return true;
}

private Object getObject(String fieldName) throws SQLException {
@Override
public Object getObject(String fieldName) throws SQLException {
if (cursor instanceof TableRow) {
TableRow currentRow = (TableRow) cursor;
if (currentRow == null) {
Expand All @@ -103,6 +97,169 @@ public String getString(String fieldName) throws SQLException {
}
}

/** ****TODO Methods - to be impemented****** */
@Override
public long getLong(String columnLabel) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public float getFloat(String columnLabel) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public double getDouble(String columnLabel) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public void close() throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public boolean wasNull() throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public String getString(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public boolean getBoolean(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public byte getByte(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public short getShort(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public int getInt(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public long getLong(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public float getFloat(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public double getDouble(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public byte[] getBytes(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public Date getDate(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public Time getTime(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public Timestamp getTimestamp(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public InputStream getAsciiStream(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public InputStream getUnicodeStream(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public InputStream getBinaryStream(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public int findColumn(String columnLabel) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public Reader getCharacterStream(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public Reader getCharacterStream(String columnLabel) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

/*
TODO: Create methods to meet the following signature?
while(resultSet.next()) {
Expand Down

0 comments on commit e35ad7d

Please sign in to comment.