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

FilterOut only care about _to field on edge. #133

Closed SteamShon closed 8 years ago

SteamShon commented 8 years ago

current implementation only cares about _to field value for filtering out. (https://github.com/kakao/s2graph/blob/develop/app/controllers/PostProcess.scala#L73)

maybe it is more intuitive to filterout queryResult based on (from, label, dir, to) which is reference of edge.

SteamShon commented 8 years ago

test data

curl -XPOST localhost:9000/graphs/edges/insert -H 'Content-Type: Application/json' -d '
[
    {"timestamp": 1, "from": 10001, "to": 10, "label": "s2graph_label_test_weak", "props": {"time": 10}},
    {"timestamp": 1, "from": 10001, "to": 11, "label": "s2graph_label_test_weak", "props": {"time": 20}},
    {"timestamp": 2, "from": 10001, "to": 12, "label": "s2graph_label_test_weak", "props": {"time": 30}},
    {"timestamp": 3, "from": 10001, "to": 13, "label": "s2graph_label_test_weak", "props": {"time": 40}},
    {"timestamp": 1, "from": 10002, "to": 11, "label": "s2graph_label_test_weak", "props": {"time": 10}},
    {"timestamp": 2, "from": 10002, "to": 12, "label": "s2graph_label_test_weak", "props": {"time": -10}},
    {"timestamp": 3, "from": 10002, "to": 13, "label": "s2graph_label_test_weak", "props": {"time": -30}}
]
'

and here is improved filterOut functions.

{
    "select": [
        "label",
        "time"
    ],
    "filterOutFields": [
        "label",
        "time"
    ],
    "filterOut": {
        "srcVertices": [
            {
                "serviceName": "s2graph",
                "columnName": "user_id_test",
                "id": 10002
            }
        ],
        "steps": [
            {
                "step": [
                    {
                        "label": "s2graph_label_test_weak",
                        "direction": "out",
                        "offset": 0,
                        "limit": 10,
                        "duplicate": "raw"
                    }
                ]
            }
        ]
    },
    "srcVertices": [
        {
            "serviceName": "s2graph",
            "columnName": "user_id_test",
            "id": 10001
        }
    ],
    "steps": [
        {
            "step": [
                {
                    "label": "s2graph_label_test_weak",
                    "direction": "out",
                    "offset": 0,
                    "limit": 10,
                    "duplicate": "raw"
                }
            ]
        }
    ]
}

then expected result would be edges start from 10001, and time in (20, 30, 40)

{
    "size": 3,
    "degrees": [],
    "results": [
        {
            "label": "s2graph_label_test_weak",
            "props": {
                "weight": 0,
                "timestamp": 3,
                "is_blocked": false,
                "is_hidden": false,
                "time": 40
            }
        },
        {
            "label": "s2graph_label_test_weak",
            "props": {
                "weight": 0,
                "timestamp": 2,
                "is_blocked": false,
                "is_hidden": false,
                "time": 30
            }
        },
        {
            "label": "s2graph_label_test_weak",
            "props": {
                "weight": 0,
                "timestamp": 1,
                "is_blocked": false,
                "is_hidden": false,
                "time": 20
            }
        }
    ],
    "impressionId": 1972178414
}
SteamShon commented 8 years ago

This issue is resolved by https://github.com/kakao/s2graph/pull/134