Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[geomesa-users] Key/Index construction question.

Hi there:

I've come across some tests in the project in my quest to understand how indexes work and how is the index partitioned in Accumulo's Key (what goes where, and how is constructed.

val dummyType = SimpleFeatureTypes.createType("DummyType",s"foo:String,bar:Geometry,baz:Date,$DEFAULT_GEOMETRY_PROPERTY_NAME:Geometry,$DEFAULT_DTG_PROPERTY_NAME:Date,$DEFAULT_DTG_END_PROPERTY_NAME:Date")
  val customType = SimpleFeatureTypes.createType("DummyType",s"foo:String,bar:Geometry,baz:Date,*the_geom:Geometry,dt_start:Date,$DEFAULT_DTG_END_PROPERTY_NAME:Date")
  customType.setDtgField("dt_start")
  val dummyEncoder = SimpleFeatureSerializers(dummyType, SerializationType.AVRO)
  val customEncoder = SimpleFeatureSerializers(customType, SerializationType.AVRO)
  val dummyIndexValueEncoder = IndexValueEncoder(dummyType)`
  val geometryFactory = new GeometryFactory(new PrecisionModel, 4326)
  val now = new DateTime().toDate
  val Apr_23_2001 = new DateTime(2001, 4, 23, 12, 5, 0, DateTimeZone.forID("UTC")).toDate
  val schemaEncoding = "%~#s%feature#cstr%99#r::%~#s%0,4#gh::%~#s%4,3#gh%#id"
  val index = IndexSchema.buildKeyEncoder(dummyType, schemaEncoding)
 val line : Geometry = WKTUtils.read("LINESTRING(-78.5000092574703 38.0272986617359,-78.5000196719491 38.0272519798381,-78.5000300864205 38.0272190279085,-78.5000370293904 38.0271853867342,-78.5000439723542 38.027151748305,-78.5000509153117 38.027118112621,-78.5000578582629 38.0270844741902,-78.5000648011924 38.0270329867966,-78.5000648011781 38.0270165108316,-78.5000682379314 38.026999348366,-78.5000752155953 38.026982185898,-78.5000786870602 38.0269657099304,-78.5000856300045 38.0269492339602,-78.5000891014656 38.0269327579921,-78.5000960444045 38.0269162820211,-78.5001064588197 38.0269004925451,-78.5001134017528 38.0268847030715,-78.50012381616 38.0268689135938,-78.5001307590877 38.0268538106175,-78.5001411734882 38.0268387076367,-78.5001550593595 38.0268236046505,-78.5001654737524 38.0268091881659,-78.5001758881429 38.0267954581791,-78.5001897740009 38.0267810416871,-78.50059593303 38.0263663951609,-78.5007972751677 38.0261625038609)")
      val item = AvroSimpleFeatureFactory.buildAvroFeature(dummyType, List("TEST_LINE", line, now, line, now, now), "TEST_LINE")
      val toWrite = new FeatureToWrite(item, "", dummyEncoder, dummyIndexValueEncoder)
      val indexEntries = index.encode(toWrite).toList
      indexEntries.size must equalTo(1)
      indexEntries.head.size() mustEqual(6)
      val cf = new Text(indexEntries.head.getUpdates.get(0).getColumnFamily)
      val cq = new Text(indexEntries.head.getUpdates.get(0).getColumnQualifier)
      val keyStr = cf + "::" + cq val line : Geometry = WKTUtils.read("LINESTRING(-78.5000092574703 38.0272986617359,-78.5000196719491 38.0272519798381,-78.5000300864205 38.0272190279085,-78.5000370293904 38.0271853867342,-78.5000439723542 38.027151748305,-78.5000509153117 38.027118112621,-78.5000578582629 38.0270844741902,-78.5000648011924 38.0270329867966,-78.5000648011781 38.0270165108316,-78.5000682379314 38.026999348366,-78.5000752155953 38.026982185898,-78.5000786870602 38.0269657099304,-78.5000856300045 38.0269492339602,-78.5000891014656 38.0269327579921,-78.5000960444045 38.0269162820211,-78.5001064588197 38.0269004925451,-78.5001134017528 38.0268847030715,-78.50012381616 38.0268689135938,-78.5001307590877 38.0268538106175,-78.5001411734882 38.0268387076367,-78.5001550593595 38.0268236046505,-78.5001654737524 38.0268091881659,-78.5001758881429 38.0267954581791,-78.5001897740009 38.0267810416871,-78.50059593303 38.0263663951609,-78.5007972751677 38.0261625038609)")
      val item = AvroSimpleFeatureFactory.buildAvroFeature(dummyType, List("TEST_LINE", line, now, line, now, now), "TEST_LINE")
      val toWrite = new FeatureToWrite(item, "", dummyEncoder, dummyIndexValueEncoder)
      val indexEntries = index.encode(toWrite).toList
      indexEntries.size must equalTo(1)
      indexEntries.head.size() mustEqual(6)
      val cf = new Text(indexEntries.head.getUpdates.get(0).getColumnFamily)
      val cq = new Text(indexEntries.head.getUpdates.get(0).getColumnQualifier)
      val keyStr = cf + "::" + cq

How all those points in the Linestring translate to encoding only 6 rows in Accumulo? As far as I understand, the Key definition (string :: gh :: gh + ID) should encode a single point correct? What am I missing in the process here?

If somebody could walk me through this example with special attention to how the key is being constructed it would be very much appreciated.

Thank you for your time

Moises


Back to the top