kakao / s2graph

This code base is retained for historical interest only, please visit Apache Incubator Repo for latest one
https://github.com/apache/incubator-s2graph
Other
250 stars 32 forks source link

Query Option "interval" is Broken #209

Closed HyunsungJo closed 8 years ago

HyunsungJo commented 8 years ago

Problem

The "interval" option doesn't seem to work on secondary indices.

Steps to Reproduce Issue

  1. Create service.

    curl -XPOST localhost:9000/graphs/createService -H 'Content-Type: Application/json' -d '
    {
     "serviceName": "interval",
     "hTableName": "interval-dev"
    }
    '
  2. Create label with more than multiple indices.

    curl -XPOST localhost:9000/graphs/createLabel -H 'Content-Type: Application/json' -d '
    {
     "label": "interval_test",
     "srcServiceName": "interval",
     "srcColumnName": "ad_id",
     "srcColumnType": "string",
     "tgtServiceName": "interval",
     "tgtColumnName": "url",
     "tgtColumnType": "string",
    "isDirected": "true",
    "indices": [
       {
           "name": "_PK",
           "propNames": [
               "_timestamp"
           ]
       },
       {
           "name": "IDX_ACTION_TYPE",
           "propNames": [
               "actionType",
               "_timestamp"
           ]
       }
    ],
    "props": [
       {
           "name": "serviceName",
           "defaultValue": "",
           "dataType": "string"
       },
       {
           "name": "actionType",
           "defaultValue": "",
           "dataType": "string"
       }
    ],
    "consistencyLevel": "strong"
    }
    '
  3. Insert test data.

    curl -XPOST -H 'Content-Type: application/json' localhost:9000/graphs/edges/insert -d '
    [
      {
          "from": "jojo",
          "to": "www.kakaocorp.com",
          "label": "interval_test",
          "props": {"serviceName": "talk-scrap", "actionType": "share"},
          "timestamp": 1433495457557
      }
    ]
    '
  4. Query with interval on primary index. => This works! (edge returned)

    curl -XPOST localhost:9000/graphs/getEdges -H 'Content-type: Application/json' -d '
    {
       "srcVertices": [
           {
               "serviceName": "interval",
               "columnName": "ad_id",
               "id": "jojo"
           }
       ],
       "steps": [
           {
               "step": [
                   {
                       "label": "interval_test",
                       "index": "_PK",
                       "interval": {
                           "from": [
                               {
                                   "_timestamp": 1433495457556
                               }
                           ],
                           "to": [
                               {
                                   "_timestamp": 1433495457558
                               }
                           ]
                       }
                   }
               ]
           }
       ]
    }
    '
  5. Query with interval on secondary index. => Doesn't work!! (empty result..)

    curl -XPOST localhost:9000/graphs/getEdges -H 'Content-type: Application/json' -d '
    {
       "srcVertices": [
           {
               "serviceName": "interval",
               "columnName": "ad_id",
               "id": "jojo"
           }
       ],
       "steps": [
           {
               "step": [
                   {
                       "label": "interval_test",
                       "index": "IDX_ACTION_TYPE",
                       "interval": {
                           "from": [
                               {
                                   "actionType": "share"
                               }
                           ],
                           "to": [
                               {
                                   "actionType": "share"
                               }
                           ]
                       }
                   }
               ]
           }
       ]
    }
    '

    Cause of Issue

The function interval() in QueryParam.scala uses labelOrderSeq witch is currently not set at time of function call. In function parseQueryParam() of RequestParser.scala, .interval(interval) should come after .labelOrderSeq(indexSeq).

SteamShon commented 8 years ago

:+1: