-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARROW-386: [Java] Respect case of struct / map field names
Changes include: - Remove all toLowerCase() calls on field names in MapWriters.java template file, so that the writers can respect case of the field names. - Use lower-case keys for internalMap in UnionVector instead of camel-case (e.g. bigInt -> bigint). p.s. I don't know what is the original purpose of using camel case here. It did not conflict because all field names are converted to lower cases in the past. - Add a simple test case of MapWriter with mixed-case field names. Author: Jingyuan Wang <[email protected]> Closes #261 from alphalfalfa/arrow-386 and squashes the following commits: cd08145 [Jingyuan Wang] Remove unnecessary handleCase() call 7b28bfc [Jingyuan Wang] Pass caseSensitive Attribute down to nested MapWriters 2fe7bcf [Jingyuan Wang] Separate MapWriters with CaseSensitiveMapWriters d269e21 [Jingyuan Wang] Configure case sensitivity when constructing ComplexWriterImpl cba60d1 [Jingyuan Wang] Add option to MapWriters to configure the case sensitivity (defaulted as case-insensitive) 51da2a1 [Jingyuan Wang] Arrow-386: [Java] Respect case of struct / map field names
- Loading branch information
1 parent
6811d3f
commit 512bc16
Showing
10 changed files
with
253 additions
and
29 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
java/vector/src/main/codegen/templates/CaseSensitiveMapWriters.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,54 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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. | ||
*/ | ||
|
||
<@pp.dropOutputFile /> | ||
<#list ["Nullable", "Single"] as mode> | ||
<@pp.changeOutputFile name="/org/apache/arrow/vector/complex/impl/${mode}CaseSensitiveMapWriter.java" /> | ||
<#assign index = "idx()"> | ||
<#if mode == "Single"> | ||
<#assign containerClass = "MapVector" /> | ||
<#else> | ||
<#assign containerClass = "NullableMapVector" /> | ||
</#if> | ||
<#include "/@includes/license.ftl" /> | ||
package org.apache.arrow.vector.complex.impl; | ||
<#include "/@includes/vv_imports.ftl" /> | ||
/* | ||
* This class is generated using FreeMarker and the ${.template_name} template. | ||
*/ | ||
@SuppressWarnings("unused") | ||
public class ${mode}CaseSensitiveMapWriter extends ${mode}MapWriter { | ||
public ${mode}CaseSensitiveMapWriter(${containerClass} container) { | ||
super(container); | ||
} | ||
|
||
@Override | ||
protected String handleCase(final String input){ | ||
return input; | ||
} | ||
|
||
@Override | ||
protected NullableMapWriterFactory getNullableMapWriterFactory() { | ||
return NullableMapWriterFactory.getNullableCaseSensitiveMapWriterFactoryInstance(); | ||
} | ||
|
||
} | ||
</#list> |
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
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
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
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
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
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
42 changes: 42 additions & 0 deletions
42
java/vector/src/main/java/org/apache/arrow/vector/complex/impl/NullableMapWriterFactory.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,42 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 | ||
* <p/> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p/> | ||
* 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 org.apache.arrow.vector.complex.impl; | ||
|
||
import org.apache.arrow.vector.complex.NullableMapVector; | ||
|
||
public class NullableMapWriterFactory { | ||
private final boolean caseSensitive; | ||
private static final NullableMapWriterFactory nullableMapWriterFactory = new NullableMapWriterFactory(false); | ||
private static final NullableMapWriterFactory nullableCaseSensitiveWriterFactory = new NullableMapWriterFactory(true); | ||
|
||
public NullableMapWriterFactory(boolean caseSensitive) { | ||
this.caseSensitive = caseSensitive; | ||
} | ||
|
||
public NullableMapWriter build(NullableMapVector container) { | ||
return this.caseSensitive? new NullableCaseSensitiveMapWriter(container) : new NullableMapWriter(container); | ||
} | ||
|
||
public static NullableMapWriterFactory getNullableMapWriterFactoryInstance() { | ||
return nullableMapWriterFactory; | ||
} | ||
|
||
public static NullableMapWriterFactory getNullableCaseSensitiveMapWriterFactoryInstance() { | ||
return nullableCaseSensitiveWriterFactory; | ||
} | ||
} |
Oops, something went wrong.