-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from ihsandemir/adaptor
Raw pointer capability feature implementation
- Loading branch information
Showing
71 changed files
with
5,431 additions
and
342 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# | ||
# Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
add_executable(rawmap ./RawMap.cpp) | ||
add_executable(rawlist ./RawList.cpp) | ||
add_executable(rawmultimap ./RawMultiMap.cpp) | ||
add_executable(rawqueue ./RawQueue.cpp) | ||
add_executable(rawset ./RawSet.cpp) | ||
add_executable(rawtxmap ./RawTransactionalMap.cpp) | ||
add_executable(rawtxmultimap ./RawTransactionalMultiMap.cpp) | ||
add_executable(rawtxqueue ./RawTransactionalQueue.cpp) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
// | ||
// Created by İhsan Demir on 21/12/15. | ||
// | ||
#include <hazelcast/client/HazelcastClient.h> | ||
#include <hazelcast/client/adaptor/RawPointerList.h> | ||
|
||
int main() { | ||
hazelcast::client::ClientConfig config; | ||
hazelcast::client::HazelcastClient hz(config); | ||
|
||
hazelcast::client::IList<std::string> l = hz.getList<std::string>("list"); | ||
hazelcast::client::adaptor::RawPointerList<std::string> list(l); | ||
|
||
std::cout << "There are " << list.size() << " values initally in the list" << std::endl; | ||
|
||
list.clear(); | ||
|
||
std::cout << "After clear operation, there are " << list.size() << " values in the list" << std::endl; | ||
|
||
list.add("Tokyo"); | ||
list.add("Paris"); | ||
list.add("New York"); | ||
std::cout << "Finished loading list" << std::endl; | ||
|
||
std::cout << "There are " << list.size() << " values in the list" << std::endl; | ||
|
||
std::auto_ptr<hazelcast::client::adaptor::DataArray<std::string> > vals = list.subList(0, 2); | ||
std::cout << "Got sublist between indexes 0 and 2. Size is:" << vals->size() << std::endl; | ||
for (size_t i = 0; i < vals->size(); ++i) { | ||
std::auto_ptr<std::string> val = vals->get(i); | ||
if (NULL == val.get()) { | ||
std::cout << "Value " << i << " is NULL" << std::endl; | ||
} else { | ||
std::cout << "Value: " << *val << std::endl; | ||
} | ||
} | ||
|
||
std::auto_ptr<std::string> item = list.get(1); | ||
if (NULL != item.get()) { | ||
std::cout << "Item at index 1 is " << *item << std::endl; | ||
} else { | ||
std::cout << "Item at index 1 is NULL" << std::endl; | ||
} | ||
|
||
vals = list.toArray(); | ||
|
||
for (size_t i = 0; i < vals->size(); ++i) { | ||
std::auto_ptr<std::string> val = vals->get(i); | ||
if (NULL == val.get()) { | ||
std::cout << "Value " << i << " is NULL" << std::endl; | ||
} else { | ||
std::cout << "Value: " << *val << std::endl; | ||
} | ||
} | ||
|
||
std::cout << "Finished" << std::endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
// | ||
// Created by İhsan Demir on 21/12/15. | ||
// | ||
#include <hazelcast/client/HazelcastClient.h> | ||
#include <hazelcast/client/adaptor/RawPointerMap.h> | ||
|
||
int main() { | ||
hazelcast::client::ClientConfig config; | ||
hazelcast::client::HazelcastClient hz(config); | ||
|
||
hazelcast::client::IMap<std::string, std::string> m = hz.getMap<std::string, std::string>("map"); | ||
hazelcast::client::adaptor::RawPointerMap<std::string, std::string> map(m); | ||
map.put("1", "Tokyo"); | ||
map.put("2", "Paris"); | ||
map.put("3", "New York"); | ||
std::cout << "Finished loading map" << std::endl; | ||
|
||
std::auto_ptr<hazelcast::client::adaptor::DataArray<std::string> > vals = map.values(); | ||
std::auto_ptr<hazelcast::client::adaptor::EntryArray<std::string, std::string> > entries = map.entrySet(); | ||
|
||
std::cout << "There are " << vals->size() << " values in the map" << std::endl; | ||
std::cout << "There are " << entries->size() << " entries in the map" << std::endl; | ||
|
||
for (size_t i = 0; i < entries->size(); ++i) { | ||
std::auto_ptr<std::string> key = entries->getKey(i); | ||
if ((std::string *) NULL == key.get()) { | ||
std::cout << "The key at index " << i << " is NULL" << std::endl; | ||
} else { | ||
std::auto_ptr<std::string> val = entries->getValue(i); | ||
std::cout << "(Key, Value) for index " << i << " is: (" << *key << ", " << | ||
(val.get() == NULL ? "NULL" : *val) << ")" << std::endl; | ||
} | ||
} | ||
|
||
std::cout << "Finished" << std::endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
// | ||
// Created by İhsan Demir on 21/12/15. | ||
// | ||
#include <hazelcast/client/HazelcastClient.h> | ||
#include <hazelcast/client/adaptor/RawPointerMultiMap.h> | ||
|
||
int main() { | ||
hazelcast::client::ClientConfig config; | ||
hazelcast::client::HazelcastClient hz(config); | ||
|
||
hazelcast::client::MultiMap<std::string, std::string> m = hz.getMultiMap<std::string, std::string>("multimap"); | ||
hazelcast::client::adaptor::RawPointerMultiMap<std::string, std::string> multimap(m); | ||
multimap.put("1", "Tokyo"); | ||
multimap.put("2", "Paris"); | ||
multimap.put("3", "New York"); | ||
std::cout << "Finished loading multimap" << std::endl; | ||
|
||
std::auto_ptr<hazelcast::client::adaptor::DataArray<std::string> > vals = multimap.values(); | ||
std::auto_ptr<hazelcast::client::adaptor::EntryArray<std::string, std::string> > entries = multimap.entrySet(); | ||
|
||
std::cout << "There are " << vals->size() << " values in the multimap" << std::endl; | ||
size_t size = entries->size(); | ||
std::cout << "There are " << size << " entries in the multimap" << std::endl; | ||
|
||
for (size_t i = 0; i < size; ++i) { | ||
std::auto_ptr<std::string> key = entries->getKey(i); | ||
if ((std::string *) NULL == key.get()) { | ||
std::cout << "The key at index " << i << " is NULL" << std::endl; | ||
} else { | ||
std::auto_ptr<std::string> val = entries->getValue(i); | ||
std::cout << "(Key, Value) for index " << i << " is: (" << *key << ", " << | ||
(val.get() == NULL ? "NULL" : *val) << ")" << std::endl; | ||
} | ||
} | ||
|
||
multimap.put("1", "Istanbul"); | ||
std::cout << "Put the second value for key '1' into the multimap" << std::endl; | ||
|
||
vals = multimap.get("1"); | ||
size = vals->size(); | ||
std::cout << "There are " << vals->size() << " values for key '1' in the multimap. These are:" << std::endl; | ||
for (size_t j = 0; j < size; ++j) { | ||
std::auto_ptr<std::string> val = vals->get(j); | ||
if (NULL == val.get()) { | ||
std::cout << "NULL" << std::endl; | ||
} else { | ||
std::cout << *val << std::endl; | ||
} | ||
} | ||
|
||
std::cout << "Finished" << std::endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
// | ||
// Created by İhsan Demir on 21/12/15. | ||
// | ||
#include <hazelcast/client/HazelcastClient.h> | ||
#include <hazelcast/client/adaptor/RawPointerQueue.h> | ||
|
||
int main() { | ||
hazelcast::client::ClientConfig config; | ||
hazelcast::client::HazelcastClient hz(config); | ||
|
||
hazelcast::client::IQueue<std::string> q = hz.getQueue<std::string>("queue"); | ||
hazelcast::client::adaptor::RawPointerQueue<std::string> queue(q); | ||
queue.offer("Tokyo"); | ||
queue.offer("Paris"); | ||
queue.offer("New York"); | ||
std::cout << "Finished loading queue" << std::endl; | ||
|
||
std::auto_ptr<hazelcast::client::adaptor::DataArray<std::string> > vals = queue.toArray(); | ||
|
||
std::cout << "There are " << queue.size() << " values in the queue" << std::endl; | ||
|
||
for (size_t i = 0; i < vals->size(); ++i) { | ||
std::auto_ptr<std::string> val = vals->get(i); | ||
if (NULL == val.get()) { | ||
std::cout << "Value " << i << " is NULL" << std::endl; | ||
} else { | ||
std::cout << "Value: " << *val << std::endl; | ||
} | ||
} | ||
|
||
std::auto_ptr<std::string> item = queue.peek(); | ||
if (NULL == item.get()) { | ||
std::cout << "Head of the queue is NULL" << std::endl; | ||
} else { | ||
std::cout << "Head of the queue is " << *item << std::endl; | ||
} | ||
|
||
item = queue.take(); | ||
if (NULL == item.get()) { | ||
std::cout << "Take operation returned NULL" << std::endl; | ||
} else { | ||
std::cout << "Take operation returned " << *item << std::endl; | ||
} | ||
|
||
std::cout << "Finished" << std::endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
// | ||
// Created by İhsan Demir on 21/12/15. | ||
// | ||
#include <hazelcast/client/HazelcastClient.h> | ||
#include <hazelcast/client/adaptor/RawPointerSet.h> | ||
|
||
int main() { | ||
hazelcast::client::ClientConfig config; | ||
hazelcast::client::HazelcastClient hz(config); | ||
|
||
hazelcast::client::ISet<std::string> s = hz.getSet<std::string>("set"); | ||
hazelcast::client::adaptor::RawPointerSet<std::string> set(s); | ||
set.add("Tokyo"); | ||
set.add("Paris"); | ||
set.add("New York"); | ||
std::cout << "Finished loading set" << std::endl; | ||
|
||
std::auto_ptr<hazelcast::client::adaptor::DataArray<std::string> > vals = set.toArray(); | ||
|
||
std::cout << "There are " << set.size() << " values in the set" << std::endl; | ||
|
||
for (size_t i = 0; i < vals->size(); ++i) { | ||
std::auto_ptr<std::string> val = (*vals)[i]; | ||
if (NULL == val.get()) { | ||
std::cout << "Value " << i << " is NULL" << std::endl; | ||
} else { | ||
std::cout << "Value: " << *val << std::endl; | ||
} | ||
} | ||
|
||
bool exists = set.remove("Tokyo"); | ||
if (exists) { | ||
std::cout << "Removed Tokyo from set" << std::endl; | ||
} else { | ||
std::cout << "Could not remove Tokyo from set. It did not exist." << std::endl; | ||
} | ||
|
||
std::cout << "Finished" << std::endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
// | ||
// Created by İhsan Demir on 21/12/15. | ||
// | ||
#include <hazelcast/client/HazelcastClient.h> | ||
#include <hazelcast/client/adaptor/RawPointerTransactionalMap.h> | ||
|
||
int main() { | ||
hazelcast::client::ClientConfig config; | ||
hazelcast::client::HazelcastClient hz(config); | ||
|
||
hazelcast::client::TransactionContext txCtxt = hz.newTransactionContext(); | ||
|
||
txCtxt.beginTransaction(); | ||
|
||
hazelcast::client::TransactionalMap<std::string, std::string> transactionalMap = txCtxt.getMap<std::string, std::string>("txMap"); | ||
|
||
hazelcast::client::adaptor::RawPointerTransactionalMap<std::string, std::string> map(transactionalMap); | ||
map.put("1", "Tokyo"); | ||
map.put("2", "Paris"); | ||
map.put("3", "New York"); | ||
|
||
txCtxt.commitTransaction(); | ||
|
||
std::cout << "Finished loading transactional map" << std::endl; | ||
|
||
return 0; | ||
} |
Oops, something went wrong.