code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public void upload(Map<String, ParameterBindingDTO> bindValues) throws BindException
{
if (!closed)
{
serializeBinds(bindValues);
putBinds();
}
} | java |
private void serializeBinds(Map<String, ParameterBindingDTO> bindValues) throws BindException
{
List<ColumnTypeDataPair> columns = getColumnValues(bindValues);
List<String[]> rows = buildRows(columns);
writeRowsToCSV(rows);
} | java |
private List<ColumnTypeDataPair> getColumnValues(Map<String, ParameterBindingDTO> bindValues) throws BindException
{
List<ColumnTypeDataPair> columns = new ArrayList<>(bindValues.size());
for (int i = 1; i <= bindValues.size(); i++)
{
// bindValues should have n entries with string keys 1 ... n and ... | java |
private List<String[]> buildRows(List<ColumnTypeDataPair> columns) throws BindException
{
List<String[]> rows = new ArrayList<>();
int numColumns = columns.size();
// columns should have binds
if (columns.get(0).data.isEmpty())
{
throw new BindException("No binds found in first column", Bin... | java |
private void writeRowsToCSV(List<String[]> rows) throws BindException
{
int numBytes;
int rowNum = 0;
int fileCount = 0;
while (rowNum < rows.size())
{
File file = getFile(++fileCount);
try (OutputStream out = openFile(file))
{
// until we reach the last row or the file... | java |
private OutputStream openFile(File file) throws BindException
{
try
{
return new GZIPOutputStream(new FileOutputStream(file));
}
catch (IOException ex)
{
throw new BindException(
String.format("Failed to create output file %s: %s", file.toString(), ex.getMessage()), BindExcep... | java |
private byte[] createCSVRecord(String[] data)
{
StringBuilder sb = new StringBuilder(1024);
for (int i = 0; i < data.length; ++i)
{
if (i > 0)
{
sb.append(',');
}
sb.append(SnowflakeType.escapeForCSV(data[i]));
}
sb.append('\n');
return sb.toString().getBytes(U... | java |
private String getPutStmt(String bindDir, String stagePath)
{
return String.format(PUT_STMT, bindDir, File.separator, stagePath)
.replaceAll("\\\\", "\\\\\\\\");
} | java |
private void putBinds() throws BindException
{
createStageIfNeeded();
String putStatement = getPutStmt(bindDir.toString(), stagePath);
for (int i = 0; i < PUT_RETRY_COUNT; i++)
{
try
{
SFStatement statement = new SFStatement(session);
SFBaseResultSet putResult = statement... | java |
private void createStageIfNeeded() throws BindException
{
if (session.getArrayBindStage() != null)
{
return;
}
synchronized (session)
{
// another thread may have created the session by the time we enter this block
if (session.getArrayBindStage() == null)
{
try
... | java |
public static int arrayBindValueCount(Map<String, ParameterBindingDTO> bindValues)
{
if (!isArrayBind(bindValues))
{
return 0;
}
else
{
ParameterBindingDTO bindSample = bindValues.values().iterator().next();
List<String> bindSampleValues = (List<String>) bindSample.getValue();
... | java |
public static boolean isArrayBind(Map<String, ParameterBindingDTO> bindValues)
{
if (bindValues == null || bindValues.size() == 0)
{
return false;
}
ParameterBindingDTO bindSample = bindValues.values().iterator().next();
return bindSample.getValue() instanceof List;
} | java |
public static StorageObjectSummary createFromS3ObjectSummary(S3ObjectSummary objSummary)
{
return new StorageObjectSummary(
objSummary.getBucketName(),
objSummary.getKey(),
// S3 ETag is not always MD5, but since this code path is only
// used in skip duplicate files in PUT comman... | java |
public static StorageObjectSummary createFromAzureListBlobItem(ListBlobItem listBlobItem)
throws StorageProviderException
{
String location, key, md5;
long size;
// Retrieve the BLOB properties that we need for the Summary
// Azure Storage stores metadata inside each BLOB, therefore the listBlobIte... | java |
private boolean isSnowflakeAuthenticator()
{
String authenticator = (String) connectionPropertiesMap.get(
SFSessionProperty.AUTHENTICATOR);
PrivateKey privateKey = (PrivateKey) connectionPropertiesMap.get(
SFSessionProperty.PRIVATE_KEY);
return (authenticator == null && privateKey == nul... | java |
boolean isExternalbrowserAuthenticator()
{
String authenticator = (String) connectionPropertiesMap.get(
SFSessionProperty.AUTHENTICATOR);
return ClientAuthnDTO.AuthenticatorType.EXTERNALBROWSER.name()
.equalsIgnoreCase(authenticator);
} | java |
synchronized void renewSession(String prevSessionToken)
throws SFException, SnowflakeSQLException
{
if (sessionToken != null &&
!sessionToken.equals(prevSessionToken))
{
logger.debug("not renew session because session token has not been updated.");
return;
}
SessionUtil.LoginInp... | java |
protected void startHeartbeatForThisSession()
{
if (enableHeartbeat && !Strings.isNullOrEmpty(masterToken))
{
logger.debug("start heartbeat, master token validity: " +
masterTokenValidityInSeconds);
HeartbeatBackground.getInstance().addSession(this,
... | java |
protected void stopHeartbeatForThisSession()
{
if (enableHeartbeat && !Strings.isNullOrEmpty(masterToken))
{
logger.debug("stop heartbeat");
HeartbeatBackground.getInstance().removeSession(this);
}
else
{
logger.debug("heartbeat not enabled for the session");
}
} | java |
protected void heartbeat() throws SFException, SQLException
{
logger.debug(" public void heartbeat()");
if (isClosed)
{
return;
}
HttpPost postRequest = null;
String requestId = UUID.randomUUID().toString();
boolean retry = false;
// the loop for retrying if it runs into ses... | java |
void setCurrentObjects(
SessionUtil.LoginInput loginInput, SessionUtil.LoginOutput loginOutput)
{
this.sessionToken = loginOutput.sessionToken; // used to run the commands.
runInternalCommand(
"USE ROLE IDENTIFIER(?)", loginInput.getRole());
runInternalCommand(
"USE WAREHOUSE IDENTIF... | java |
private void executeImmediate(String stmtText) throws SQLException
{
// execute the statement and auto-close it as well
try (final Statement statement = this.createStatement())
{
statement.execute(stmtText);
}
} | java |
@Override
public Statement createStatement() throws SQLException
{
raiseSQLExceptionIfConnectionIsClosed();
Statement stmt = createStatement(
ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_READ_ONLY);
openStatements.add(stmt);
return stmt;
} | java |
@Override
public void setTransactionIsolation(int level) throws SQLException
{
logger.debug(
"void setTransactionIsolation(int level), level = {}", level);
raiseSQLExceptionIfConnectionIsClosed();
if (level == Connection.TRANSACTION_NONE
|| level == Connection.TRANSACTION_READ_COMMITTED)... | java |
public InputStream downloadStream(String stageName, String sourceFileName,
boolean decompress) throws SQLException
{
logger.debug("download data to stream: stageName={}" +
", sourceFileName={}",
stageName, sourceFileName);
if (Strings.isN... | java |
public static InputStream decryptStream(InputStream inputStream,
String keyBase64,
String ivBase64,
RemoteStoreFileEncryptionMaterial encMat)
throws NoSuchPaddingException, NoSuchAlgorithmExce... | java |
synchronized void startFlusher()
{
// Create a new scheduled executor service with a threadfactory that
// creates daemonized threads; this way if the user doesn't exit nicely
// the JVM Runtime won't hang
flusher =
Executors.newScheduledThreadPool(1,
n... | java |
public void dumpLogBuffer(String identifier)
{
final ArrayList<LogRecord> logBufferCopy;
final PrintWriter logDumper;
final OutputStream outStream;
Formatter formatter = this.getFormatter();
// Check if compression of dump file is enabled
boolean disableCompression =
System.getPropert... | java |
protected void cleanupSfDumps(boolean deleteOldest)
{
// Check what the maximum number of dumpfiles and the max allowable
// aggregate dump file size is.
int maxDumpFiles =
System.getProperty(MAX_NUM_DUMP_FILES_PROP) != null ?
Integer.valueOf(System.getProperty(MAX_NUM_DUMP_FILES_PROP)) :
... | java |
private synchronized boolean needsToThrottle(String signature)
{
AtomicInteger sigCount;
// Are we already throttling this signature?
if (throttledIncidents.containsKey(signature))
{
// Lazily check if it's time to unthrottle
if (throttledIncidents.get(signature).plusHours(THROTTLE_DURATI... | java |
@Override
public void start()
{
LOGGER.debug("Start Loading");
// validate parameters
validateParameters();
if (_op == null)
{
this.abort(new ConnectionError("Loader started with no operation"));
return;
}
initDateFormats();
initQueues();
if (_is_first_start_call)... | java |
private void flushQueues()
{
// Terminate data loading thread.
LOGGER.debug("Flush Queues");
try
{
_queueData.put(new byte[0]);
_thread.join(10000);
if (_thread.isAlive())
{
_thread.interrupt();
}
}
catch (Exception ex)
{
String msg = "Failed to... | java |
@Override
public void resetOperation(Operation op)
{
LOGGER.debug("Reset Loader");
if (op.equals(_op))
{
//no-op
return;
}
LOGGER.debug("Operation is changing from {} to {}", _op, op);
_op = op;
if (_stage != null)
{
try
{
queuePut(_stage);
}
... | java |
void overrideCacheFile(File newCacheFile)
{
this.cacheFile = newCacheFile;
this.cacheDir = newCacheFile.getParentFile();
this.baseCacheFileName = newCacheFile.getName();
} | java |
JsonNode readCacheFile()
{
if (cacheFile == null || !this.checkCacheLockFile())
{
// no cache or the cache is not valid.
return null;
}
try
{
if (!cacheFile.exists())
{
LOGGER.debug(
"Cache file doesn't exists. File: {}", cacheFile);
return null;... | java |
private boolean tryLockCacheFile()
{
int cnt = 0;
boolean locked = false;
while (cnt < 100 && !(locked = lockCacheFile()))
{
try
{
Thread.sleep(100);
}
catch (InterruptedException ex)
{
// doesn't matter
}
++cnt;
}
if (!locked)
{
... | java |
private void verifyLocalFilePath(String localFilePathFromGS)
throws SnowflakeSQLException
{
if (command == null)
{
logger.error("null command");
return;
}
if (command.indexOf(FILE_PROTOCOL) < 0)
{
logger.error(
"file:// prefix not found in command: {}", command);
... | java |
private void uploadStream() throws SnowflakeSQLException
{
try
{
threadExecutor = SnowflakeUtil.createDefaultExecutorService(
"sf-stream-upload-worker-", 1);
RemoteStoreFileEncryptionMaterial encMat = encryptionMaterial.get(0);
if (commandType == CommandType.UPLOAD)
{
... | java |
InputStream downloadStream(String fileName) throws SnowflakeSQLException
{
if (stageInfo.getStageType() == StageInfo.StageType.LOCAL_FS)
{
logger.error("downloadStream function doesn't support local file system");
throw new SnowflakeSQLException(SqlState.INTERNAL_ERROR,
... | java |
private void downloadFiles() throws SnowflakeSQLException
{
try
{
threadExecutor = SnowflakeUtil.createDefaultExecutorService(
"sf-file-download-worker-", 1);
for (String srcFile : sourceFiles)
{
FileMetadata fileMetadata = fileMetadataMap.get(srcFile);
// Check i... | java |
private void uploadFiles(Set<String> fileList,
int parallel) throws SnowflakeSQLException
{
try
{
threadExecutor = SnowflakeUtil.createDefaultExecutorService(
"sf-file-upload-worker-", parallel);
for (String srcFile : fileList)
{
FileMetadata fil... | java |
static public Set<String> expandFileNames(String[] filePathList)
throws SnowflakeSQLException
{
Set<String> result = new HashSet<String>();
// a location to file pattern map so that we only need to list the
// same directory once when they appear in multiple times.
Map<String, List<String>> locatio... | java |
private FileCompressionType mimeTypeToCompressionType(String mimeTypeStr)
throws MimeTypeParseException
{
MimeType mimeType = null;
if (mimeTypeStr != null)
{
mimeType = new MimeType(mimeTypeStr);
}
if (mimeType != null && mimeType.getSubType() != null)
{
return FileCompression... | java |
private String getMimeTypeFromFileExtension(String srcFile)
{
String srcFileLowCase = srcFile.toLowerCase();
for (FileCompressionType compressionType : FileCompressionType.values())
{
if (srcFileLowCase.endsWith(compressionType.fileExtension))
{
return compressionType.mimeType + "/" +... | java |
static public remoteLocation extractLocationAndPath(String stageLocationPath)
{
String location = stageLocationPath;
String path = "";
// split stage location as location name and path
if (stageLocationPath.contains("/"))
{
location = stageLocationPath.substring(0, stageLocationPath.indexOf... | java |
@Override
public List<SnowflakeColumnMetadata> describeColumns() throws Exception
{
return SnowflakeUtil.describeFixedViewColumns(
commandType == CommandType.UPLOAD ?
(showEncryptionParameter ?
UploadCommandEncryptionFacade.class : UploadCommandFacade.class) :
(showEncryptionPar... | java |
private void populateStatusRows()
{
for (Map.Entry<String, FileMetadata> entry : fileMetadataMap.entrySet())
{
FileMetadata fileMetadata = entry.getValue();
if (commandType == CommandType.UPLOAD)
{
statusRows.add(showEncryptionParameter ?
new UploadCommandEncr... | java |
@Override
public void flush()
{
ObjectMapper mapper = ObjectMapperFactory.getObjectMapper();
String dtoDump;
URI incidentURI;
try
{
dtoDump = mapper.writeValueAsString(new IncidentV2DTO(this));
}
catch (JsonProcessingException ex)
{
logger.error("Incident registration fa... | java |
private static String[] decideCipherSuites()
{
String sysCipherSuites = System.getProperty("https.cipherSuites");
String[] cipherSuites = sysCipherSuites != null ? sysCipherSuites.split(",") :
// use jdk default cipher suites
((SSLServerSocketFactory) S... | java |
public static Telemetry createTelemetry(Connection conn, int flushSize)
{
try
{
return createTelemetry(conn.unwrap(SnowflakeConnectionV1.class).getSfSession(), flushSize);
}
catch (SQLException ex)
{
logger.debug("input connection is not a SnowflakeConnection");
return null;
... | java |
public void addLogToBatch(TelemetryData log) throws IOException
{
if (isClosed)
{
throw new IOException("Telemetry connector is closed");
}
if (!isTelemetryEnabled())
{
return; // if disable, do nothing
}
synchronized (locker)
{
this.logBatch.add(log);
}
if ... | java |
public void tryAddLogToBatch(TelemetryData log)
{
try
{
addLogToBatch(log);
}
catch (IOException ex)
{
logger.debug("Exception encountered while sending metrics to telemetry endpoint.", ex);
}
} | java |
public void close() throws IOException
{
if (isClosed)
{
throw new IOException("Telemetry connector is closed");
}
try
{
this.sendBatch();
}
catch (IOException e)
{
logger.error("Send logs failed on closing", e);
}
finally
{
this.isClosed = true;
... | java |
public boolean sendBatch() throws IOException
{
if (isClosed)
{
throw new IOException("Telemetry connector is closed");
}
if (!isTelemetryEnabled())
{
return false;
}
LinkedList<TelemetryData> tmpList;
synchronized (locker)
{
tmpList = this.logBatch;
this.l... | java |
static ObjectNode logsToJson(LinkedList<TelemetryData> telemetryData)
{
ObjectNode node = mapper.createObjectNode();
ArrayNode logs = mapper.createArrayNode();
for (TelemetryData data : telemetryData)
{
logs.add(data.toJson());
}
node.set("logs", logs);
return node;
} | java |
@Override
public ResultSet executeQuery(String sql) throws SQLException
{
raiseSQLExceptionIfStatementIsClosed();
return executeQueryInternal(sql, null);
} | java |
ResultSet executeQueryInternal(
String sql,
Map<String, ParameterBindingDTO> parameterBindings)
throws SQLException
{
SFBaseResultSet sfResultSet;
try
{
sfResultSet = sfStatement.execute(sql, parameterBindings,
SFStatement.CallingMethod.EXECUTE_Q... | java |
void setParameter(String name, Object value) throws Exception
{
logger.debug("public void setParameter");
try
{
if (this.sfStatement != null)
{
this.sfStatement.addProperty(name, value);
}
}
catch (SFException ex)
{
throw new SnowflakeSQLException(ex);
}
... | java |
private static ThreadPoolExecutor createChunkDownloaderExecutorService(
final String threadNamePrefix, final int parallel)
{
ThreadFactory threadFactory = new ThreadFactory()
{
private int threadCount = 1;
public Thread newThread(final Runnable r)
{
final Thread thread = new T... | java |
private void startNextDownloaders() throws SnowflakeSQLException
{
long waitingTime = BASE_WAITING_MS;
// submit the chunks to be downloaded up to the prefetch slot capacity
// and limited by memory
while (nextChunkToDownload - nextChunkToConsume < prefetchSlots &&
nextChunkToDownload < ch... | java |
public void releaseAllChunkMemoryUsage()
{
if (chunks == null || chunks.size() == 0)
{
return;
}
for (int i = 0; i < chunks.size(); i++)
{
releaseCurrentMemoryUsage(i, chunks.get(i).computeNeededChunkMemory());
}
} | java |
private void logOutOfMemoryError()
{
logger.error("Dump some crucial information below:\n" +
"Total milliseconds waiting for chunks: {},\n" +
"Total memory used: {}, Max heap size: {}, total download time: {} millisec,\n" +
"total parsing time: {} milliseconds, t... | java |
public Metrics terminate()
{
if (!terminated)
{
logger.debug("Total milliseconds waiting for chunks: {}, " +
"Total memory used: {}, total download time: {} millisec, " +
"total parsing time: {} milliseconds, total chunks: {}",
numberMillisWaitin... | java |
public static String maskAWSSecret(String sql)
{
List<SecretDetector.SecretRange> secretRanges =
SecretDetector.getAWSSecretPos(sql);
for (SecretDetector.SecretRange secretRange : secretRanges)
{
sql = maskText(sql, secretRange.beginPos, secretRange.endPos);
}
return sql;
} | java |
private void sanityCheckQuery(String sql) throws SQLException
{
if (sql == null || sql.isEmpty())
{
throw new SnowflakeSQLException(SqlState.SQL_STATEMENT_NOT_YET_COMPLETE,
ErrorCode.INVALID_SQL.getMessageCode(), sql);
}
} | java |
private SFBaseResultSet executeQuery(
String sql,
Map<String, ParameterBindingDTO> parametersBinding,
boolean describeOnly,
CallingMethod caller)
throws SQLException, SFException
{
sanityCheckQuery(sql);
String trimmedSql = sql.trim();
// snowflake specific client side commands... | java |
public SFStatementMetaData describe(String sql) throws SFException, SQLException
{
SFBaseResultSet baseResultSet = executeQuery(sql, null, true, null);
describeJobUUID = baseResultSet.getQueryId();
return new SFStatementMetaData(baseResultSet.getMetaData(),
baseResultS... | java |
private void setTimeBomb(ScheduledExecutorService executor)
{
class TimeBombTask implements Callable<Void>
{
private final SFStatement statement;
private TimeBombTask(SFStatement statement)
{
this.statement = statement;
}
@Override
public Void call() throws SQLEx... | java |
private void cancelHelper(String sql, String mediaType)
throws SnowflakeSQLException, SFException
{
synchronized (this)
{
if (isClosed)
{
throw new SFException(ErrorCode.INTERNAL_ERROR,
"statement already closed");
}
}
StmtUtil.StmtInput stmtI... | java |
public boolean getMoreResults(int current) throws SQLException
{
// clean up current result, if exists
if (resultSet != null &&
(current == Statement.CLOSE_CURRENT_RESULT ||
current == Statement.CLOSE_ALL_RESULTS))
{
resultSet.close();
}
resultSet = null;
// verify if m... | java |
public boolean isServiceException404()
{
if ((Exception) this instanceof AmazonServiceException)
{
AmazonServiceException asEx = (AmazonServiceException) ((java.lang.Exception) this);
return (asEx.getStatusCode() == HttpStatus.SC_NOT_FOUND);
}
return false;
} | java |
public static String oneLiner(Throwable thrown)
{
StackTraceElement[] stack = thrown.getStackTrace();
String topOfStack = null;
if (stack.length > 0)
{
topOfStack = " at " + stack[0];
}
return thrown.toString() + topOfStack;
} | java |
public static void dumpVmMetrics(String incidentId)
{
PrintWriter writer = null;
try
{
String dumpFile = EventUtil.getDumpPathPrefix() + "/" +
INC_DUMP_FILE_NAME + incidentId + INC_DUMP_FILE_EXT;
final OutputStream outStream =
new GZIPOutputStream(new FileOut... | java |
public static Throwable generateIncidentV2WithException(SFSession session,
Throwable exc,
String jobId,
String requestId)
{
new Incident(ses... | java |
public static String getUTCNow()
{
SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
dateFormatGmt.setTimeZone(TimeZone.getTimeZone("GMT"));
//Time in GMT
return dateFormatGmt.format(new Date());
} | java |
@Override
public void renew(Map stageCredentials) throws SnowflakeSQLException
{
stageInfo.setCredentials(stageCredentials);
setupAzureClient(stageInfo, encMat);
} | java |
@Override
public StorageObjectMetadata getObjectMetadata(String remoteStorageLocation, String prefix)
throws StorageProviderException
{
AzureObjectMetadata azureObjectMetadata = null;
try
{
// Get a reference to the BLOB, to retrieve its metadata
CloudBlobContainer container = azStorageCli... | java |
@Override
public void download(SFSession connection, String command, String localLocation, String destFileName,
int parallelism, String remoteStorageLocation, String stageFilePath, String stageRegion)
throws SnowflakeSQLException
{
int retryCount = 0;
do
{
try
{
... | java |
private static void handleAzureException(
Exception ex,
int retryCount,
String operation,
SFSession connection,
String command,
SnowflakeAzureClient azClient)
throws SnowflakeSQLException
{
// no need to retry if it is invalid key exception
if (ex.getCause() instanceof I... | java |
@Override
public void addDigestMetadata(StorageObjectMetadata meta, String digest)
{
if (!SnowflakeUtil.isBlank(digest))
{
// Azure doesn't allow hyphens in the name of a metadata field.
meta.addUserMetadata("sfcdigest", digest);
}
} | java |
private static long initMemoryLimit(final ResultOutput resultOutput)
{
// default setting
long memoryLimit = SessionUtil.DEFAULT_CLIENT_MEMORY_LIMIT * 1024 * 1024;
if (resultOutput.parameters.get(CLIENT_MEMORY_LIMIT) != null)
{
// use the settings from the customer
memoryLimit =
... | java |
static private Object effectiveParamValue(
Map<String, Object> parameters,
String paramName)
{
String upper = paramName.toUpperCase();
Object value = parameters.get(upper);
if (value != null)
{
return value;
}
value = defaultParameters.get(upper);
if (value != null)
... | java |
static private SnowflakeDateTimeFormat specializedFormatter(
Map<String, Object> parameters,
String id,
String param,
String defaultFormat)
{
String sqlFormat =
SnowflakeDateTimeFormat.effectiveSpecializedTimestampFormat(
(String) effectiveParamValue(parameters, param),... | java |
static public Timestamp adjustTimestamp(Timestamp timestamp)
{
long milliToAdjust = ResultUtil.msDiffJulianToGregorian(timestamp);
if (milliToAdjust != 0)
{
if (logger.isDebugEnabled())
{
logger.debug("adjust timestamp by {} days", milliToAdjust / 86400000);
}
Timestamp ... | java |
static public long msDiffJulianToGregorian(java.util.Date date)
{
// get the year of the date
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int year = cal.get(Calendar.YEAR);
int month = cal.get(Calendar.MONTH);
int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH);
// if date is be... | java |
static public String getSFTimeAsString(
SFTime sft, int scale, SnowflakeDateTimeFormat timeFormatter)
{
return timeFormatter.format(sft, scale);
} | java |
static public String getSFTimestampAsString(
SFTimestamp sfTS, int columnType, int scale,
SnowflakeDateTimeFormat timestampNTZFormatter,
SnowflakeDateTimeFormat timestampLTZFormatter,
SnowflakeDateTimeFormat timestampTZFormatter,
SFSession session) throws SFException
{
// Derive the ... | java |
static public String getDateAsString(
Date date, SnowflakeDateTimeFormat dateFormatter)
{
return dateFormatter.format(date, timeZoneUTC);
} | java |
static public Date adjustDate(Date date)
{
long milliToAdjust = ResultUtil.msDiffJulianToGregorian(date);
if (milliToAdjust != 0)
{
// add the difference to the new date
return new Date(date.getTime() + milliToAdjust);
}
else
{
return date;
}
} | java |
static public Date getDate(String str, TimeZone tz, SFSession session) throws SFException
{
try
{
long milliSecsSinceEpoch = Long.valueOf(str) * 86400000;
SFTimestamp tsInUTC = SFTimestamp.fromDate(new Date(milliSecsSinceEpoch),
0, TimeZone.getTime... | java |
static public int calculateUpdateCount(SFBaseResultSet resultSet)
throws SFException, SQLException
{
int updateCount = 0;
SFStatementType statementType = resultSet.getStatementType();
if (statementType.isDML())
{
while (resultSet.next())
{
if (statementType == SFStatementType.COP... | java |
public static int listSearchCaseInsensitive(List<String> source, String target)
{
for (int i = 0; i < source.size(); i++)
{
if (target.equalsIgnoreCase(source.get(i)))
{
return i;
}
}
return -1;
} | java |
private static List<String> getResultIds(JsonNode result)
{
JsonNode resultIds = result.path("data").path("resultIds");
if (resultIds.isNull() ||
resultIds.isMissingNode() ||
resultIds.asText().isEmpty())
{
return Collections.emptyList();
}
return new ArrayList<>(Arrays.asLis... | java |
private static List<SFStatementType> getResultTypes(JsonNode result)
{
JsonNode resultTypes = result.path("data").path("resultTypes");
if (resultTypes.isNull() ||
resultTypes.isMissingNode() ||
resultTypes.asText().isEmpty())
{
return Collections.emptyList();
}
String[] type... | java |
public static List<SFChildResult> getChildResults(SFSession session,
String requestId,
JsonNode result)
throws SFException
{
List<String> ids = getResultIds(result);
List<SFStatementType> types = getResul... | java |
private synchronized void openFile()
{
try
{
String fName = _directory.getAbsolutePath()
+ File.separatorChar + StreamLoader.FILE_PREFIX
+ _stamp + _fileCount;
if (_loader._compressDataBeforePut)
{
fName += StreamLoader.FILE_SUFFIX;
}
... | java |
boolean stageData(final byte[] line) throws IOException
{
if (this._rowCount % 10000 == 0)
{
LOGGER.debug(
"rowCount: {}, currentSize: {}", this._rowCount, _currentSize);
}
_outstream.write(line);
_currentSize += line.length;
_outstream.write(newLineBytes);
this._rowCount+... | java |
void completeUploading() throws IOException
{
LOGGER.debug("name: {}, currentSize: {}, Threshold: {},"
+ " fileCount: {}, fileBucketSize: {}",
_file.getAbsolutePath(),
_currentSize, this._csvFileSize, _fileCount,
this._csvFileBucketSize);
_o... | java |
private static String escapeFileSeparatorChar(String fname)
{
if (File.separatorChar == '\\')
{
return fname.replaceAll(File.separator + File.separator, "_");
}
else
{
return fname.replaceAll(File.separator, "_");
}
} | java |
@CheckForNull
private Object executeSyncMethod(Method method, Object[] args) throws ApplicationException {
if (preparingForShutdown.get()) {
throw new JoynrIllegalStateException("Preparing for shutdown. Only stateless methods can be called.");
}
return executeMethodWithCaller(met... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.