Skip to content

Commit

Permalink
Adding missing comments to public methods part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-jf committed Oct 17, 2024
1 parent d8e90a8 commit a936500
Show file tree
Hide file tree
Showing 26 changed files with 185 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/main/java/net/snowflake/client/core/ChunkDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ public interface ChunkDownloader {
* be blocked if the chunk is not ready to be consumed (a.k.a not loaded into memory yet)
*
* @return result chunk with data loaded
* @throws InterruptedException
* @throws SnowflakeSQLException
*/
SnowflakeResultChunk getNextChunkToConsume() throws InterruptedException, SnowflakeSQLException;

/**
* Terminate the chunk downloader, release all resources allocated
*
* @return metrics measuring downloader performance
* @throws InterruptedException
*/
DownloaderMetrics terminate() throws InterruptedException;
}
2 changes: 0 additions & 2 deletions src/main/java/net/snowflake/client/core/SFResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
/**
* Snowflake ResultSet implementation
*
* <p>
*
* @author jhuang
*/
public class SFResultSet extends SFJsonResultSet {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/snowflake/client/core/SFSqlInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static SFSqlInput unwrap(SQLInput sqlInput) {
*
* @param <T> the type of the class modeled by this Class object
* @param type Class representing the Java data type to convert the attribute to.
* @param tz timezone to consider.
* @return the attribute at the head of the stream as an {@code Object} in the Java programming
* language;{@code null} if the attribute is SQL {@code NULL}
* @exception SQLException if a database access error occurs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,20 @@ abstract class AbstractArrowVectorConverter implements ArrowVectorConverter {
/** Field names of the struct vectors used by timestamp */
public static final String FIELD_NAME_EPOCH = "epoch"; // seconds since epoch

/** Timezone index */
public static final String FIELD_NAME_TIME_ZONE_INDEX = "timezone"; // time zone index

/** Fraction in nanoseconds */
public static final String FIELD_NAME_FRACTION = "fraction"; // fraction in nanoseconds

/**
* Constructor
*
* @param logicalTypeStr snowflake logical type of the target arrow vector.
* @param valueVector value vector
* @param vectorIndex value index
* @param context DataConversionContext
*/
AbstractArrowVectorConverter(
String logicalTypeStr,
ValueVector valueVector,
Expand Down Expand Up @@ -153,6 +164,11 @@ public BigDecimal toBigDecimal(int index) throws SFException {
ErrorCode.INVALID_VALUE_CONVERT, logicalTypeStr, SnowflakeUtil.BIG_DECIMAL_STR, "");
}

/**
* True if should treat decimal as int type.
*
* @return true or false if decimal should be treated as int type.
*/
boolean shouldTreatDecimalAsInt() {
return shouldTreatDecimalAsInt;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,18 @@
import org.apache.arrow.vector.FieldVector;
import org.apache.arrow.vector.complex.ListVector;

/** Array type converter. */
public class ArrayConverter extends AbstractArrowVectorConverter {

private final ListVector vector;

/**
* Constructor
*
* @param valueVector ListVector
* @param vectorIndex vector index
* @param context DataConversionContext
*/
public ArrayConverter(ListVector valueVector, int vectorIndex, DataConversionContext context) {
super(SnowflakeType.ARRAY.name(), valueVector, vectorIndex, context);
this.vector = valueVector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface ArrowVectorConverter {
/**
* Set to true when time value should be displayed in wallclock time (no timezone offset)
*
* @param useSessionTimezone
* @param useSessionTimezone boolean value indicating if there is a timezone offset.
*/
void setUseSessionTimezone(boolean useSessionTimezone);

Expand Down Expand Up @@ -160,6 +160,8 @@ public interface ArrowVectorConverter {
Object toObject(int index) throws SFException;

/**
* Set to true if NTZ timestamp should be set to UTC
*
* @param isUTC true or false value of whether NTZ timestamp should be set to UTC
*/
void setTreatNTZAsUTC(boolean isUTC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ public class BigIntToFixedConverter extends AbstractArrowVectorConverter {

protected ByteBuffer byteBuf = ByteBuffer.allocate(BigIntVector.TYPE_WIDTH);

/**
* Constructor
*
* @param fieldVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
*/
public BigIntToFixedConverter(
ValueVector fieldVector, int columnIndex, DataConversionContext context) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@
import org.apache.arrow.vector.BigIntVector;
import org.apache.arrow.vector.ValueVector;

/** BigInt to Time type converter. */
public class BigIntToTimeConverter extends AbstractArrowVectorConverter {
private BigIntVector bigIntVector;
protected ByteBuffer byteBuf = ByteBuffer.allocate(BigIntVector.TYPE_WIDTH);

/**
* Constructor
*
* @param fieldVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
*/
public BigIntToTimeConverter(
ValueVector fieldVector, int columnIndex, DataConversionContext context) {
super(SnowflakeType.TIME.name(), fieldVector, columnIndex, context);
Expand Down Expand Up @@ -49,6 +57,15 @@ public Time toTime(int index) throws SFException {
}
}

/**
* Return the long value as a Time object.
*
* @param value long value to represent as Time
* @param scale the scale
* @param useSessionTimezone boolean indicating use of session timezone
* @return Time object representing the value
* @throws SFException invalid data conversion
*/
public static Time getTime(long value, int scale, boolean useSessionTimezone) throws SFException {
SFTime sfTime = SFTime.fromFractionalSeconds(value, scale);
Time ts =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ public class BigIntToTimestampLTZConverter extends AbstractArrowVectorConverter
private BigIntVector bigIntVector;
private ByteBuffer byteBuf = ByteBuffer.allocate(BigIntVector.TYPE_WIDTH);

/**
* Constructor
*
* @param fieldVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
*/
public BigIntToTimestampLTZConverter(
ValueVector fieldVector, int columnIndex, DataConversionContext context) {
super(SnowflakeType.TIMESTAMP_LTZ.name(), fieldVector, columnIndex, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ public class BigIntToTimestampNTZConverter extends AbstractArrowVectorConverter
private static final TimeZone NTZ = TimeZone.getTimeZone("UTC");
private ByteBuffer byteBuf = ByteBuffer.allocate(BigIntVector.TYPE_WIDTH);

/**
* Constructor
*
* @param fieldVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
*/
public BigIntToTimestampNTZConverter(
ValueVector fieldVector, int columnIndex, DataConversionContext context) {
super(SnowflakeType.TIMESTAMP_NTZ.name(), fieldVector, columnIndex, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
public class BitToBooleanConverter extends AbstractArrowVectorConverter {
private BitVector bitVector;

/**
* Constructor
*
* @param fieldVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
*/
public BitToBooleanConverter(
ValueVector fieldVector, int columnIndex, DataConversionContext context) {
super(SnowflakeType.BOOLEAN.name(), fieldVector, columnIndex, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ public DateConverter(ValueVector fieldVector, int columnIndex, DataConversionCon
this.useDateFormat = false;
}

/**
* Constructor
*
* @param fieldVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
* @param useDateFormat boolean indicates whether to use session timezone
*/
public DateConverter(
ValueVector fieldVector,
int columnIndex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@
public class DecimalToScaledFixedConverter extends AbstractArrowVectorConverter {
protected DecimalVector decimalVector;

/**
* Constructor
*
* @param fieldVector ValueVector
* @param vectorIndex vector index
* @param context DataConversionContext
*/
public DecimalToScaledFixedConverter(
ValueVector fieldVector, int vectorIndex, DataConversionContext context) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@
import org.apache.arrow.vector.Float8Vector;
import org.apache.arrow.vector.ValueVector;

/** Convert from Arrow Float8Vector to Real. */
public class DoubleToRealConverter extends AbstractArrowVectorConverter {
private Float8Vector float8Vector;
private ByteBuffer byteBuf = ByteBuffer.allocate(Float8Vector.TYPE_WIDTH);

/**
* Constructor
*
* @param fieldVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
*/
public DoubleToRealConverter(
ValueVector fieldVector, int columnIndex, DataConversionContext context) {
super(SnowflakeType.REAL.name(), fieldVector, columnIndex, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ public class IntToFixedConverter extends AbstractArrowVectorConverter {
protected int sfScale;
protected ByteBuffer byteBuf = ByteBuffer.allocate(IntVector.TYPE_WIDTH);

/**
* Constructor
*
* @param fieldVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
*/
public IntToFixedConverter(
ValueVector fieldVector, int columnIndex, DataConversionContext context) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@
import org.apache.arrow.vector.IntVector;
import org.apache.arrow.vector.ValueVector;

/** Convert from Arrow IntVector to Time. */
public class IntToTimeConverter extends AbstractArrowVectorConverter {
private IntVector intVector;
private ByteBuffer byteBuf = ByteBuffer.allocate(IntVector.TYPE_WIDTH);

/**
* Constructor
*
* @param fieldVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
*/
public IntToTimeConverter(
ValueVector fieldVector, int columnIndex, DataConversionContext context) {
super(SnowflakeType.TIME.name(), fieldVector, columnIndex, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,18 @@
import org.apache.arrow.vector.complex.MapVector;
import org.apache.arrow.vector.util.JsonStringHashMap;

/** Arrow MapVector converter. */
public class MapConverter extends AbstractArrowVectorConverter {

private final MapVector vector;

/**
* Constructor
*
* @param valueVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
*/
public MapConverter(MapVector valueVector, int columnIndex, DataConversionContext context) {
super(SnowflakeType.MAP.name(), valueVector, columnIndex, context);
this.vector = valueVector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ public class SmallIntToFixedConverter extends AbstractArrowVectorConverter {
protected SmallIntVector smallIntVector;
ByteBuffer byteBuf = ByteBuffer.allocate(SmallIntVector.TYPE_WIDTH);

/**
* Constructor
*
* @param fieldVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
*/
public SmallIntToFixedConverter(
ValueVector fieldVector, int columnIndex, DataConversionContext context) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ public class ThreeFieldStructToTimestampTZConverter extends AbstractArrowVectorC
private IntVector timeZoneIndices;
private TimeZone timeZone = TimeZone.getTimeZone("UTC");

/**
* Constructor
*
* @param fieldVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
*/
public ThreeFieldStructToTimestampTZConverter(
ValueVector fieldVector, int columnIndex, DataConversionContext context) {
super(SnowflakeType.TIMESTAMP_LTZ.name(), fieldVector, columnIndex, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ public class TinyIntToFixedConverter extends AbstractArrowVectorConverter {
protected TinyIntVector tinyIntVector;
protected int sfScale = 0;

/**
* Constructor
*
* @param fieldVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
*/
public TinyIntToFixedConverter(
ValueVector fieldVector, int columnIndex, DataConversionContext context) {
super(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public class TwoFieldStructToTimestampLTZConverter extends AbstractArrowVectorCo
private BigIntVector epochs;
private IntVector fractions;

/**
* Constructor
*
* @param fieldVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
*/
public TwoFieldStructToTimestampLTZConverter(
ValueVector fieldVector, int columnIndex, DataConversionContext context) {
super(SnowflakeType.TIMESTAMP_LTZ.name(), fieldVector, columnIndex, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ public class TwoFieldStructToTimestampNTZConverter extends AbstractArrowVectorCo

private static final TimeZone NTZ = TimeZone.getTimeZone("UTC");

/**
* Constructor
*
* @param fieldVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
*/
public TwoFieldStructToTimestampNTZConverter(
ValueVector fieldVector, int columnIndex, DataConversionContext context) {
super(SnowflakeType.TIMESTAMP_NTZ.name(), fieldVector, columnIndex, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@
import org.apache.arrow.vector.ValueVector;
import org.apache.arrow.vector.VarBinaryVector;

/** Converter from Arrow VarBinaryVector to Binary. */
public class VarBinaryToBinaryConverter extends AbstractArrowVectorConverter {
private VarBinaryVector varBinaryVector;

/**
* Constructor
*
* @param valueVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
*/
public VarBinaryToBinaryConverter(
ValueVector valueVector, int columnIndex, DataConversionContext context) {
super(SnowflakeType.BINARY.name(), valueVector, columnIndex, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
public class VarCharConverter extends AbstractArrowVectorConverter {
private VarCharVector varCharVector;

/**
* Constructor
*
* @param valueVector ValueVector
* @param columnIndex column index
* @param context DataConversionContext
*/
public VarCharConverter(ValueVector valueVector, int columnIndex, DataConversionContext context) {
super(SnowflakeType.TEXT.name(), valueVector, columnIndex, context);
this.varCharVector = (VarCharVector) valueVector;
Expand Down
Loading

0 comments on commit a936500

Please sign in to comment.