use of jetbrains.exodus.bindings.ComparableValueType in project xodus by JetBrains.
the class PropertyTypes method entryToPropertyValue.
public PropertyValue entryToPropertyValue(@NotNull final ByteIterable entry) {
final ByteIterableBase it = (ByteIterableBase) entry;
final byte[] bytes = it.getBytesUnsafe();
final ComparableValueType type = getPropertyType((byte) (bytes[0] ^ 0x80));
final Comparable data = type.getBinding().readObject(new ByteArrayInputStream(bytes, 1, it.getLength() - 1));
return new PropertyValue(type, data);
}
use of jetbrains.exodus.bindings.ComparableValueType in project xodus by JetBrains.
the class PropertyTypes method clear.
public void clear() {
typesById.clear();
typesByClass.clear();
for (final ComparableValueType predefinedType : ComparableValueType.PREDEFINED_COMPARABLE_VALUE_TYPES) {
typesById.put(predefinedType.getTypeId(), predefinedType);
typesByClass.put(predefinedType.getClazz(), predefinedType);
}
final ComparableValueType comparableSetType = typesByClass.get(ComparableSet.class);
final ComparableSetBinding newBinding = new ComparableSetBinding() {
@Override
protected ComparableValueType getType(@NotNull Class<? extends Comparable> itemClass) {
final ComparableValueType result = super.getType(itemClass);
return result == null ? typesByClass.get(itemClass) : result;
}
@Override
protected ComparableBinding getBinding(int valueTypeId) {
final ComparableBinding result = super.getBinding(valueTypeId);
return result == null ? typesById.get(valueTypeId).getBinding() : result;
}
};
final int typeId = comparableSetType.getTypeId();
final ComparableValueType newComparableSetType = new ComparableValueType(typeId, newBinding, comparableSetType.getClazz());
typesByClass.put(ComparableSet.class, newComparableSetType);
typesById.put(typeId, newComparableSetType);
}
use of jetbrains.exodus.bindings.ComparableValueType in project xodus by JetBrains.
the class PropertyTypes method registerCustomPropertyType.
public void registerCustomPropertyType(int typeId, @NotNull final Class<? extends Comparable> clazz, @NotNull final ComparableBinding binding) {
typeId += ComparableValueType.PREDEFINED_COMPARABLE_VALUE_TYPES.length;
final ComparableValueType propType = new ComparableValueType(typeId, binding, clazz);
if (typesById.put(typeId, propType) != null) {
throw new EntityStoreException("Already registered property type id " + typeId);
}
if (typesByClass.put(clazz, propType) != null) {
throw new EntityStoreException("Already registered property type " + clazz);
}
}
use of jetbrains.exodus.bindings.ComparableValueType in project xodus by JetBrains.
the class PropertyTypes method entryToPropertyValue.
public PropertyValue entryToPropertyValue(@NotNull final ByteIterable entry, @Nullable ComparableBinding binding) {
final byte[] bytes = entry.getBytesUnsafe();
final ComparableValueType type = getPropertyType((byte) (bytes[0] ^ 0x80));
if (binding == null) {
binding = type.getBinding();
}
final Comparable data = binding.readObject(new ByteArraySizedInputStream(bytes, 1, entry.getLength() - 1));
return new PropertyValue(type, data);
}
Aggregations