Skip to content

Commit

Permalink
Minor improvements for DwrfMetadataReader
Browse files Browse the repository at this point in the history
  • Loading branch information
sdruzkin authored and ARUNACHALAM THIRUPATHI committed Jun 30, 2022
1 parent bff66c4 commit de6ef8b
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.Iterables;
import com.sun.management.ThreadMXBean;
import io.airlift.slice.BasicSliceInput;
import io.airlift.slice.Slice;
Expand Down Expand Up @@ -266,7 +265,7 @@ private static DwrfEncryption toEncryption(DwrfProto.Encryption encryption)

private static List<EncryptionGroup> toEncryptionGroups(List<DwrfProto.EncryptionGroup> encryptionGroups)
{
ImmutableList.Builder<EncryptionGroup> encryptionGroupBuilder = ImmutableList.builder();
ImmutableList.Builder<EncryptionGroup> encryptionGroupBuilder = ImmutableList.builderWithExpectedSize(encryptionGroups.size());
for (DwrfProto.EncryptionGroup dwrfEncryptionGroup : encryptionGroups) {
encryptionGroupBuilder.add(new EncryptionGroup(
dwrfEncryptionGroup.getNodesList(),
Expand All @@ -290,7 +289,7 @@ private static KeyProvider toKeyProvider(DwrfProto.Encryption.KeyProvider keyPro

private static List<StripeInformation> toStripeInformation(List<DwrfProto.StripeInformation> stripeInformationList)
{
ImmutableList.Builder<StripeInformation> stripeInfoBuilder = ImmutableList.builder();
ImmutableList.Builder<StripeInformation> stripeInfoBuilder = ImmutableList.builderWithExpectedSize(stripeInformationList.size());
List<byte[]> previousKeyMetadata = ImmutableList.of();
for (DwrfProto.StripeInformation dwrfStripeInfo : stripeInformationList) {
StripeInformation prestoStripeInfo = toStripeInformation(dwrfStripeInfo, previousKeyMetadata);
Expand Down Expand Up @@ -400,7 +399,6 @@ private static ColumnEncoding toColumnEncoding(OrcType type, List<DwrfProto.Colu
private static Map<Integer, ColumnEncoding> toColumnEncoding(List<OrcType> types, List<DwrfProto.ColumnEncoding> columnEncodings)
{
Map<Integer, List<DwrfProto.ColumnEncoding>> groupedColumnEncodings = new HashMap<>(columnEncodings.size());
ImmutableMap.Builder<Integer, ColumnEncoding> resultBuilder = ImmutableMap.builder();

for (int i = 0; i < columnEncodings.size(); i++) {
DwrfProto.ColumnEncoding columnEncoding = columnEncodings.get(i);
Expand All @@ -414,9 +412,9 @@ private static Map<Integer, ColumnEncoding> toColumnEncoding(List<OrcType> types
groupedColumnEncodings.computeIfAbsent(column, key -> new ArrayList<>()).add(columnEncoding);
}

ImmutableMap.Builder<Integer, ColumnEncoding> resultBuilder = ImmutableMap.builderWithExpectedSize(groupedColumnEncodings.size());
for (Map.Entry<Integer, List<DwrfProto.ColumnEncoding>> entry : groupedColumnEncodings.entrySet()) {
OrcType type = types.get(entry.getKey());

resultBuilder.put(
entry.getKey(),
toColumnEncoding(type, entry.getValue()));
Expand Down Expand Up @@ -448,7 +446,7 @@ public List<HiveBloomFilter> readBloomFilterIndexes(InputStream inputStream)
private RowGroupIndex toRowGroupIndex(HiveWriterVersion hiveWriterVersion, DwrfProto.RowIndexEntry rowIndexEntry, HiveBloomFilter bloomFilter)
{
List<Long> positionsList = rowIndexEntry.getPositionsList();
ImmutableList.Builder<Integer> positions = ImmutableList.builder();
ImmutableList.Builder<Integer> positions = ImmutableList.builderWithExpectedSize(positionsList.size());
for (int index = 0; index < positionsList.size(); index++) {
long longPosition = positionsList.get(index);
int intPosition = (int) longPosition;
Expand Down Expand Up @@ -573,7 +571,9 @@ private static OrcType toType(DwrfProto.Type type)

private static List<OrcType> toType(List<DwrfProto.Type> types)
{
return ImmutableList.copyOf(Iterables.transform(types, DwrfMetadataReader::toType));
return types.stream()
.map(DwrfMetadataReader::toType)
.collect(toImmutableList());
}

private static OrcTypeKind toTypeKind(DwrfProto.Type.Kind kind)
Expand Down

0 comments on commit de6ef8b

Please sign in to comment.