-
Notifications
You must be signed in to change notification settings - Fork 7
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
Showing
25 changed files
with
573 additions
and
257 deletions.
There are no files selected for viewing
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
34 changes: 34 additions & 0 deletions
34
pig/src/org/partiql/pig/domain/parser/ImportSourceOpener.kt
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,34 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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.partiql.pig.domain.parser | ||
|
||
import com.amazon.ion.IonReader | ||
import com.amazon.ion.system.IonReaderBuilder | ||
import java.io.Closeable | ||
import java.io.File | ||
import java.io.FileInputStream | ||
import java.nio.file.Path | ||
|
||
//class ImportSource( | ||
// val fullyQualifiedName: String, | ||
// val reader: IonReader | ||
//) : Closeable { | ||
// override fun close() { | ||
// reader.close() | ||
// } | ||
//} | ||
|
||
// TODO: names |
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,45 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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.partiql.pig.domain.parser | ||
|
||
import java.io.File | ||
import java.io.FileInputStream | ||
import java.io.InputStream | ||
|
||
/** | ||
* Provides an abstraction for file-system related functions used when importing files. | ||
*/ | ||
internal interface InputSource { | ||
/** | ||
* Opens an input stream for the given source name. | ||
* | ||
* The [sourceName] is implementation-defined. In the case of a file system implementaiton it is the path to a | ||
* file, either relative to the working directory or absolute. | ||
*/ | ||
fun openStream(sourceName: String): InputStream | ||
|
||
/** | ||
* Returns the "canonical name" of the given source. In the case of a file system, this converts the relative | ||
* path to an absolute path. | ||
*/ | ||
fun getCanonicalName(sourceName: String): String | ||
} | ||
|
||
internal val FILE_SYSTEM_SOURCE = object : InputSource { | ||
override fun openStream(qualifiedSource: String) = FileInputStream(qualifiedSource) | ||
|
||
override fun getCanonicalName(sourceName: String): String = File(sourceName).canonicalFile.toString() | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file 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.partiql.pig.domain.parser | ||
|
||
import com.amazon.ionelement.api.IonLocation | ||
import com.amazon.ionelement.api.MetaContainer | ||
|
||
/** | ||
* Includes path to a source file and a position within it. | ||
* | ||
* Used to construct helpful error messages for the end-user, who will be able to know the file, line & column of | ||
* a given error. | ||
*/ | ||
data class SourceLocation(val path: String, val location: IonLocation) { | ||
override fun toString(): String { | ||
return "$path:$location" | ||
} | ||
} | ||
|
||
internal const val SOURCE_LOCATION_META_TAG = "\$pig_source_location" | ||
|
||
internal val MetaContainer.sourceLocation | ||
get() = this[SOURCE_LOCATION_META_TAG] as? SourceLocation |
Oops, something went wrong.