Skip to content
Merged
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 @@ -40,8 +40,6 @@
import static io.airlift.slice.SizeOf.instanceSize;
import static io.airlift.slice.SizeOf.sizeOf;
import static io.airlift.slice.SizeOf.sizeOfByteArray;
import static io.trino.execution.buffer.PageCodecMarker.COMPRESSED;
import static io.trino.execution.buffer.PageCodecMarker.ENCRYPTED;
import static io.trino.execution.buffer.PagesSerdeUtil.ESTIMATED_AES_CIPHER_RETAINED_SIZE;
import static io.trino.execution.buffer.PagesSerdeUtil.SERIALIZED_PAGE_CIPHER_NAME;
import static io.trino.execution.buffer.PagesSerdeUtil.SERIALIZED_PAGE_COMPRESSED_BLOCK_MASK;
Expand Down Expand Up @@ -129,7 +127,6 @@ private static class SerializedPageOutput

private final Optional<Compressor> compressor;
private final Optional<SecretKey> encryptionKey;
private final int markers;
private final Optional<Cipher> cipher;

private final WriteBuffer[] buffers;
Expand All @@ -149,10 +146,8 @@ private SerializedPageOutput(
+ (encryptionKey.isPresent() ? 1 : 0) // encryption buffer
+ 1 // output buffer
];
PageCodecMarker.MarkerSet markerSet = PageCodecMarker.MarkerSet.empty();
if (compressor.isPresent()) {
buffers[0] = new WriteBuffer(blockSizeInBytes);
markerSet.add(COMPRESSED);
}
if (encryptionKey.isPresent()) {
int bufferSize = blockSizeInBytes;
Expand All @@ -162,7 +157,6 @@ private SerializedPageOutput(
+ Integer.BYTES;
}
buffers[buffers.length - 2] = new WriteBuffer(bufferSize);
markerSet.add(ENCRYPTED);

try {
cipher = Optional.of(Cipher.getInstance(SERIALIZED_PAGE_CIPHER_NAME));
Expand All @@ -174,14 +168,12 @@ private SerializedPageOutput(
else {
cipher = Optional.empty();
}
markers = markerSet.byteValue();
}

public void startPage(int positionCount, int sizeInBytes)
{
WriteBuffer buffer = new WriteBuffer(round(sizeInBytes * 1.2F) + SERIALIZED_PAGE_HEADER_SIZE);
buffer.writeInt(positionCount);
buffer.writeByte(markers);
// leave space for uncompressed and compressed sizes
buffer.skip(Integer.BYTES * 2);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import io.airlift.slice.SliceOutput;
import io.airlift.slice.Slices;
import io.airlift.slice.XxHash64;
import io.trino.execution.buffer.PageCodecMarker.MarkerSet;
import io.trino.spi.Page;
import io.trino.spi.block.Block;
import io.trino.spi.block.BlockEncodingSerde;
Expand All @@ -35,8 +34,6 @@
import static com.google.common.base.Verify.verify;
import static io.trino.block.BlockSerdeUtil.readBlock;
import static io.trino.block.BlockSerdeUtil.writeBlock;
import static io.trino.execution.buffer.PageCodecMarker.COMPRESSED;
import static io.trino.execution.buffer.PageCodecMarker.ENCRYPTED;
import static java.util.Arrays.asList;
import static java.util.Objects.requireNonNull;

Expand All @@ -45,8 +42,7 @@ public final class PagesSerdeUtil
private PagesSerdeUtil() {}

static final int SERIALIZED_PAGE_POSITION_COUNT_OFFSET = 0;
static final int SERIALIZED_PAGE_CODEC_MARKERS_OFFSET = SERIALIZED_PAGE_POSITION_COUNT_OFFSET + Integer.BYTES;
static final int SERIALIZED_PAGE_UNCOMPRESSED_SIZE_OFFSET = SERIALIZED_PAGE_CODEC_MARKERS_OFFSET + Byte.BYTES;
static final int SERIALIZED_PAGE_UNCOMPRESSED_SIZE_OFFSET = SERIALIZED_PAGE_POSITION_COUNT_OFFSET + Integer.BYTES;
static final int SERIALIZED_PAGE_COMPRESSED_SIZE_OFFSET = SERIALIZED_PAGE_UNCOMPRESSED_SIZE_OFFSET + Integer.BYTES;
static final int SERIALIZED_PAGE_HEADER_SIZE = SERIALIZED_PAGE_COMPRESSED_SIZE_OFFSET + Integer.BYTES;
static final String SERIALIZED_PAGE_CIPHER_NAME = "AES/CBC/PKCS5Padding";
Expand Down Expand Up @@ -124,21 +120,6 @@ public static int getSerializedPageUncompressedSizeInBytes(Slice serializedPage)
return serializedPage.getInt(SERIALIZED_PAGE_UNCOMPRESSED_SIZE_OFFSET);
}

public static boolean isSerializedPageEncrypted(Slice serializedPage)
{
return getSerializedPageMarkerSet(serializedPage).contains(ENCRYPTED);
}

public static boolean isSerializedPageCompressed(Slice serializedPage)
{
return getSerializedPageMarkerSet(serializedPage).contains(COMPRESSED);
}

private static MarkerSet getSerializedPageMarkerSet(Slice serializedPage)
{
return MarkerSet.fromByteValue(serializedPage.getByte(Integer.BYTES));
}

private static class PageReader
extends AbstractIterator<Page>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ static void main()
System.out.println("Page Size Max: " + Arrays.stream(data.dataPages).mapToLong(Page::getSizeInBytes).max().getAsLong());
System.out.println("Page Size Sum: " + Arrays.stream(data.dataPages).mapToLong(Page::getSizeInBytes).sum());
System.out.println("Page count: " + data.dataPages.length);
System.out.println("Compressed: " + Arrays.stream(data.serializedPages).filter(PagesSerdeUtil::isSerializedPageCompressed).count());

benchmark(BenchmarkPagesSerde.class)
.withOptions(optionsBuilder -> optionsBuilder.jvmArgs("-Xms4g", "-Xmx4g"))
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ public void testBigintSerializedSize()
// empty page
Page page = new Page(builder.build());
int pageSize = serializedSize(ImmutableList.of(BIGINT), page);
assertThat(pageSize).isEqualTo(36);
assertThat(pageSize).isEqualTo(35);

// page with one value
BIGINT.writeLong(builder, 123);
pageSize = 35; // Now we have moved to the normal block implementation so the page size overhead is 35
page = new Page(builder.build());
int firstValueSize = serializedSize(ImmutableList.of(BIGINT), page) - pageSize;
assertThat(firstValueSize).isEqualTo(9); // value size + value overhead
assertThat(firstValueSize).isEqualTo(8); // value size + value overhead

// page with two values
BIGINT.writeLong(builder, 456);
Expand All @@ -211,11 +211,11 @@ public void testVarcharSerializedSize()
// empty page
Page page = new Page(builder.build());
int pageSize = serializedSize(ImmutableList.of(VARCHAR), page);
assertThat(pageSize).isEqualTo(44);
assertThat(pageSize).isEqualTo(43);

// page with one value
VARCHAR.writeString(builder, "alice");
pageSize = 44; // Now we have moved to the normal block implementation so the page size overhead is 44
pageSize = 43; // Now we have moved to the normal block implementation so the page size overhead is 43
page = new Page(builder.build());
int firstValueSize = serializedSize(ImmutableList.of(VARCHAR), page) - pageSize;
assertThat(firstValueSize).isEqualTo(4 + 5); // ending offset + nonNullsCount + "alice"
Expand Down
Loading