Skip to content

Commit

Permalink
Add a StreamOrdering config
Browse files Browse the repository at this point in the history
  • Loading branch information
harsharastogi authored and ARUNACHALAM THIRUPATHI committed Jun 2, 2022
1 parent 71663cf commit 2bc8e67
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 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 com.facebook.presto.orc;

import com.facebook.presto.orc.proto.DwrfProto;
import com.google.common.collect.ImmutableMap;

import java.util.List;
import java.util.Map;

import static java.util.Objects.requireNonNull;

public class DwrfStreamOrderingConfig
{
// column is the logical columns index for a table with n columns
// This index range from 0 to n - 1
private final ImmutableMap<Integer, List<DwrfProto.KeyInfo>> columnIdToFlatMapKeyIds;

public DwrfStreamOrderingConfig(Map<Integer, List<DwrfProto.KeyInfo>> columnIdToFlatMapKeyIds)
{
requireNonNull(columnIdToFlatMapKeyIds, "columnIdToFlatMapKeyIds cannot be null");
this.columnIdToFlatMapKeyIds = ImmutableMap.copyOf(columnIdToFlatMapKeyIds);
}

public Map<Integer, List<DwrfProto.KeyInfo>> getStreamOrdering()
{
return columnIdToFlatMapKeyIds;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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 com.facebook.presto.orc;

import com.facebook.presto.orc.proto.DwrfProto;
import com.google.common.collect.ImmutableMap;
import org.testng.annotations.Test;

import java.util.Collections;
import java.util.List;

import static org.testng.Assert.assertEquals;

public class TestDwrfStreamOrdering
{
@Test
public void testDwrfStreamOrder()
{
ImmutableMap<Integer, List<DwrfProto.KeyInfo>> columnIdToFlatMapKeyIds =
ImmutableMap.of(
1, Collections.singletonList(DwrfProto.KeyInfo.newBuilder().setIntKey(1).build()),
2, Collections.singletonList(DwrfProto.KeyInfo.newBuilder().setIntKey(1).build()),
3, Collections.singletonList(DwrfProto.KeyInfo.newBuilder().setIntKey(1).build()));
DwrfStreamOrderingConfig config = new DwrfStreamOrderingConfig(columnIdToFlatMapKeyIds);
assertEquals(config.getStreamOrdering(), columnIdToFlatMapKeyIds);
}
}

0 comments on commit 2bc8e67

Please sign in to comment.