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
2 changes: 2 additions & 0 deletions pixels-common/src/main/resources/pixels.properties
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ cache.read.direct=false
# properties for pixels writer
pixel.stride=10000
row.group.size=268435456
# The alignment is for SIMD and its unit is byte
column.chunk.alignment=32
block.size=2147483648
block.replication=1
block.padding=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.pixelsdb.pixels.common.physical.PhysicalWriterUtil;
import io.pixelsdb.pixels.common.physical.Storage;
import io.pixelsdb.pixels.common.utils.Constants;
import io.pixelsdb.pixels.common.utils.ConfigFactory;
import io.pixelsdb.pixels.core.PixelsProto.CompressionKind;
import io.pixelsdb.pixels.core.PixelsProto.RowGroupInformation;
import io.pixelsdb.pixels.core.PixelsProto.RowGroupStatistic;
Expand Down Expand Up @@ -99,7 +100,7 @@ public class PixelsWriterImpl implements PixelsWriter
private final List<TypeDescription> children;

private final ExecutorService columnWriterService = Executors.newCachedThreadPool();

private int chunkAlignment;
private PixelsWriterImpl(
TypeDescription schema,
int pixelStride,
Expand All @@ -124,7 +125,7 @@ private PixelsWriterImpl(
this.encoding = encoding;
this.partitioned = partitioned;
this.partKeyColumnIds = requireNonNull(partKeyColumnIds, "partKeyColumnIds is null");

this.chunkAlignment = Integer.parseInt(ConfigFactory.Instance().getProperty("column.chunk.alignment"));
children = schema.getChildren();
checkArgument(!requireNonNull(children, "schema is null").isEmpty(), "schema is empty");
this.columnWriters = new ColumnWriter[children.size()];
Expand Down Expand Up @@ -519,6 +520,13 @@ private void writeRowGroup()
byte[] rowGroupBuffer = writer.getColumnChunkContent();
physicalWriter.append(rowGroupBuffer, 0, rowGroupBuffer.length);
writtenBytes += rowGroupBuffer.length;
// add align bytes to make sure the column size is the multiple of fsBlockSize
if(rowGroupBuffer.length % chunkAlignment != 0) {
int alignByte = chunkAlignment - rowGroupBuffer.length % chunkAlignment;
byte[] emptyArray = new byte[alignByte];
physicalWriter.append(emptyArray, 0, alignByte);
writtenBytes += alignByte;
}
}
physicalWriter.flush();
}
Expand All @@ -543,6 +551,9 @@ private void writeRowGroup()
chunkIndexBuilder.setChunkOffset(curRowGroupOffset + rowGroupDataLength);
chunkIndexBuilder.setChunkLength(writer.getColumnChunkSize());
rowGroupDataLength += writer.getColumnChunkSize();
if((curRowGroupOffset + rowGroupDataLength) % chunkAlignment != 0) {
rowGroupDataLength += (int) (chunkAlignment - (curRowGroupOffset + rowGroupDataLength) % chunkAlignment);
}
// collect columnChunkIndex from every column chunk into curRowGroupIndex
curRowGroupIndex.addColumnChunkIndexEntries(chunkIndexBuilder.build());
// collect columnChunkStatistic into rowGroupStatistic
Expand Down