Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SEDONA-18] error reading shapefile #569

Merged
merged 4 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@
public class ShapeInputFormat
extends CombineFileInputFormat<ShapeKey, PrimitiveShape>
{
/**
* suffix of attribute file
*/
private final static String DBF_SUFFIX = "dbf";
/**
* suffix of shape record file
*/
private final static String SHP_SUFFIX = "shp";
/**
* suffix of index file
*/
private final static String SHX_SUFFIX = "shx";

public RecordReader<ShapeKey, PrimitiveShape> createRecordReader(InputSplit split, TaskAttemptContext context)
throws IOException
{
Expand Down Expand Up @@ -86,10 +99,13 @@ public List<InputSplit> getSplits(JobContext job)

for (Path filePath : filePathSizePair.keySet()) {
String filename = FilenameUtils.removeExtension(filePath.getName()).toLowerCase();
String suffix = FilenameUtils.getExtension(filePath.getName()).toLowerCase();

fileSplitPathParts.add(filePath);
fileSplitSizeParts.add(filePathSizePair.get(filePath));

if (prevfilename != "" && !prevfilename.equals(filename)) {
if (prevfilename != "" && !prevfilename.equals(filename)
&& (suffix.equals(SHX_SUFFIX) || suffix.equals(DBF_SUFFIX) || suffix.equals(SHP_SUFFIX))) {
// compare file name and if it is different then all same filename is into CombileFileSplit
splits.add(new CombineFileSplit(fileSplitPathParts.toArray(new Path[0]), Longs.toArray(fileSplitSizeParts)));
fileSplitPathParts.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void testShapefileEndWithUndefinedType()
}

/**
* Test correctness of parsing shapefile
* Test correctness of parsing shapefile. There are additional unnecessary files in directory
*
* @throws IOException
*/
Expand Down
5 changes: 5 additions & 0 deletions core/src/test/resources/shapefiles/polygon/map.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<test>
<testName>testReadToGeometryRDD</testName>
<fileName>map</fileName>
<desc>additional file</desc>
</test>
5 changes: 5 additions & 0 deletions core/src/test/resources/shapefiles/polygon/map1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<test>
<testName>testReadToGeometryRDD</testName>
<fileName>map1</fileName>
<desc>additional file</desc>
</test>