forked from hazelcast/hazelcast-cpp-client
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Predicates implementation (hazelcast#89) * Added builtin predicates * Added and predicate. * Added missing methods in ObjectDataOutput and ObjectDataInput for read/writeObject and added BetweenPredicate. * EqualPredicate * GreaterLessPredicate * LikePredicate * InPredicate * InstanceOfPredicate * Not and NotEqual * OrPredicate * RegExPredicate * Added Predicate interface, ClientMapTest not compiling due to PagingPredicate. * PagingPredicate * Predicate with EntryListener is added. * Added values with predicate test * testEntrySetWithPredicateTest and testKeySetWithPredicateTest added * RawPointerMap API is corrected. * Changed the DataArray and EntryArray interfaces. Made the PagingPredicate work for primitives. * Fix for setAnchor * Update To map test and raw pointer examples * Added example for builtin predicate queries. * Added entry listener with different predicates tests.
- Loading branch information
1 parent
f9d375a
commit ae83b4c
Showing
85 changed files
with
7,342 additions
and
604 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
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
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
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,119 @@ | ||
/* | ||
* 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 ihsan demir on 18 Apr 2016. | ||
|
||
#include "Employee.h" | ||
#include "hazelcast/client/serialization/PortableWriter.h" | ||
#include "hazelcast/client/serialization/PortableReader.h" | ||
|
||
namespace hazelcast { | ||
namespace client { | ||
namespace examples { | ||
namespace criteriaapi { | ||
Employee::Employee():age(-1), name("") { | ||
|
||
} | ||
|
||
Employee::Employee(std::string name, int age) | ||
:age(age) | ||
, name(name) { | ||
|
||
} | ||
|
||
bool Employee::operator==(const Employee &rhs) const { | ||
return age == rhs.getAge() && name == rhs.getName(); | ||
} | ||
|
||
bool Employee::operator !=(const Employee &employee) const { | ||
return !(*this == employee); | ||
} | ||
|
||
int Employee::getFactoryId() const { | ||
return 666; | ||
} | ||
|
||
int Employee::getClassId() const { | ||
return 2; | ||
} | ||
|
||
void Employee::writePortable(serialization::PortableWriter &writer) const { | ||
writer.writeUTF("n", &name); | ||
writer.writeInt("a", age); | ||
} | ||
|
||
void Employee::readPortable(serialization::PortableReader &reader) { | ||
name = *reader.readUTF("n"); | ||
age = reader.readInt("a"); | ||
} | ||
|
||
int Employee::getAge() const { | ||
return age; | ||
} | ||
|
||
const std::string &Employee::getName() const { | ||
return name; | ||
} | ||
|
||
bool Employee::operator<(const Employee &rhs) const { | ||
return age < rhs.getAge(); | ||
} | ||
|
||
int EmployeeEntryComparator::getFactoryId() const { | ||
return 666; | ||
} | ||
|
||
int EmployeeEntryComparator::getClassId() const { | ||
return 4; | ||
} | ||
|
||
void EmployeeEntryComparator::writeData(serialization::ObjectDataOutput &writer) const { | ||
} | ||
|
||
void EmployeeEntryComparator::readData(serialization::ObjectDataInput &reader) { | ||
} | ||
|
||
int EmployeeEntryComparator::compare(const std::pair<const int *, const Employee *> &lhs, | ||
const std::pair<const int *, const Employee *> &rhs) const { | ||
const Employee *lv = lhs.second; | ||
const Employee *rv = rhs.second; | ||
|
||
if (NULL == lv) { | ||
return -1; | ||
} | ||
|
||
if (NULL == rv) { | ||
return 1; | ||
} | ||
|
||
int la = lv->getAge(); | ||
int ra = rv->getAge(); | ||
|
||
if (la == ra) { | ||
return 0; | ||
} | ||
|
||
if (la < ra) { | ||
return -1; | ||
} | ||
|
||
return 1; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
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,82 @@ | ||
/* | ||
* 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 ihsan demir on 18 Apr 2016. | ||
|
||
#ifndef HAZELCAST_Employee | ||
#define HAZELCAST_Employee | ||
|
||
#include <string> | ||
#include "hazelcast/client/serialization/Portable.h" | ||
#include "hazelcast/util/Comparator.h" | ||
#include "hazelcast/client/serialization/IdentifiedDataSerializable.h" | ||
#include "hazelcast/client/query/EntryComparator.h" | ||
|
||
namespace hazelcast { | ||
namespace client { | ||
namespace examples { | ||
namespace criteriaapi { | ||
class Employee : public serialization::Portable { | ||
public: | ||
Employee(); | ||
|
||
Employee(std::string name, int age); | ||
|
||
bool operator==(const Employee &employee) const; | ||
|
||
bool operator!=(const Employee &employee) const; | ||
|
||
int getFactoryId() const; | ||
|
||
int getClassId() const; | ||
|
||
void writePortable(serialization::PortableWriter &writer) const; | ||
|
||
void readPortable(serialization::PortableReader &reader); | ||
|
||
int getAge() const; | ||
|
||
const std::string &getName() const; | ||
|
||
bool operator<(const Employee &rhs) const; | ||
private: | ||
int age; | ||
std::string name; | ||
}; | ||
|
||
// Compares based on the employee age | ||
class EmployeeEntryComparator | ||
: public query::EntryComparator<int, Employee> { | ||
|
||
public: | ||
int getFactoryId() const; | ||
|
||
int getClassId() const; | ||
|
||
void writeData(serialization::ObjectDataOutput &writer) const; | ||
|
||
void readData(serialization::ObjectDataInput &reader); | ||
|
||
int compare(const std::pair<const int *, const Employee *> &lhs, | ||
const std::pair<const int *, const Employee *> &rhs) const; | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
|
||
#endif //HAZELCAST_Employee | ||
|
Oops, something went wrong.