Skip to content

Commit

Permalink
Iteration 2: Google format
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-tjones committed Sep 13, 2023
1 parent c348607 commit 6b21fab
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 37 deletions.
48 changes: 12 additions & 36 deletions src/main/java/net/snowflake/ingest/utils/ParameterProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ private void setParameterMap(Map<String, Object> parameterOverrides, Properties
MAX_CLIENT_LAG_ENABLED, MAX_CLIENT_LAG_ENABLED_DEFAULT, parameterOverrides, props);
}

/**
* @return Longest interval in milliseconds between buffer flushes
*/
/** @return Longest interval in milliseconds between buffer flushes */
public long getBufferFlushIntervalInMs() {
if (getMaxClientLagEnabled()) {
if (cachedBufferFlushIntervalMs != -1L) {
Expand Down Expand Up @@ -225,9 +223,7 @@ private boolean getMaxClientLagEnabled() {
return (val instanceof Boolean) ? (Boolean) val : false;
}

/**
* @return Time in milliseconds between checks to see if the buffer should be flushed
*/
/** @return Time in milliseconds between checks to see if the buffer should be flushed */
public long getBufferFlushCheckIntervalInMs() {
Object val =
this.parameterMap.getOrDefault(
Expand All @@ -238,9 +234,7 @@ public long getBufferFlushCheckIntervalInMs() {
return (long) val;
}

/**
* @return Duration in milliseconds to delay data insertion to the buffer when throttled
*/
/** @return Duration in milliseconds to delay data insertion to the buffer when throttled */
public long getInsertThrottleIntervalInMs() {
Object val =
this.parameterMap.getOrDefault(
Expand All @@ -251,9 +245,7 @@ public long getInsertThrottleIntervalInMs() {
return (long) val;
}

/**
* @return Percent of free total memory at which we throttle row inserts
*/
/** @return Percent of free total memory at which we throttle row inserts */
public int getInsertThrottleThresholdInPercentage() {
Object val =
this.parameterMap.getOrDefault(
Expand All @@ -265,9 +257,7 @@ public int getInsertThrottleThresholdInPercentage() {
return (int) val;
}

/**
* @return Absolute size in bytes of free total memory at which we throttle row inserts
*/
/** @return Absolute size in bytes of free total memory at which we throttle row inserts */
public int getInsertThrottleThresholdInBytes() {
Object val =
this.parameterMap.getOrDefault(
Expand All @@ -278,9 +268,7 @@ public int getInsertThrottleThresholdInBytes() {
return (int) val;
}

/**
* @return true if jmx metrics are enabled for a client
*/
/** @return true if jmx metrics are enabled for a client */
public boolean hasEnabledSnowpipeStreamingMetrics() {
Object val =
this.parameterMap.getOrDefault(
Expand All @@ -291,9 +279,7 @@ public boolean hasEnabledSnowpipeStreamingMetrics() {
return (boolean) val;
}

/**
* @return Blob format version
*/
/** @return Blob format version */
public Constants.BdecVersion getBlobFormatVersion() {
Object val = this.parameterMap.getOrDefault(BLOB_FORMAT_VERSION, BLOB_FORMAT_VERSION_DEFAULT);
if (val instanceof Constants.BdecVersion) {
Expand Down Expand Up @@ -322,9 +308,7 @@ public int getIOTimeCpuRatio() {
return (int) val;
}

/**
* @return the max retry count when waiting for a blob upload task to finish
*/
/** @return the max retry count when waiting for a blob upload task to finish */
public int getBlobUploadMaxRetryCount() {
Object val =
this.parameterMap.getOrDefault(
Expand All @@ -335,39 +319,31 @@ public int getBlobUploadMaxRetryCount() {
return (int) val;
}

/**
* @return The max memory limit in bytes
*/
/** @return The max memory limit in bytes */
public long getMaxMemoryLimitInBytes() {
Object val =
this.parameterMap.getOrDefault(
MAX_MEMORY_LIMIT_IN_BYTES, MAX_MEMORY_LIMIT_IN_BYTES_DEFAULT);
return (val instanceof String) ? Long.parseLong(val.toString()) : (long) val;
}

/**
* @return Return whether memory optimization for Parquet is enabled.
*/
/** @return Return whether memory optimization for Parquet is enabled. */
public boolean getEnableParquetInternalBuffering() {
Object val =
this.parameterMap.getOrDefault(
ENABLE_PARQUET_INTERNAL_BUFFERING, ENABLE_PARQUET_INTERNAL_BUFFERING_DEFAULT);
return (val instanceof String) ? Boolean.parseBoolean(val.toString()) : (boolean) val;
}

/**
* @return The max channel size in bytes
*/
/** @return The max channel size in bytes */
public long getMaxChannelSizeInBytes() {
Object val =
this.parameterMap.getOrDefault(
MAX_CHANNEL_SIZE_IN_BYTES, MAX_CHANNEL_SIZE_IN_BYTES_DEFAULT);
return (val instanceof String) ? Long.parseLong(val.toString()) : (long) val;
}

/**
* @return The max chunk size in bytes that could avoid OOM at server side
*/
/** @return The max chunk size in bytes that could avoid OOM at server side */
public long getMaxChunkSizeInBytes() {
Object val =
this.parameterMap.getOrDefault(MAX_CHUNK_SIZE_IN_BYTES, MAX_CHUNK_SIZE_IN_BYTES_DEFAULT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.Properties;
import net.snowflake.ingest.utils.ParameterProvider;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class ParameterProviderTest {
Expand Down Expand Up @@ -154,6 +153,7 @@ public void testMaxClientLagEnabledPluralTimeUnit() {
ParameterProvider parameterProvider = new ParameterProvider(parameterMap, prop);
Assert.assertEquals(2000, parameterProvider.getBufferFlushIntervalInMs());
}

@Test
public void testMaxClientLagEnabledMinuteTimeUnit() {
Properties prop = new Properties();
Expand Down

0 comments on commit 6b21fab

Please sign in to comment.