use of com.hazelcast.core.TypeConverter in project hazelcast by hazelcast.
the class BetweenVisitor method findBoundaryOrNull.
private Boundaries findBoundaryOrNull(String attributeName, List<GreaterLessPredicate> predicates, Indexes indexes) {
GreaterLessPredicate mostRightGreaterOrEquals = null;
GreaterLessPredicate mostLeftLessThanOrEquals = null;
Index index = indexes.getIndex(attributeName);
TypeConverter converter = index.getConverter();
for (GreaterLessPredicate predicate : predicates) {
if (predicate.less) {
if (mostLeftLessThanOrEquals == null || isLessThan(mostLeftLessThanOrEquals, predicate, converter)) {
mostLeftLessThanOrEquals = predicate;
}
} else {
if (mostRightGreaterOrEquals == null || isGreaterThan(mostRightGreaterOrEquals, predicate, converter)) {
mostRightGreaterOrEquals = predicate;
}
}
}
if (mostRightGreaterOrEquals == null || mostLeftLessThanOrEquals == null) {
return null;
}
return new Boundaries(mostRightGreaterOrEquals, mostLeftLessThanOrEquals, converter);
}
use of com.hazelcast.core.TypeConverter in project hazelcast by hazelcast.
the class AbstractIndex method obtainConverter.
private TypeConverter obtainConverter(QueryableEntry entry) {
if (components.length == 1) {
return entry.getConverter(components[0]);
} else {
CompositeConverter existingConverter = (CompositeConverter) converter;
TypeConverter[] converters = new TypeConverter[components.length];
for (int i = 0; i < components.length; ++i) {
TypeConverter existingComponentConverter = getNonTransientComponentConverter(existingConverter, i);
if (existingComponentConverter == null) {
converters[i] = entry.getConverter(components[i]);
assert converters[i] != null;
} else {
// preserve the old one to avoid downgrading
converters[i] = existingComponentConverter;
}
}
return new CompositeConverter(converters);
}
}
use of com.hazelcast.core.TypeConverter in project hazelcast by hazelcast.
the class EvaluateVisitor method visit.
@Override
public Predicate visit(InPredicate predicate, Indexes indexes) {
Index index = indexes.matchIndex(predicate.attributeName, predicate.getClass(), IndexMatchHint.PREFER_UNORDERED, SKIP_PARTITIONS_COUNT_CHECK);
if (index == null) {
return predicate;
}
TypeConverter converter = index.getConverter();
if (converter == null) {
return predicate;
}
return new EvaluatePredicate(predicate, index.getName());
}
use of com.hazelcast.core.TypeConverter in project hazelcast by hazelcast.
the class EvaluateVisitor method visit.
@Override
public Predicate visit(EqualPredicate predicate, Indexes indexes) {
Index index = indexes.matchIndex(predicate.attributeName, predicate.getClass(), IndexMatchHint.PREFER_UNORDERED, SKIP_PARTITIONS_COUNT_CHECK);
if (index == null) {
return predicate;
}
TypeConverter converter = index.getConverter();
if (converter == null) {
return predicate;
}
return new EvaluatePredicate(predicate, index.getName());
}
use of com.hazelcast.core.TypeConverter in project hazelcast by hazelcast.
the class DiscoveryServicePropertiesUtil method prepareProperties.
/**
* Validates, verifies, and maps {@code properties} with the given {@code propertyDefinitions}.
*
* @param properties properties from the Hazelcast node configuration (from the service-discovery section)
* @param propertyDefinitions property definitions specific for the given
* {@link com.hazelcast.spi.discovery.DiscoveryStrategy}
* @return mapped properties
* @throws InvalidConfigurationException if the the required properties are not satisfied or any property is not not
* applicable to the given definitions
* @throws ValidationException if any property is invalid
*/
static Map<String, Comparable> prepareProperties(Map<String, Comparable> properties, Collection<PropertyDefinition> propertyDefinitions) {
Map<String, Comparable> mappedProperties = createHashMap(propertyDefinitions.size());
for (PropertyDefinition propertyDefinition : propertyDefinitions) {
String propertyKey = propertyDefinition.key();
if (properties.containsKey(propertyKey.replace("-", ""))) {
properties.put(propertyKey, properties.remove(propertyKey.replace("-", "")));
}
if (!properties.containsKey(propertyKey)) {
if (!propertyDefinition.optional()) {
throw new InvalidConfigurationException(String.format("Missing property '%s' on discovery strategy", propertyKey));
}
continue;
}
Comparable value = properties.get(propertyKey);
TypeConverter typeConverter = propertyDefinition.typeConverter();
Comparable mappedValue = typeConverter.convert(value);
ValueValidator validator = propertyDefinition.validator();
if (validator != null) {
validator.validate(mappedValue);
}
mappedProperties.put(propertyKey, mappedValue);
}
verifyNoUnknownProperties(mappedProperties, properties);
return mappedProperties;
}
Aggregations