예제 #1
0
def generate_address_book_graph(session, size):
    to_run = [
        ALLOW_SCANS,
        "schema.propertyKey('name').Text().create()\n" +
        "schema.propertyKey('pointPropWithBoundsWithSearchIndex')." +
        getPointTypeWithBounds(-100, -100, 100, 100) + ".create()\n" +
        "schema.propertyKey('pointPropWithBounds')." +
        getPointTypeWithBounds(-100, -100, 100, 100) + ".create()\n" +
        "schema.propertyKey('pointPropWithGeoBoundsWithSearchIndex')." +
        getPointType() + ".create()\n" +
        "schema.propertyKey('pointPropWithGeoBounds')." + getPointType() +
        ".create()\n" + "schema.propertyKey('city').Text().create()\n" +
        "schema.propertyKey('state').Text().create()\n" +
        "schema.propertyKey('description').Text().create()\n" +
        "schema.vertexLabel('person').properties('name', 'city', 'state', 'description', 'pointPropWithBoundsWithSearchIndex', 'pointPropWithBounds', 'pointPropWithGeoBoundsWithSearchIndex', 'pointPropWithGeoBounds').create()",
        "schema.vertexLabel('person').index('searchPointWithBounds').secondary().by('pointPropWithBounds').add()",
        "schema.vertexLabel('person').index('searchPointWithGeoBounds').secondary().by('pointPropWithGeoBounds').add()",
        "g.addV('person').property('name', 'Paul Thomas Joe').property('city', 'Rochester').property('state', 'MN').property('pointPropWithBoundsWithSearchIndex', Geo.point(-92.46295, 44.0234)).property('pointPropWithBounds', Geo.point(-92.46295, 44.0234)).property('pointPropWithGeoBoundsWithSearchIndex', Geo.point(-92.46295, 44.0234)).property('pointPropWithGeoBounds', Geo.point(-92.46295, 44.0234)).property('description', 'Lives by the hospital')",
        "g.addV('person').property('name', 'George Bill Steve').property('city', 'Minneapolis').property('state', 'MN').property('pointPropWithBoundsWithSearchIndex', Geo.point(-93.266667, 44.093333)).property('pointPropWithBounds', Geo.point(-93.266667, 44.093333)).property('pointPropWithGeoBoundsWithSearchIndex', Geo.point(-93.266667, 44.093333)).property('pointPropWithGeoBounds', Geo.point(-93.266667, 44.093333)).property('description', 'A cold dude')",
        "g.addV('person').property('name', 'James Paul Smith').property('city', 'Chicago').property('state', 'IL').property('pointPropWithBoundsWithSearchIndex', Geo.point(-87.684722, 41.836944)).property('description', 'Likes to hang out')",
        "g.addV('person').property('name', 'Jill Alice').property('city', 'Atlanta').property('state', 'GA').property('pointPropWithBoundsWithSearchIndex', Geo.point(-84.39, 33.755)).property('description', 'Enjoys a nice cold coca cola')",
    ]

    if not DSE_VERSION.startswith("5.0"):
        to_run.append(
            "schema.vertexLabel('person').index('search').search().by('pointPropWithBoundsWithSearchIndex').withError(0.00001, 0.0).by('pointPropWithGeoBoundsWithSearchIndex').withError(0.00001, 0.0).add()"
        )

    for run in to_run:
        session.execute_graph(run)
예제 #2
0
def getLineType():
    if DSE_VERSION.startswith("5.0"):
        return "Linestring()"

    return "Linestring().withGeoBounds()"
예제 #3
0
def getPolygonType():
    if DSE_VERSION.startswith("5.0"):
        return "Polygon()"

    return "Polygon().withGeoBounds()"
예제 #4
0
def getPointTypeWithBounds(lowerX, lowerY, upperX, upperY):
    if DSE_VERSION.startswith("5.0"):
        return "Point()"

    return "Point().withBounds({0}, {1}, {2}, {3})".format(
        lowerX, lowerY, upperX, upperY)