Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ public FormatReaderFactory createReaderFactory(
@Override
public FormatWriterFactory createWriterFactory(RowType type) {
return new VortexWriterFactory(
() -> new ArrowFormatCWriter(type, formatContext.writeBatchSize(), true));
() ->
new ArrowFormatCWriter(
type,
formatContext.writeBatchSize(),
true,
formatContext.writeBatchMemory().getBytes(),
null));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.paimon.format.vortex;

import org.apache.paimon.annotation.VisibleForTesting;
import org.apache.paimon.arrow.vector.ArrowFormatCWriter;
import org.apache.paimon.format.FormatWriter;
import org.apache.paimon.format.FormatWriterFactory;
Expand All @@ -42,6 +43,11 @@ public VortexWriterFactory(Supplier<ArrowFormatCWriter> cWriterSupplier) {
this.cWriterSupplier = cWriterSupplier;
}

@VisibleForTesting
Supplier<ArrowFormatCWriter> cWriterSupplier() {
return cWriterSupplier;
}

@Override
public FormatWriter create(PositionOutputStream positionOutputStream, String compression) {
throw new UnsupportedOperationException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@

package org.apache.paimon.format.vortex;

import org.apache.paimon.arrow.vector.ArrowFormatCWriter;
import org.apache.paimon.data.GenericRow;
import org.apache.paimon.format.FileFormatFactory;
import org.apache.paimon.options.MemorySize;
import org.apache.paimon.options.Options;
import org.apache.paimon.types.DataTypes;
import org.apache.paimon.types.RowType;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down Expand Up @@ -64,6 +70,33 @@ public void testCreateWriterFactory() {
assertDoesNotThrow(() -> format.createWriterFactory(rowType));
}

@ParameterizedTest
@ValueSource(booleans = {false, true})
public void testWriterFactoryHonorsWriteBatchMemory(boolean limitMemory) {
int writeBatchSize = 1024;
FileFormatFactory.FormatContext formatContext =
limitMemory
? new FileFormatFactory.FormatContext(
new Options(), 1024, writeBatchSize, MemorySize.parse("1 kb"))
: new FileFormatFactory.FormatContext(new Options(), 1024, writeBatchSize);
VortexFileFormat format = new VortexFileFormat(formatContext);
RowType rowType = RowType.of(DataTypes.BYTES(), DataTypes.BYTES());
VortexWriterFactory factory = (VortexWriterFactory) format.createWriterFactory(rowType);

GenericRow row = new GenericRow(2);
row.setField(0, new byte[1024]);
row.setField(1, new byte[1024]);

try (ArrowFormatCWriter writer = factory.cWriterSupplier().get()) {
// the memory limit is only re-checked every 32 rows
for (int i = 0; i < 32; i++) {
assertThat(writer.write(row)).isTrue();
}
// this row is still far below write-batch-size, so only the memory limit can reject it
assertThat(writer.write(row)).isEqualTo(!limitMemory);
}
}

@Test
public void testValidateDataFields_UnsupportedMapType() {
VortexFileFormat format =
Expand Down
Loading