Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/stats
diff options
context:
space:
mode:
authorDmitry Kunin <dkunin@mapswith.me>2013-12-17 17:11:46 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:09:07 +0300
commit3b1dc66f241ddab6e6062c474004cf03c5bd3086 (patch)
tree2b9c04c0674e47ad39d6766dddd02b4f6151c424 /stats
parentdaa0c06cb887735b8007d6ea5bdd3788816b0a4e (diff)
Client clean up.
Diffstat (limited to 'stats')
-rw-r--r--stats/client/client.pro9
-rw-r--r--stats/client/client_tests/client_tests.pro20
-rw-r--r--stats/client/client_tests/stats_writer_test.cpp69
-rw-r--r--stats/client/leveldb_reader.hpp76
-rw-r--r--stats/client/stats_writer.cpp29
-rw-r--r--stats/client/stats_writer.hpp8
-rw-r--r--stats/stats.pro2
7 files changed, 10 insertions, 203 deletions
diff --git a/stats/client/client.pro b/stats/client/client.pro
index 8cb689c0bc..c0910d46fe 100644
--- a/stats/client/client.pro
+++ b/stats/client/client.pro
@@ -6,13 +6,9 @@ CONFIG += staticlib
ROOT_DIR = ../..
include($$ROOT_DIR/common.pri)
-INCLUDEPATH += $$ROOT_DIR/3party/leveldb/include \
- $$ROOT_DIR/3party/protobuf/src \
- $$ROOT_DIR/3party/cityhash/src \
-
-
-DEPENDENCIES = base protobuf leveldb cityhash
+INCLUDEPATH += $$ROOT_DIR/3party/protobuf/src
+DEPENDENCIES = base protobuf
SOURCES += \
stats_client.cpp \
@@ -22,7 +18,6 @@ SOURCES += \
HEADERS += \
stats_client.hpp \
stats_writer.hpp \
- leveldb_reader.hpp \
../common/wire.pb.h \
OTHER_FILES += ../common/wire.proto
diff --git a/stats/client/client_tests/client_tests.pro b/stats/client/client_tests/client_tests.pro
deleted file mode 100644
index ad6d7531bb..0000000000
--- a/stats/client/client_tests/client_tests.pro
+++ /dev/null
@@ -1,20 +0,0 @@
-TARGET = stats_client_tests
-CONFIG += console
-CONFIG -= app_bundle
-TEMPLATE = app
-
-ROOT_DIR = ../../..
-DEPENDENCIES = stats_client coding base protobuf leveldb cityhash
-include($$ROOT_DIR/common.pri)
-INCLUDEPATH += $$ROOT_DIR/3party/leveldb/include \
- $$ROOT_DIR/3party/protobuf/src \
- $$ROOT_DIR/3party/cityhash/src
-
-QT *= core
-
-HEADERS += \
- ../leveldb_reader.hpp
-
-SOURCES += \
- $$ROOT_DIR/testing/testingmain.cpp \
- stats_writer_test.cpp \
diff --git a/stats/client/client_tests/stats_writer_test.cpp b/stats/client/client_tests/stats_writer_test.cpp
deleted file mode 100644
index d2e8e39a57..0000000000
--- a/stats/client/client_tests/stats_writer_test.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-#include "../../testing/testing.hpp"
-
-#include "../stats_writer.hpp"
-#include "../leveldb_reader.hpp"
-
-#include "../../coding/file_writer.hpp"
-
-#include "../../std/cstdlib.hpp"
-#include "../../std/target_os.hpp"
-
-#include <city.h>
-
-#define USER_ID "123"
-#define DB_PATH "tmp_testdb"
-
-using namespace stats;
-
-namespace
-{
-
-template<class P>
-bool Compare(P const & a, P const & b)
-{
- string as, bs;
- a.SerializeToString(&as);
- b.SerializeToString(&bs);
- return as == bs;
-}
-
-template<class P>
-string Diff(P const & act, P const & exp)
-{
-// Doesn't work with lite protos.
-// return string("\nactual: ") + act.DebugString() +
-// + " expect: " + exp.DebugString();
- return "";
-}
-
-UNIT_TEST(Simple)
-{
- Search s;
- s.set_query("pizza nyc");
-
- {
- StatsWriter w(USER_ID, DB_PATH);
- TEST(w.Write(s), ());
- }
-
- vector<Event> v = ReadAllFromLevelDB<Event>(DB_PATH);
- TEST_EQUAL(v.size(), 1, ());
-
- Event exp;
- exp.MutableExtension(Search::event)->CopyFrom(s);
- exp.set_userid(CityHash64(USER_ID, strlen(USER_ID)));
- exp.set_timestamp(0);
-
- Event act = v[0];
- act.set_timestamp(0);
-
- TEST(Compare(act, exp), (Diff(act, exp)));
-
-#ifdef OMIM_OS_WINDOWS
- system("rmdir /s /q " DB_PATH);
-#else
- system("rm -rf " DB_PATH);
-#endif
-}
-
-} // namespace
diff --git a/stats/client/leveldb_reader.hpp b/stats/client/leveldb_reader.hpp
deleted file mode 100644
index 131827303f..0000000000
--- a/stats/client/leveldb_reader.hpp
+++ /dev/null
@@ -1,76 +0,0 @@
-#pragma once
-
-#include <string>
-#include <vector>
-#include <leveldb/db.h>
-
-namespace stats
-{
-
-template <class P>
-class LevelDBReader
-{
-public:
- LevelDBReader(string const & db_path) : m_db(NULL), m_it(NULL), m_path(db_path)
- {
- }
-
- bool ReadNext(P * proto)
- {
- if ((m_it == NULL && !Open()) || !m_it->Valid())
- return false;
-
- string const s = m_it->value().ToString();
- m_it->Next();
-
- return proto->ParseFromString(s);
- }
-
- bool Open()
- {
- leveldb::Options options;
- leveldb::Status status = leveldb::DB::Open(options, m_path, &m_db);
-
- if (!status.ok())
- return false;
-
- m_it = m_db->NewIterator(leveldb::ReadOptions());
- m_it->SeekToFirst();
- if (!m_it->status().ok())
- {
- delete m_it;
- m_it = NULL;
- }
-
- return m_it->status().ok();
- }
-
- ~LevelDBReader()
- {
- delete m_it;
- delete m_db;
- }
-
- private:
- leveldb::DB * m_db;
- leveldb::Iterator * m_it;
- string const m_path;
-};
-
-template <class P>
-vector<P> ReadAllFromLevelDB(string const & db_path)
-{
- vector<P> res;
-
- LevelDBReader<P> reader(db_path);
-
- P proto;
- while (reader.ReadNext(&proto))
- {
- res.push_back(proto);
- }
-
- return res;
-}
-
-} // namespace stats
diff --git a/stats/client/stats_writer.cpp b/stats/client/stats_writer.cpp
index 2819139a06..2648d7022d 100644
--- a/stats/client/stats_writer.cpp
+++ b/stats/client/stats_writer.cpp
@@ -4,44 +4,25 @@
#include "../../std/ctime.hpp"
-#include <city.h>
-
namespace stats
{
StatsWriter::StatsWriter(string const & uniqueClientId, string const & dbPath)
: m_cnt(0), m_db(0), m_path(dbPath),
- m_uid(CityHash64(uniqueClientId.c_str(), uniqueClientId.size()))
+ m_uid(0)
{
}
bool StatsWriter::Store(const Event & e)
{
- string buf;
- e.SerializeToString(&buf);
-
- if (!m_db)
- {
- if(!OpenDb(m_path))
- {
- return false;
- }
- }
-
- // We can't just make timestamp a key - might have
- // several writes per second.
- string key(strings::ToString(e.timestamp()) + "-" + strings::ToString(m_cnt++));
-
- leveldb::WriteOptions opt;
- opt.sync = true; // Synchronous writes.
- return m_db->Put(opt, key, buf).ok();
+ // @todo add impl
+ return false;
}
bool StatsWriter::OpenDb(string const & path)
{
- leveldb::Options options;
- options.create_if_missing = true;
- return leveldb::DB::Open(options, path, &m_db).ok();
+ // @todo add impl
+ return false;
}
} // namespace stats
diff --git a/stats/client/stats_writer.hpp b/stats/client/stats_writer.hpp
index 4ad0e213a9..388a6cfaf3 100644
--- a/stats/client/stats_writer.hpp
+++ b/stats/client/stats_writer.hpp
@@ -2,10 +2,6 @@
#include "../../std/string.hpp"
-#include <google/protobuf/message.h>
-
-#include <leveldb/db.h>
-
#include "../common/wire.pb.h"
namespace stats
@@ -18,7 +14,7 @@ public:
bool Store(Event const & e);
- ~StatsWriter() { delete m_db; }
+ ~StatsWriter() {}
template<class T>
bool Write(T const & m)
@@ -36,7 +32,7 @@ private:
private:
unsigned int m_cnt;
- leveldb::DB * m_db;
+ void * m_db; // @todo Replace with ours impl
string m_path;
unsigned long long m_uid;
};
diff --git a/stats/stats.pro b/stats/stats.pro
index 5ccab609a5..7430bc38bc 100644
--- a/stats/stats.pro
+++ b/stats/stats.pro
@@ -6,5 +6,5 @@ CONFIG += ordered
SUBDIRS = client
!iphone*:!bada*:!android* {
- SUBDIRS += client/client_tests
+ SUBDIRS +=
}