-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71663cf
commit 2bc8e67
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
presto-orc/src/main/java/com/facebook/presto/orc/DwrfStreamOrderingConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
presto-orc/src/test/java/com/facebook/presto/orc/TestDwrfStreamOrdering.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |