-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
84 lines (71 loc) · 3.7 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <phpcpp.h>
#include <iostream>
#include "include/HbaseExtension/Config.h"
#include "include/HbaseExtension/Client.h"
#include "include/HbaseExtension/Scan.h"
#include "include/HbaseExtension/Scanner.h"
/**
* tell the compiler that the get_module is a pure C function
*/
extern "C" {
/**
* Function that is called by PHP right after the PHP process
* has started, and that returns an address of an internal PHP
* strucure with all the details and features of your extension
*
* @return void* a pointer to an address that is understood by PHP
*/
PHPCPP_EXPORT void *get_module()
{
static Php::Extension extension("phphbase", "1.0");
zoo_set_debug_level( (ZooLogLevel)0);
google::InitGoogleLogging("phphbase");
google::SetCommandLineOption("GLOG_minloglevel", "1");
Php::Namespace hbaseNativeClient("HBaseNativeClient");
Php::Class<HbaseExtension::Config> hbaseExtensionConfiguration("Config");
hbaseExtensionConfiguration.method<&HbaseExtension::Config::set> ("set", {
Php::ByVal("name", Php::Type::String),
Php::ByVal("value", Php::Type::String)
});
hbaseExtensionConfiguration.add(Php::Constant(HbaseExtension::Config::HBASE_ZOOKEEPER_QUORUM, hbase::ZKUtil::kHBaseZookeeperQuorum_));
hbaseExtensionConfiguration.add(Php::Constant(HbaseExtension::Config::HBASE_ZOOKEEPER_CLIENT_PORT, hbase::ZKUtil::kHBaseZookeeperClientPort_));
hbaseExtensionConfiguration.add(Php::Constant(HbaseExtension::Config::HBASE_ZOOKEEPER_ZNODE_PARENT, hbase::ZKUtil::kHBaseZnodeParent_));
hbaseExtensionConfiguration.add(Php::Constant(HbaseExtension::Config::HBASE_ZOOKEEPER_META_REGION_SERVER, hbase::ZKUtil::kHBaseMetaRegionServer_));
hbaseExtensionConfiguration.add(Php::Constant(HbaseExtension::Config::HBASE_ZOOKEEPER_SESSION_TIMEOUT, hbase::ZKUtil::kHBaseZookeeperSessionTimeout_));
Php::Class<HbaseExtension::Client> hbaseExtensionClient("Client");
hbaseExtensionClient.method<&HbaseExtension::Client::__construct> ("__construct", {
Php::ByVal("config", "HBaseNativeClient\\Config")
});
hbaseExtensionClient.method<&HbaseExtension::Client::table> ("table", {
Php::ByVal("tableName", Php::Type::String)
});
hbaseExtensionClient.method<&HbaseExtension::Client::get> ("get", {
Php::ByVal("rowKeys", Php::Type::Array)
});
hbaseExtensionClient.method<&HbaseExtension::Client::openScanner> ("openScanner", {
Php::ByVal("scan", "HBaseNativeClient\\Scan")
});
hbaseExtensionClient.method<&HbaseExtension::Client::close> ("close");
Php::Class<HbaseExtension::Scan> hbaseExtensionScan("Scan");
hbaseExtensionScan.method<&HbaseExtension::Scan::setStartRow> ("setStartRow", {
Php::ByVal("startRow", Php::Type::String)
});
hbaseExtensionScan.method<&HbaseExtension::Scan::setStopRow> ("setStopRow", {
Php::ByVal("stopRow", Php::Type::String)
});
hbaseExtensionScan.method<&HbaseExtension::Scan::setCaching> ("setCaching", {
Php::ByVal("caching", Php::Type::Numeric)
});
Php::Class<HbaseExtension::Scanner> hbaseExtensionScanner("Scanner");
hbaseExtensionScanner.method<&HbaseExtension::Scanner::getList> ("getList");
hbaseExtensionScanner.method<&HbaseExtension::Scanner::close> ("close");
hbaseExtensionScanner.method("__construct", Php::Private);
hbaseExtensionScanner.method("__clone", Php::Private);
hbaseNativeClient.add(std::move(hbaseExtensionConfiguration));
hbaseNativeClient.add(std::move(hbaseExtensionClient));
hbaseNativeClient.add(std::move(hbaseExtensionScan));
hbaseNativeClient.add(std::move(hbaseExtensionScanner));
extension.add(std::move(hbaseNativeClient));
return extension;
}
}