Skip to content

Commit

Permalink
v1 writer
Browse files Browse the repository at this point in the history
  • Loading branch information
wanglinsong committed Sep 2, 2023
1 parent 12ecc43 commit d46393e
Show file tree
Hide file tree
Showing 11 changed files with 1,502 additions and 17 deletions.
18 changes: 18 additions & 0 deletions presto-iceberg/nb-configuration.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<netbeans.hint.jdkPlatform>JDK_11.0.19-amzn</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>
49 changes: 49 additions & 0 deletions presto-parquet/DefLevelWriterProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.trino.parquet.writer.repdef;

import com.google.common.collect.Iterables;
import org.apache.parquet.column.values.ValuesWriter;

import java.util.List;
import java.util.Optional;

public interface DefLevelWriterProvider
{
DefinitionLevelWriter getDefinitionLevelWriter(Optional<DefinitionLevelWriter> nestedWriter, ValuesWriter encoder);

interface DefinitionLevelWriter
{
ValuesCount writeDefinitionLevels(int positionsCount);

ValuesCount writeDefinitionLevels();
}

record ValuesCount(int totalValuesCount, int maxDefinitionLevelValuesCount)
{
}

static DefinitionLevelWriter getRootDefinitionLevelWriter(List<DefLevelWriterProvider> defLevelWriterProviders, ValuesWriter encoder)
{
// Constructs hierarchy of DefinitionLevelWriter from leaf to root
DefinitionLevelWriter rootDefinitionLevelWriter = Iterables.getLast(defLevelWriterProviders)
.getDefinitionLevelWriter(Optional.empty(), encoder);
for (int nestedLevel = defLevelWriterProviders.size() - 2; nestedLevel >= 0; nestedLevel--) {
DefinitionLevelWriter nestedWriter = rootDefinitionLevelWriter;
rootDefinitionLevelWriter = defLevelWriterProviders.get(nestedLevel)
.getDefinitionLevelWriter(Optional.of(nestedWriter), encoder);
}
return rootDefinitionLevelWriter;
}
}
Loading

0 comments on commit d46393e

Please sign in to comment.