-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
grab bag of non-controversial clean up tasks (#26702)
- Loading branch information
Showing
11 changed files
with
99 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...s/base-java/src/main/java/io/airbyte/integrations/destination_async/AirbyteFileUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination_async; | ||
|
||
import java.text.DecimalFormat; | ||
|
||
/** | ||
* Replicate the behavior of {@link org.apache.commons.io.FileUtils} to match the proclivities of | ||
* Davin and Charles. Courteously written by ChatGPT. | ||
*/ | ||
public class AirbyteFileUtils { | ||
|
||
private static final double ONE_KB = 1024; | ||
private static final double ONE_MB = ONE_KB * 1024; | ||
private static final double ONE_GB = ONE_MB * 1024; | ||
private static final double ONE_TB = ONE_GB * 1024; | ||
private static final DecimalFormat df = new DecimalFormat("#.##"); | ||
|
||
/** | ||
* Replicate the behavior of {@link org.apache.commons.io.FileUtils} but instead of rounding down to | ||
* the nearest whole number, it rounds to two decimal places. | ||
* | ||
* @param sizeInBytes size in bytes | ||
* @return human-readable size | ||
*/ | ||
public static String byteCountToDisplaySize(final long sizeInBytes) { | ||
|
||
if (sizeInBytes < ONE_KB) { | ||
return df.format(sizeInBytes) + " bytes"; | ||
} else if (sizeInBytes < ONE_MB) { | ||
return df.format((double) sizeInBytes / ONE_KB) + " KB"; | ||
} else if (sizeInBytes < ONE_GB) { | ||
return df.format((double) sizeInBytes / ONE_MB) + " MB"; | ||
} else if (sizeInBytes < ONE_TB) { | ||
return df.format((double) sizeInBytes / ONE_GB) + " GB"; | ||
} else { | ||
return df.format((double) sizeInBytes / ONE_TB) + " TB"; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
...e-java/src/main/java/io/airbyte/integrations/destination_async/IgnoredRecordsTracker.java
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
...se-java/src/test/java/io/airbyte/integrations/destination_async/AirbyteFileUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.integrations.destination_async; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class AirbyteFileUtilsTest { | ||
|
||
@Test | ||
void testByteCountToDisplaySize() { | ||
|
||
assertEquals("500 bytes", AirbyteFileUtils.byteCountToDisplaySize(500L)); | ||
assertEquals("1.95 KB", AirbyteFileUtils.byteCountToDisplaySize(2000L)); | ||
assertEquals("2.93 MB", AirbyteFileUtils.byteCountToDisplaySize(3072000L)); | ||
assertEquals("2.67 GB", AirbyteFileUtils.byteCountToDisplaySize(2872000000L)); | ||
assertEquals("1.82 TB", AirbyteFileUtils.byteCountToDisplaySize(2000000000000L)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters