-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
destination-s3: add file transfer #46302
Changes from 8 commits
367e2f0
d8a3bb0
53a8182
7ee9838
75486ef
415b532
ca957df
2000516
07f7b66
bac819b
1df388d
4d742a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,7 @@ class BufferDequeue( | |
|
||
// otherwise pull records until we hit the memory limit. | ||
val newSize: Long = (memoryItem.size) + bytesRead.get() | ||
if (newSize <= optimalBytesToRead) { | ||
if (newSize <= optimalBytesToRead || output.isEmpty()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this accomplishing? Is this because other changes caused There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is not 0 (it's 1) but one and yes it is allowing to add a record to the output disregard of the size. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the problem here was if |
||
memoryItem.size.let { bytesRead.addAndGet(it) } | ||
queue.poll()?.item?.let { output.add(it) } | ||
} else { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2024 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.cdk.integrations.destination.async.model | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
|
||
class AirbyteRecordMessageFile { | ||
constructor( | ||
fileUrl: String? = null, | ||
bytes: Long? = null, | ||
fileRelativePath: String? = null, | ||
modified: Long? = null, | ||
sourceFileUrl: String? = null | ||
) { | ||
this.fileUrl = fileUrl | ||
this.bytes = bytes | ||
this.fileRelativePath = fileRelativePath | ||
this.modified = modified | ||
this.sourceFileUrl = sourceFileUrl | ||
} | ||
constructor() : | ||
this( | ||
fileUrl = null, | ||
bytes = null, | ||
fileRelativePath = null, | ||
modified = null, | ||
sourceFileUrl = null | ||
) | ||
|
||
@get:JsonProperty("file_url") | ||
@set:JsonProperty("file_url") | ||
@JsonProperty("file_url") | ||
var fileUrl: String? = null | ||
|
||
@get:JsonProperty("bytes") | ||
@set:JsonProperty("bytes") | ||
@JsonProperty("bytes") | ||
var bytes: Long? = null | ||
|
||
@get:JsonProperty("file_relative_path") | ||
@set:JsonProperty("file_relative_path") | ||
@JsonProperty("file_relative_path") | ||
var fileRelativePath: String? = null | ||
|
||
@get:JsonProperty("modified") | ||
@set:JsonProperty("modified") | ||
@JsonProperty("modified") | ||
var modified: Long? = null | ||
|
||
@get:JsonProperty("source_file_url") | ||
@set:JsonProperty("source_file_url") | ||
@JsonProperty("source_file_url") | ||
var sourceFileUrl: String? = null | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=0.47.3 | ||
version=0.48.0 |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -49,7 +49,13 @@ class DetectStreamToFlushTest { | |||||
) | ||||||
|
||||||
val detect = | ||||||
DetectStreamToFlush(bufferDequeue, runningFlushWorkers, AtomicBoolean(false), flusher) | ||||||
DetectStreamToFlush( | ||||||
bufferDequeue, | ||||||
runningFlushWorkers, | ||||||
AtomicBoolean(false), | ||||||
flusher, | ||||||
false | ||||||
) | ||||||
Assertions.assertEquals(Optional.empty<Any>(), detect.getNextStreamToFlush(0)) | ||||||
} | ||||||
|
||||||
|
@@ -66,7 +72,13 @@ class DetectStreamToFlushTest { | |||||
RunningFlushWorkers::class.java, | ||||||
) | ||||||
val detect = | ||||||
DetectStreamToFlush(bufferDequeue, runningFlushWorkers, AtomicBoolean(false), flusher) | ||||||
DetectStreamToFlush( | ||||||
bufferDequeue, | ||||||
runningFlushWorkers, | ||||||
AtomicBoolean(false), | ||||||
flusher, | ||||||
false | ||||||
) | ||||||
// if above threshold, triggers | ||||||
Assertions.assertEquals(Optional.of(DESC1), detect.getNextStreamToFlush(0)) | ||||||
// if below threshold, no trigger | ||||||
|
@@ -94,10 +106,41 @@ class DetectStreamToFlushTest { | |||||
), | ||||||
) | ||||||
val detect = | ||||||
DetectStreamToFlush(bufferDequeue, runningFlushWorkers, AtomicBoolean(false), flusher) | ||||||
DetectStreamToFlush( | ||||||
bufferDequeue, | ||||||
runningFlushWorkers, | ||||||
AtomicBoolean(false), | ||||||
flusher, | ||||||
false | ||||||
) | ||||||
Assertions.assertEquals(Optional.empty<Any>(), detect.getNextStreamToFlush(0)) | ||||||
} | ||||||
|
||||||
@Test | ||||||
internal fun testFileTransfer() { | ||||||
val bufferDequeue = | ||||||
Mockito.mock( | ||||||
BufferDequeue::class.java, | ||||||
) | ||||||
Mockito.`when`(bufferDequeue.bufferedStreams).thenReturn(setOf(DESC1)) | ||||||
Mockito.`when`(bufferDequeue.getQueueSizeBytes(DESC1)).thenReturn(Optional.of(0L)) | ||||||
val runningFlushWorkers = | ||||||
Mockito.mock( | ||||||
RunningFlushWorkers::class.java, | ||||||
) | ||||||
|
||||||
val detect = | ||||||
DetectStreamToFlush( | ||||||
bufferDequeue, | ||||||
runningFlushWorkers, | ||||||
AtomicBoolean(false), | ||||||
flusher, | ||||||
true | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: use named parameters for primitive arguments
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||
) | ||||||
Assertions.assertEquals(0, detect.computeQueueThreshold()) | ||||||
Assertions.assertEquals(Optional.of(DESC1), detect.getNextStreamToFlush(0)) | ||||||
} | ||||||
|
||||||
@Test | ||||||
internal fun testGetNextPicksUpOnTimeTrigger() { | ||||||
val bufferDequeue = | ||||||
|
@@ -127,6 +170,7 @@ class DetectStreamToFlushTest { | |||||
AtomicBoolean(false), | ||||||
flusher, | ||||||
mockedNowProvider, | ||||||
false | ||||||
) | ||||||
|
||||||
// initialize flush time | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: rename to
flushOnEveryMessage
(to reflect functionality rather than usage)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done