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

Create GeoMesa suproject #1621

Merged
merged 15 commits into from
Oct 6, 2016
Merged

Create GeoMesa suproject #1621

merged 15 commits into from
Oct 6, 2016

Conversation

pomadchin
Copy link
Member

@pomadchin pomadchin commented Sep 5, 2016

  • layer reader
  • layer writer
  • tests coverage
  • GeoMesa 1.2.7

* http://www.opensource.org/licenses/apache2.0.php.
*************************************************************************/

package org.locationtech.geomesa.jobs.mapreduce
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be removed after moving to geomesa 1.2.7 locationtech/geomesa#1077

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please create an issue for this?

@pomadchin pomadchin changed the title [WIP] GeoMesa suproject Create GeoMesa suproject Sep 7, 2016
if(temporal) sftb.add(whenField, classOf[java.util.Date])
val sft = sftb.buildFeatureType
if(temporal) sft.getUserData.put(Constants.SF_PROPERTY_START_TIME, whenField) // when field is date
sft.getUserData.put("geomesa.mixed.geometries", java.lang.Boolean.TRUE) // allow GeoMesa to index points and extents together
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like these tags are specific to Geomesa, so the object should be in geotrellis.geomsea package.

if(temporal) sft.getUserData.put(Constants.SF_PROPERTY_START_TIME, whenField) // when field is date
sft.getUserData.put(SimpleFeatureTypes.MIXED_GEOMETRIES, java.lang.Boolean.TRUE) // allow GeoMesa to index points and extents together
sft.getUserData.put(Hints.USE_PROVIDED_FID, java.lang.Boolean.FALSE) // generate feature ids
sft
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then again we don't really have those concepts in GeoTrellis layers, so this might be a good thing to make a note/issue out of and add once we put those concepts into GeoTrellis (perhaps through sfcurve usage?)

Copy link

@elahrvivaz elahrvivaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me!

import org.opengis.feature.simple.SimpleFeature

trait FeatureToGeoMesaSimpleFeatureMethods[G <: Geometry, T] extends MethodExtensions[Feature[G, T]] {
def toSimpleFeature(featureName: String, featureId: Option[String] = Some(null), crs: Option[CRS] = None)(implicit transmute: T => Seq[(String, Any)]): SimpleFeature =

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't Some(null) kind of break the Option contract?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx, fixed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird, is this PR diff just not updating properly?

Copy link
Member Author

@pomadchin pomadchin Oct 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

._. looks like these comments attached to a certain sha; anyway it's perfect that this pr was not merged in (due to 8f962f3)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. Yeah you can comment commits rather than prs, might of been what happened here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's just the new review functionality for github - it no longer removes comments when a new change comes in that addresses the issue. Which makes it harder to see if issues are addressed, which is pretty crappy of GitHub.


val sft = sftb.buildFeatureType
if(data.map(_._1).contains(whenField)) sft.getUserData.put(Constants.SF_PROPERTY_START_TIME, whenField) // when field is date
sft.getUserData.put(SimpleFeatureTypes.MIXED_GEOMETRIES, java.lang.Boolean.TRUE) // allow GeoMesa to index points and extents together

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI you actually don't need this (although it won't hurt) - it's only if you specify the geometry binding as Geometry, which you don't do in your match above.

val sft = sftb.buildFeatureType
if(data.map(_._1).contains(whenField)) sft.getUserData.put(Constants.SF_PROPERTY_START_TIME, whenField) // when field is date
sft.getUserData.put(SimpleFeatureTypes.MIXED_GEOMETRIES, java.lang.Boolean.TRUE) // allow GeoMesa to index points and extents together
sft.getUserData.put(Hints.USE_PROVIDED_FID, java.lang.Boolean.FALSE) // generate feature ids

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't get used actually - you have to set (or not set) the hint on a per-feature basis. If you don't explicitly set the hint then generating IDs is the default behavior.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, lines removed

}
data.foreach({ case (key, value) => sfb.add(value) })

sfb.buildFeature(featureId.orNull)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as an optimization, you might want to cache the simple feature types - it's probably going to be slow to generate it for each simple feature you create.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cache implemented

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx, implemented.

numPartitions: Option[Int] = None
): RDD[SimpleFeature] = {
val dataStore = instance.accumuloDataStore
dataStore.createSchema(simpleFeatureType)
Copy link

@elahrvivaz elahrvivaz Sep 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a no-op if the schema already exists - but if the schema doesn't exist then there's not going to be any data in it... maybe that is ok here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added an existence check

try {
sf.foreach { rawFeature =>
val newFeature = featureWriter.next()
attrNames.foreach(an => newFeature.setAttribute(an, rawFeature.getAttribute(an)))
Copy link

@elahrvivaz elahrvivaz Sep 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a minor optimization, you could do

(0 until sft.getAttributeCount).foreach(i => newFeature.setAttribute(i, rawFeature.getAttribute(i))

lookup by index is always faster than lookup by attribute name

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx! implemented there

val sft = sftb.buildFeatureType
if(temporal) sft.getUserData.put(Constants.SF_PROPERTY_START_TIME, whenField) // when field is date
sft.getUserData.put(SimpleFeatureTypes.MIXED_GEOMETRIES, java.lang.Boolean.TRUE) // allow GeoMesa to index points and extents together
sft.getUserData.put(Hints.USE_PROVIDED_FID, java.lang.Boolean.FALSE) // generate feature ids

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as noted above - these 2 options won't really have any effect here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lines removed and created an issue #1654

@lossyrob
Copy link
Member

lossyrob commented Oct 5, 2016

Thanks for the review @elahrvivaz. @pomadchin are all the review comments addressed?

@pomadchin
Copy link
Member Author

@lossyrob yes, walked through all comments

@lossyrob
Copy link
Member

lossyrob commented Oct 6, 2016

Looks like there's some optimizations and other comments that still need to be addressed...need to either make the changes or reply to comments about why the suggested change shouldn't happen.

@lossyrob lossyrob merged commit ed0fac8 into locationtech:master Oct 6, 2016
@lossyrob lossyrob added this to the 1.0 milestone Oct 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants