Fix build against latest code base 07/1007/2
authorTasuku Suzuki <stasuku@gmail.com>
Wed, 1 Feb 2017 13:02:39 +0000 (22:02 +0900)
committerstasuku <stasuku@gmail.com>
Wed, 1 Feb 2017 13:08:10 +0000 (22:08 +0900)
Change-Id: Ib97faeb32e5598f9b556454a73bab2f19889039b
Reviewed-on: http://codereview.qt-users.jp/1007
Reviewed-by: <stasuku@gmail.com>
Tested-by: <stasuku@gmail.com>
72 files changed:
examples/cpp/anomaly/anomaly.pro [deleted file]
examples/examples.pro
examples/jubatus/cpp/anomaly/anomaly.pro [new file with mode: 0644]
examples/jubatus/cpp/anomaly/network_intrusion_detection/main.cpp [new file with mode: 0644]
examples/jubatus/cpp/anomaly/network_intrusion_detection/network_intrusion_detection.json [new file with mode: 0644]
examples/jubatus/cpp/anomaly/network_intrusion_detection/network_intrusion_detection.pro [new file with mode: 0644]
examples/jubatus/cpp/anomaly/nikkei_stock_avarage/main.cpp [moved from examples/cpp/anomaly/nikkei_stock_avarage/main.cpp with 100% similarity]
examples/jubatus/cpp/anomaly/nikkei_stock_avarage/nikkei_stock_avarage.json [moved from examples/cpp/anomaly/nikkei_stock_avarage/nikkei_stock_avarage.json with 100% similarity]
examples/jubatus/cpp/anomaly/nikkei_stock_avarage/nikkei_stock_avarage.pro [moved from examples/cpp/anomaly/nikkei_stock_avarage/nikkei_stock_avarage.pro with 63% similarity]
examples/jubatus/cpp/classifier/classifier.pro [moved from examples/cpp/classifier/classifier.pro with 100% similarity]
examples/jubatus/cpp/classifier/gender/gender.json [moved from examples/cpp/classifier/gender/gender.json with 100% similarity]
examples/jubatus/cpp/classifier/gender/gender.pro [moved from examples/cpp/classifier/gender/gender.pro with 70% similarity]
examples/jubatus/cpp/classifier/gender/main.cpp [moved from examples/cpp/classifier/gender/main.cpp with 100% similarity]
examples/jubatus/cpp/classifier/gender/widget.cpp [moved from examples/cpp/classifier/gender/widget.cpp with 100% similarity]
examples/jubatus/cpp/classifier/gender/widget.h [moved from examples/cpp/classifier/gender/widget.h with 100% similarity]
examples/jubatus/cpp/classifier/gender/widget.ui [moved from examples/cpp/classifier/gender/widget.ui with 100% similarity]
examples/jubatus/cpp/cpp.pro [moved from examples/cpp/cpp.pro with 100% similarity]
examples/jubatus/cpp/recommender/npb_similar_player/baseball.csv [moved from examples/cpp/recommender/npb_similar_player/baseball.csv with 100% similarity]
examples/jubatus/cpp/recommender/npb_similar_player/dialog.cpp [moved from examples/cpp/recommender/npb_similar_player/dialog.cpp with 100% similarity]
examples/jubatus/cpp/recommender/npb_similar_player/dialog.h [moved from examples/cpp/recommender/npb_similar_player/dialog.h with 100% similarity]
examples/jubatus/cpp/recommender/npb_similar_player/dialog.ui [moved from examples/cpp/recommender/npb_similar_player/dialog.ui with 100% similarity]
examples/jubatus/cpp/recommender/npb_similar_player/main.cpp [moved from examples/cpp/recommender/npb_similar_player/main.cpp with 100% similarity]
examples/jubatus/cpp/recommender/npb_similar_player/npb_similar_player.json [moved from examples/cpp/recommender/npb_similar_player/npb_similar_player.json with 100% similarity]
examples/jubatus/cpp/recommender/npb_similar_player/npb_similar_player.pro [moved from examples/cpp/recommender/npb_similar_player/npb_similar_player.pro with 73% similarity]
examples/jubatus/cpp/recommender/npb_similar_player/npb_similar_player.qrc [moved from examples/cpp/recommender/npb_similar_player/npb_similar_player.qrc with 100% similarity]
examples/jubatus/cpp/recommender/recommender.pro [moved from examples/cpp/recommender/recommender.pro with 100% similarity]
examples/jubatus/cpp/regression/regression.pro [moved from examples/cpp/regression/regression.pro with 100% similarity]
examples/jubatus/cpp/regression/rent_data/dialog.cpp [moved from examples/cpp/regression/rent_data/dialog.cpp with 100% similarity]
examples/jubatus/cpp/regression/rent_data/dialog.h [moved from examples/cpp/regression/rent_data/dialog.h with 100% similarity]
examples/jubatus/cpp/regression/rent_data/dialog.ui [moved from examples/cpp/regression/rent_data/dialog.ui with 100% similarity]
examples/jubatus/cpp/regression/rent_data/main.cpp [moved from examples/cpp/regression/rent_data/main.cpp with 100% similarity]
examples/jubatus/cpp/regression/rent_data/rent-data.csv [moved from examples/cpp/regression/rent_data/rent-data.csv with 100% similarity]
examples/jubatus/cpp/regression/rent_data/rent_data.json [moved from examples/cpp/regression/rent_data/rent_data.json with 100% similarity]
examples/jubatus/cpp/regression/rent_data/rent_data.pro [moved from examples/cpp/regression/rent_data/rent_data.pro with 73% similarity]
examples/jubatus/cpp/regression/rent_data/rent_data.qrc [moved from examples/cpp/regression/rent_data/rent_data.qrc with 100% similarity]
examples/jubatus/jubatus.pro [new file with mode: 0644]
examples/jubatus/qml/classifier/classifier.pro [moved from examples/qml/classifier/classifier.pro with 100% similarity]
examples/jubatus/qml/classifier/gender/Button.qml [moved from examples/qml/classifier/gender/Button.qml with 100% similarity]
examples/jubatus/qml/classifier/gender/Selector.qml [moved from examples/qml/classifier/gender/Selector.qml with 100% similarity]
examples/jubatus/qml/classifier/gender/gender.json [moved from examples/qml/classifier/gender/gender.json with 100% similarity]
examples/jubatus/qml/classifier/gender/gender.pro [moved from examples/qml/classifier/gender/gender.pro with 69% similarity]
examples/jubatus/qml/classifier/gender/gender.qml [moved from examples/qml/classifier/gender/gender.qml with 100% similarity]
examples/jubatus/qml/classifier/gender/gender.qrc [moved from examples/qml/classifier/gender/gender.qrc with 100% similarity]
examples/jubatus/qml/classifier/gender/main.cpp [moved from examples/qml/classifier/gender/main.cpp with 100% similarity]
examples/jubatus/qml/qml.pro [moved from examples/qml/qml.pro with 100% similarity]
examples/jubatus/qml/recommender/npb_similar_player/baseball.csv [moved from examples/qml/recommender/npb_similar_player/baseball.csv with 100% similarity]
examples/jubatus/qml/recommender/npb_similar_player/main.cpp [moved from examples/qml/recommender/npb_similar_player/main.cpp with 100% similarity]
examples/jubatus/qml/recommender/npb_similar_player/npb_similar_player.json [moved from examples/qml/recommender/npb_similar_player/npb_similar_player.json with 100% similarity]
examples/jubatus/qml/recommender/npb_similar_player/npb_similar_player.pro [moved from examples/qml/recommender/npb_similar_player/npb_similar_player.pro with 66% similarity]
examples/jubatus/qml/recommender/npb_similar_player/npb_similar_player.qml [moved from examples/qml/recommender/npb_similar_player/npb_similar_player.qml with 100% similarity]
examples/jubatus/qml/recommender/npb_similar_player/npb_similar_player.qrc [moved from examples/qml/recommender/npb_similar_player/npb_similar_player.qrc with 100% similarity]
examples/jubatus/qml/recommender/recommender.pro [moved from examples/qml/recommender/recommender.pro with 100% similarity]
examples/jubatus/qml/regression/iris/iris.json [moved from examples/qml/regression/iris/iris.json with 100% similarity]
examples/jubatus/qml/regression/iris/iris.pro [moved from examples/qml/regression/iris/iris.pro with 86% similarity]
examples/jubatus/qml/regression/iris/main.cpp [moved from examples/qml/regression/iris/main.cpp with 100% similarity]
examples/jubatus/qml/regression/iris/qml/iris/iris.data [moved from examples/qml/regression/iris/qml/iris/iris.data with 100% similarity]
examples/jubatus/qml/regression/iris/qml/iris/iris.qml [moved from examples/qml/regression/iris/qml/iris/iris.qml with 100% similarity]
examples/jubatus/qml/regression/iris/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.cpp [moved from examples/qml/regression/iris/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.cpp with 100% similarity]
examples/jubatus/qml/regression/iris/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.h [moved from examples/qml/regression/iris/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.h with 100% similarity]
examples/jubatus/qml/regression/iris/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri [moved from examples/qml/regression/iris/qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri with 100% similarity]
examples/jubatus/qml/regression/regression.pro [moved from examples/qml/regression/regression.pro with 100% similarity]
src/imports/jubatus/qmljubatusclassifier.h
src/imports/jubatus/qmljubatusrecommender.h
src/imports/jubatus/qmljubatusregression.h
src/jubatus/anomaly/qjubatusanomaly.h
src/jubatus/classifier/qjubatusclassifier.h
src/jubatus/client/qjubatusclient.cpp
src/jubatus/client/qjubatusclient.h
src/jubatus/clustering/qjubatusclustering.cpp
src/jubatus/clustering/qjubatusclustering.h
src/jubatus/recommender/qjubatusrecommender.h
src/jubatus/regression/qjubatusregression.h

diff --git a/examples/cpp/anomaly/anomaly.pro b/examples/cpp/anomaly/anomaly.pro
deleted file mode 100644 (file)
index 4cc3114..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS += nikkei_stock_avarage
index d1ff340..5bf556a 100644 (file)
@@ -1,6 +1,3 @@
 TEMPLATE = subdirs
-!isEmpty(QT.jubatus.name) {
-       SUBDIRS += cpp
-       !isEmpty(QT.qml.name): SUBDIRS += qml
-}
+SUBDIRS += jubatus
 
diff --git a/examples/jubatus/cpp/anomaly/anomaly.pro b/examples/jubatus/cpp/anomaly/anomaly.pro
new file mode 100644 (file)
index 0000000..da0c597
--- /dev/null
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += network_intrusion_detection
diff --git a/examples/jubatus/cpp/anomaly/network_intrusion_detection/main.cpp b/examples/jubatus/cpp/anomaly/network_intrusion_detection/main.cpp
new file mode 100644 (file)
index 0000000..3cb5bad
--- /dev/null
@@ -0,0 +1,121 @@
+#include <QtCore>
+#include <QtNetwork>
+#include <QtWidgets>
+#include <QtJubatus>
+
+class Graph : public QWidget
+{
+    Q_OBJECT
+public:
+    Graph(QWidget *parent = 0);
+
+protected:
+    void paintEvent(QPaintEvent *e);
+
+private:
+    QNetworkAccessManager manager;
+    struct Data {
+        Data() : first(0), last(0), score(0) {}
+        float first;
+        float last;
+        float score;
+    };
+
+    QList<Data> data;
+};
+
+Graph::Graph(QWidget *parent)
+    : QWidget(parent)
+{
+    QJubatusAnomaly anomaly;
+
+    QFile file("kddcup.data_10_percent");
+    if (!file.open(QFile::ReadOnly)) {
+        qWarning() << file.errorString();
+        return;
+    }
+
+    QTextStream stream(&file);
+    while (!stream.atEnd()) {
+        QStringList fields = stream.readLine().split(',');
+        QVariantMap params;
+        int i = 0;
+
+        params["duration"] = fields.at(i++).toFloat();
+        params["protocol_type"] = fields.at(i++);
+        params["service"] = fields.at(i++);
+        params["flag"] = fields.at(i++);
+        params["src_bytes"] = fields.at(i++).toFloat();
+        params["dst_bytes"] = fields.at(i++).toFloat();
+        params["land"] = fields.at(i++);
+        params["wrong_fragment"] = fields.at(i++).toFloat();
+        params["urgent"] = fields.at(i++).toFloat();
+        params["hot"] = fields.at(i++).toFloat();
+        params["num_failed_logins"] = fields.at(i++).toFloat();
+        params["logged_in"] = fields.at(i++);
+        params["num_compromised"] = fields.at(i++).toFloat();
+        params["root_shell"] = fields.at(i++).toFloat();
+        params["su_attempted"] = fields.at(i++).toFloat();
+        params["num_root"] = fields.at(i++).toFloat();
+        params["num_file_creations"] = fields.at(i++).toFloat();
+        params["num_shells"] = fields.at(i++).toFloat();
+        params["num_access_files"] = fields.at(i++).toFloat();
+        params["num_outbound_cmds"] = fields.at(i++).toFloat();
+        params["is_host_login"] = fields.at(i++);
+        params["is_guest_login"] = fields.at(i++);
+        params["count"] = fields.at(i++).toFloat();
+        params["srv_count"] = fields.at(i++).toFloat();
+        params["serror_rate"] = fields.at(i++).toFloat();
+        params["srv_serror_rate"] = fields.at(i++).toFloat();
+        params["rerror_rate"] = fields.at(i++).toFloat();
+        params["srv_rerror_rate"] = fields.at(i++).toFloat();
+        params["same_srv_rate"] = fields.at(i++).toFloat();
+        params["diff_srv_rate"] = fields.at(i++).toFloat();
+        params["srv_diff_host_rate"] = fields.at(i++).toFloat();
+        params["dst_host_count"] = fields.at(i++).toFloat();
+        params["dst_host_srv_count"] = fields.at(i++).toFloat();
+        params["dst_host_same_srv_rate"] = fields.at(i++).toFloat();
+        params["dst_host_diff_srv_rate"] = fields.at(i++).toFloat();
+        params["dst_host_same_src_port_rate"] = fields.at(i++).toFloat();
+        params["dst_host_srv_diff_host_rate"] = fields.at(i++).toFloat();
+        params["dst_host_serror_rate"] = fields.at(i++).toFloat();
+        params["dst_host_srv_serror_rate"] = fields.at(i++).toFloat();
+        params["dst_host_rerror_rate"] = fields.at(i++).toFloat();
+        params["dst_host_srv_rerror_rate"] = fields.at(i++).toFloat();
+        QString label = fields.at(i++);
+        QJubatusAnomaly::IdAndScore ret = anomaly.add(params);
+        if (!qIsInf(ret.score) && !qFuzzyCompare(ret.score, 1.0f)) {
+            qDebug() << label << ret.id << ret.score;
+        }
+    }
+
+    file.close();
+}
+
+void Graph::paintEvent(QPaintEvent *e)
+{
+    if (data.isEmpty()) return;
+
+    QPainter p(this);
+
+    float x = 0;
+    float dx = (float)width() / data.count();
+    float dy = height();
+
+    foreach (const Data &d, data) {
+        p.fillRect(QRectF(x, (1.0 - qMax(d.first, d.last)) * dy, dx, qAbs(d.last - d.first) * dy), QColor(qIsInf(d.score) ? Qt::red : Qt::black));
+        x += dx;
+    }
+}
+
+int main(int argc, char **argv)
+{
+    QApplication app(argc, argv);
+
+    Graph graph;
+    graph.show();
+
+    return app.exec();
+}
+
+#include "main.moc"
diff --git a/examples/jubatus/cpp/anomaly/network_intrusion_detection/network_intrusion_detection.json b/examples/jubatus/cpp/anomaly/network_intrusion_detection/network_intrusion_detection.json
new file mode 100644 (file)
index 0000000..3135490
--- /dev/null
@@ -0,0 +1,26 @@
+{
+ "method" : "lof",
+ "parameter" : {
+  "nearest_neighbor_num" : 10,
+  "reverse_nearest_neighbor_num" : 30,
+  "method" : "euclid_lsh",
+  "parameter" : {
+   "hash_num" : 8,
+   "table_num" : 16,
+   "probe_num" : 64,
+   "bin_width" : 10,
+   "seed" : 1234
+  }
+ },
+
+ "converter" : {
+  "string_filter_types": {},
+  "string_filter_rules": [],
+  "num_filter_types": {},
+  "num_filter_rules": [],
+  "string_types": {},
+  "string_rules": [{"key":"*", "type":"str", "global_weight" : "bin", "sample_weight" : "bin"}],
+  "num_types": {},
+  "num_rules": [{"key" : "*", "type" : "num"}]
+ }
+}
diff --git a/examples/jubatus/cpp/anomaly/network_intrusion_detection/network_intrusion_detection.pro b/examples/jubatus/cpp/anomaly/network_intrusion_detection/network_intrusion_detection.pro
new file mode 100644 (file)
index 0000000..a5251a0
--- /dev/null
@@ -0,0 +1,11 @@
+TEMPLATE = app
+TARGET = jubatus-network-intrusion-detection
+QT = core network gui widgets jubatus
+CONFIG += c++11
+SOURCES = main.cpp
+
+OTHER_FILES += network_intrusion_detection.json
+
+target.path = $$[QT_INSTALL_EXAMPLES]/jubatus/cpp/anomaly/network_intrusion_detection
+INSTALLS += target
+
@@ -14,3 +14,6 @@ FORMS += \
     widget.ui
 
 OTHER_FILES += gender.json
+
+target.path = $$[QT_INSTALL_EXAMPLES]/jubatus/cpp/classifier/gender
+INSTALLS += target
@@ -15,3 +15,6 @@ FORMS += \
 
 HEADERS += \
     dialog.h
+
+target.path = $$[QT_INSTALL_EXAMPLES]/jubatus/cpp/regression/rent_data
+INSTALLS += target
diff --git a/examples/jubatus/jubatus.pro b/examples/jubatus/jubatus.pro
new file mode 100644 (file)
index 0000000..d1ff340
--- /dev/null
@@ -0,0 +1,6 @@
+TEMPLATE = subdirs
+!isEmpty(QT.jubatus.name) {
+       SUBDIRS += cpp
+       !isEmpty(QT.qml.name): SUBDIRS += qml
+}
+
@@ -10,3 +10,6 @@ RESOURCES += \
 OTHER_FILES += gender.qml gender.json \
     Selector.qml \
     Button.qml
+
+target.path = $$[QT_INSTALL_EXAMPLES]/jubatus/qml/classifier/gender
+INSTALLS += target
@@ -8,3 +8,6 @@ RESOURCES += \
     npb_similar_player.qrc
 
 OTHER_FILES += npb_similar_player.qml npb_similar_player.json
+
+target.path = $$[QT_INSTALL_EXAMPLES]/jubatus/qml/recommender/npb_similar_player
+INSTALLS += target
similarity index 86%
rename from examples/qml/regression/iris/iris.pro
rename to examples/jubatus/qml/regression/iris/iris.pro
index d3cec94..d7e923d 100644 (file)
@@ -17,3 +17,6 @@ include(qtquick2controlsapplicationviewer/qtquick2controlsapplicationviewer.pri)
 qtcAddDeployment()
 
 OTHER_FILES += iris.json
+
+target.path = $$[QT_INSTALL_EXAMPLES]/jubatus/qml/regression/iris
+INSTALLS += target
index 8855a08..7e3e961 100644 (file)
@@ -7,7 +7,7 @@ class QmlJubatusClassifier : public QJubatusClassifier
 {
     Q_OBJECT
 public:
-    QmlJubatusClassifier(QObject *parent = 0);
+    QmlJubatusClassifier(QObject *parent = nullptr);
 
     Q_INVOKABLE void train(const QString &label, const QVariantMap &data);
     Q_INVOKABLE QVariantList classify(const QVariantMap &data);
index e03a148..2a9e56a 100644 (file)
@@ -7,7 +7,7 @@ class QmlJubatusRecommender : public QJubatusRecommender
 {
     Q_OBJECT
 public:
-    explicit QmlJubatusRecommender(QObject *parent = 0);
+    explicit QmlJubatusRecommender(QObject *parent = nullptr);
 
     Q_INVOKABLE QVariantList similarRowFromId(const QString &id, uint size);
     Q_INVOKABLE QVariantList similarRowFromDatum(const QVariantMap &data, uint size);
index f67b4e8..d8e9c86 100644 (file)
@@ -7,7 +7,7 @@ class QmlJubatusRegression : public QJubatusRegression
 {
     Q_OBJECT
 public:
-    explicit QmlJubatusRegression(QObject *parent = 0);
+    explicit QmlJubatusRegression(QObject *parent = nullptr);
 
     Q_INVOKABLE bool train(const QVariantMap &data, float score);
     Q_INVOKABLE float estimate(const QVariantMap &data);
index 5418ec7..3fa791b 100644 (file)
@@ -45,7 +45,7 @@ class JUBATUS_EXPORT QJubatusAnomaly : public QJubatusClient
 {
     Q_OBJECT
 public:
-    explicit QJubatusAnomaly(QObject *parent = 0);
+    explicit QJubatusAnomaly(QObject *parent = nullptr);
 
     struct IdAndScore {
         IdAndScore() : score(0.0) {}
index 850c9f6..0eaed1a 100644 (file)
@@ -47,7 +47,7 @@ class JUBATUS_EXPORT QJubatusClassifier : public QJubatusClient
 {
     Q_OBJECT
 public:
-    explicit QJubatusClassifier(QObject *parent = 0);
+    explicit QJubatusClassifier(QObject *parent = nullptr);
 
     struct LabeledDatum {
         QString label;
index 83bed9a..24cc860 100644 (file)
@@ -111,10 +111,10 @@ void QJubatusClient::setTimeout(double timeout)
     emit timeoutChanged(timeout);
 }
 
-bool QJubatusClient::save(const QString &id)
+QHash<QString, QString> QJubatusClient::save(const QString &id)
 {
-    bool ret = false;
-    EXEC_JUBATUS_COMMAND_PRIVATE( ret = m_client->save(convert(id));, m_client )
+    QHash<QString, QString> ret;
+    EXEC_JUBATUS_COMMAND_PRIVATE( ret = convert(m_client->save(convert(id)));, m_client )
     return ret;
 }
 
@@ -221,3 +221,22 @@ QList<QVariantMap> QJubatusClient::convert(const std::vector<jubatus::client::co
     }
     return ret;
 }
+
+std::map<std::string, std::string> QJubatusClient::convert(const QHash<QString, QString> &data) const
+{
+    std::map<std::string, std::string> ret;
+    QHashIterator<QString, QString> i(data);
+    while (i.hasNext()) {
+        ret[convert(i.key())] = convert(i.value());
+    }
+    return ret;
+}
+
+QHash<QString, QString> QJubatusClient::convert(const std::map<std::string, std::string> &data) const
+{
+    QHash<QString, QString> ret;
+    for(const auto itr : data) {
+        ret.insert(convert(itr.first), convert(itr.second));
+    }
+    return ret;
+}
index 6ed2c83..276eee6 100644 (file)
@@ -49,23 +49,23 @@ class JUBATUS_EXPORT QJubatusClient : public QObject
     Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
     Q_PROPERTY(double timeout READ timeout WRITE setTimeout NOTIFY timeoutChanged)
 public:
-    explicit QJubatusClient(QObject *parent = 0);
+    explicit QJubatusClient(QObject *parent = nullptr);
 
     const QString &host() const;
     int port() const;
     const QString &name() const;
     double timeout() const;
 
-    bool save(const QString &id);
+    QHash<QString, QString> save(const QString &id);
     bool load(const QString &id);
 
-public slots:
+public Q_SLOTS:
     void setHost(const QString &host);
     void setPort(int port);
     void setName(const QString &name);
     void setTimeout(double timeout);
 
-signals:
+Q_SIGNALS:
     void hostChanged(const QString &host);
     void portChanged(int port);
     void nameChanged(const QString &name);
@@ -90,6 +90,8 @@ protected:
     QVariantMap convert(const jubatus::client::common::datum &data) const;
     std::vector<jubatus::client::common::datum> convert(const QList<QVariantMap> &data) const;
     QList<QVariantMap> convert(const std::vector<jubatus::client::common::datum> &data) const;
+    std::map<std::string, std::string> convert(const QHash<QString, QString> &data) const;
+    QHash<QString, QString> convert(const std::map<std::string, std::string> &data) const;
 
 private:
     class Private;
index 25b7ebb..a306577 100644 (file)
@@ -35,7 +35,7 @@ QJubatusClustering::QJubatusClustering(QObject *parent)
 {
 }
 
-bool QJubatusClustering::push(const QList<QVariantMap> &data)
+bool QJubatusClustering::push(const QList<IndexedPoint> &data)
 {
     bool ret = false;
     EXEC_JUBATUS_COMMAND( ret = client()->push(convert(data)); )
@@ -93,6 +93,7 @@ QList<QJubatusClustering::WeightedDatum> QJubatusClustering::convert(const std::
     }
     return ret;
 }
+
 QList<QList<QJubatusClustering::WeightedDatum> > QJubatusClustering::convert(const std::vector<std::vector<jubatus::clustering::weighted_datum> > &data) const
 {
     QList<QList<QJubatusClustering::WeightedDatum> > ret;
@@ -102,6 +103,23 @@ QList<QList<QJubatusClustering::WeightedDatum> > QJubatusClustering::convert(con
     return ret;
 }
 
+jubatus::clustering::indexed_point QJubatusClustering::convert(const QJubatusClustering::IndexedPoint &data) const
+{
+    jubatus::clustering::indexed_point ret;
+    ret.id = convert(data.id);
+    ret.point = convert(data.point);
+    return ret;
+}
+
+std::vector<jubatus::clustering::indexed_point> QJubatusClustering::convert(const QList<QJubatusClustering::IndexedPoint> &data) const
+{
+    std::vector<jubatus::clustering::indexed_point> ret;
+    foreach (const IndexedPoint &indexPoint, data) {
+        ret.push_back(convert(indexPoint));
+    }
+    return ret;
+}
+
 jubatus::clustering::client::clustering *QJubatusClustering::client() {
     return QJubatusClient::client<jubatus::clustering::client::clustering>();
 }
index a382077..46c9f65 100644 (file)
@@ -35,6 +35,7 @@
 namespace jubatus {
     namespace clustering {
         struct weighted_datum;
+        struct indexed_point;
         namespace client {
             class clustering;
         }
@@ -45,14 +46,19 @@ class JUBATUS_EXPORT QJubatusClustering : public QJubatusClient
 {
     Q_OBJECT
 public:
-    explicit QJubatusClustering(QObject *parent = 0);
+    explicit QJubatusClustering(QObject *parent = nullptr);
 
     struct WeightedDatum {
         double weight;
         QVariantMap point;
     };
 
-    Q_INVOKABLE bool push(const QList<QVariantMap> &data);
+    struct IndexedPoint {
+        QString id;
+        QVariantMap point;
+    };
+
+    Q_INVOKABLE bool push(const QList<IndexedPoint> &data);
     Q_INVOKABLE uint getRevision();
     Q_INVOKABLE QList<QList<QJubatusClustering::WeightedDatum> > getCoreMembers();
     Q_INVOKABLE QList<QVariantMap> getKCenter();
@@ -64,6 +70,8 @@ protected:
     QJubatusClustering::WeightedDatum convert(const jubatus::clustering::weighted_datum &data) const;
     QList<QJubatusClustering::WeightedDatum> convert(const std::vector<jubatus::clustering::weighted_datum> &data) const;
     QList<QList<QJubatusClustering::WeightedDatum> > convert(const std::vector<std::vector<jubatus::clustering::weighted_datum> > &data) const;
+    jubatus::clustering::indexed_point convert(const QJubatusClustering::IndexedPoint &data) const;
+    std::vector<jubatus::clustering::indexed_point> convert(const QList<QJubatusClustering::IndexedPoint> &data) const;
 
 private:
     jubatus::clustering::client::clustering *client();
index df8138d..e45c11f 100644 (file)
@@ -45,7 +45,7 @@ class JUBATUS_EXPORT QJubatusRecommender : public QJubatusClient
 {
     Q_OBJECT
 public:
-    explicit QJubatusRecommender(QObject *parent = 0);
+    explicit QJubatusRecommender(QObject *parent = nullptr);
 
     struct IdWithScore {
         QString id;
index 7dcbe26..86b84b3 100644 (file)
@@ -45,7 +45,7 @@ class JUBATUS_EXPORT QJubatusRegression : public QJubatusClient
 {
     Q_OBJECT
 public:
-    explicit QJubatusRegression(QObject *parent = 0);
+    explicit QJubatusRegression(QObject *parent = nullptr);
 
     struct ScoredDatum {
         float score;