This file contains hidden or 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
| # issue movies query | |
| conf = {"es.resource" : "movies/logs", "es.query" : "?q=name:bourne"} | |
| movies = sc.newAPIHadoopRDD("org.elasticsearch.hadoop.mr.EsInputFormat",\ | |
| "org.apache.hadoop.io.NullWritable", "org.elasticsearch.hadoop.mr.LinkedMapWritable", conf=conf) | |
| # place results in table | |
| moviesRows = movies.map(lambda p: Row(id=int(p[1]['id']), name=p[1]['name'])) | |
| moviesRowsList = moviesRows.collect() | |
| schemaMovies = sqlContext.createDataFrame(moviesRowsList) | |
| schemaMovies.registerTempTable("movies") |
This file contains hidden or 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
| <named-native-query name="ObjectType.updateLocation"> | |
| <query> | |
| <![CDATA[ | |
| update object_type set location = :location where id in ( | |
| with recursive tree (child) as ( | |
| values(:parent_id) | |
| union | |
| select ot.id from object_type ot, tree where ot.parent_id = child and ot.direct_location = false) | |
| select child from tree) | |
| ]]> |
This file contains hidden or 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
| <named-native-query name="ObjectType.updateLocation"> | |
| <query> | |
| <![CDATA[ | |
| update object_type set location = :location where id in ( | |
| with recursive tree (child) as ( | |
| values(:parent_id) | |
| union | |
| select ot.id from object_type ot, tree where ot.parent_id = child and ot.direct_location = false) | |
| select child from tree) | |
| ]]> |
This file contains hidden or 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
| db=# select * from object_type; | |
| id | parent_id | label | location | direct_location | |
| -----+-----------+-------------+------------+----------------- | |
| 103 | 102 | ww2 | main floor | t | |
| 104 | 101 | biography | 2nd floor | t | |
| 100 | 0 | book | new floor | t | |
| 101 | 100 | non-fiction | new floor | f | |
| 102 | 101 | history | new floor | f | |
| 105 | 100 | fiction | new floor | f |
This file contains hidden or 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
| update object_type set location = 'new floor' where id in ( | |
| with recursive tree (child) as ( | |
| values(cast(100 as bigint)) | |
| union | |
| select ot.id from object_type ot, tree where ot.parent_id = child and ot.direct_location = false) | |
| select child from tree) |
This file contains hidden or 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
| item | |
| book (main floor)* | |
| non-fiction (main floor) | |
| history (main floor) | |
| ww2 (main floor)* | |
| biography (2nd floor)* | |
| fiction (main floor) |
This file contains hidden or 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
| db=# create table object_type (id bigint, parent_id bigint, | |
| label text, location text, direct_location boolean); | |
| db=# select * from object_type; | |
| id | parent_id | label | location | direct_location | |
| -----+-----------+-------------+------------+----------------- | |
| 100 | 0 | book | main floor | t | |
| 101 | 100 | non-fiction | main floor | f | |
| 102 | 101 | history | main floor | f | |
| 103 | 102 | ww2 | main floor | t |
This file contains hidden or 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
| db=# create table object_type (id bigint, parent_id bigint, label text, location text, direct_location boolean); | |
| db=# select * from object_type; | |
| id | parent_id | label | location | direct_location | |
| -----+-----------+-------------+------------+----------------- | |
| 100 | 0 | book | main floor | t | |
| 101 | 100 | non-fiction | main floor | f | |
| 102 | 101 | history | main floor | f | |
| 103 | 102 | ww2 | main floor | t | |
| 104 | 101 | biography | 2nd floor | t |
This file contains hidden or 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
| // We have a lot of residences in our portfolio. There would probably be many methods in addition to this one. | |
| public class Residence { | |
| // Accept a visitor object so it can do something | |
| void accept(Visitor visit); | |
| } | |
| // We have detached houses | |
| public class DetachedHouse implements Residence { | |
| // imagine getters and setters for these values | |
| private double squareFeet; |
This file contains hidden or 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
| final DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'"); | |
| final String timestampString = "2014-03-09T02:01:47Z" | |
| final DateTime dateTime = dateTimeFormatter.parseDateTime(timestampString); |
NewerOlder