for (Component c : components) { Serializer<?> s = serializerForPosition(i); ByteBuffer cb = c.getBytes(s); if (cb == null) { cb = ByteBuffer.allocate(0); String comparator = comparatorForPosition(i); if (comparator == null) { comparator = c.getComparator(); out.write(equality.toByte()); } else { out.write(c.getEquality().toByte());
@SuppressWarnings("unchecked") @Override public Object set(int index, Object element) { serialized = null; if (element instanceof Component) { Component prev = components.set(index, (Component<?>) element); if (prev != null) { return prev.getValue(); } return null; } element = mapIfNumber(element); Serializer s = serializerForPosition(index); if (s == null) { s = SerializerTypeInferer.getSerializer(element); } String c = comparatorForPosition(index); if (c == null) { c = comparatorForSerializer(s); } Component prev = components.set(index, new Component(element, null, s, c, ComponentEquality.EQUAL)); if (prev != null) { return prev.getValue(); } return null; }
for (Component c : components) { Serializer<?> s = serializerForPosition(i); ByteBuffer cb = c.getBytes(s); if (cb == null) { cb = ByteBuffer.allocate(0); String comparator = comparatorForPosition(i); if (comparator == null) { comparator = c.getComparator(); out.write(equality.toByte()); } else { out.write(c.getEquality().toByte());
for (Component c : components) { Serializer<?> s = serializerForPosition(i); ByteBuffer cb = c.getBytes(s); if (cb == null) { cb = ByteBuffer.allocate(0); String comparator = comparatorForPosition(i); if (comparator == null) { comparator = c.getComparator(); out.write(equality.toByte()); } else { out.write(c.getEquality().toByte());
for (; i < startComponents.size() - 1; i++) { current = start.getComponent(i); end.setComponent(i, current.getValue(), current.getSerializer(), current.getComparator(), ComponentEquality.EQUAL); end.setComponent(i, current.getValue(), current.getSerializer(), current.getComparator(), ComponentEquality.GREATER_THAN_EQUAL);
for (; i < startComponents.size() - 1; i++) { current = start.getComponent(i); end.setComponent(i, current.getValue(), current.getSerializer(), current.getComparator(), ComponentEquality.EQUAL); end.setComponent(i, current.getValue(), current.getSerializer(), current.getComparator(), ComponentEquality.GREATER_THAN_EQUAL);
current = component.get(i); readComposite.addComponent(current.getValue(), current.getSerializer(), current.getComparator()); readComposite.addComponent(current.getValue(), current.getSerializer(), current.getComparator());
Object value = embeddedSerializer.getObject(composite.getComponent(i).getBytes()); if (value == null) { continue;
@SuppressWarnings("unchecked") @Override public Object set(int index, Object element) { serialized = null; if (element instanceof Component) { Component prev = components.set(index, (Component<?>) element); if (prev != null) { return prev.getValue(); } return null; } element = mapIfNumber(element); Serializer s = serializerForPosition(index); if (s == null) { s = SerializerTypeInferer.getSerializer(element); } String c = comparatorForPosition(index); if (c == null) { c = comparatorForSerializer(s); } Component prev = components.set(index, new Component(element, null, s, c, ComponentEquality.EQUAL)); if (prev != null) { return prev.getValue(); } return null; }
@SuppressWarnings("unchecked") @Override public Object set(int index, Object element) { serialized = null; if (element instanceof Component) { Component prev = components.set(index, (Component<?>) element); if (prev != null) { return prev.getValue(); } return null; } element = mapIfNumber(element); Serializer s = serializerForPosition(index); if (s == null) { s = SerializerTypeInferer.getSerializer(element); } String c = comparatorForPosition(index); if (c == null) { c = comparatorForSerializer(s); } Component prev = components.set(index, new Component(element, null, s, c, ComponentEquality.EQUAL)); if (prev != null) { return prev.getValue(); } return null; }
/** * Increase the last comparator to GT_E to ensure we get the next page * * @param composite * @return */ @SuppressWarnings({ "rawtypes", "unchecked" }) private DynamicComposite bumpComposite(DynamicComposite composite) { DynamicComposite newComposite = new DynamicComposite(); int size = composite.getComponents().size(); Component component = null; for (int i = 0; i < size - 1; i++) { component = composite.getComponent(i); newComposite.addComponent(component.getValue(), component.getSerializer(), component.getComparator(), component.getEquality()); } component = composite.getComponent(size - 1); newComposite.addComponent(component.getValue(), component.getSerializer(), component.getComparator(), ComponentEquality.GREATER_THAN_EQUAL); return newComposite; }
@SuppressWarnings("unchecked") public <T> AbstractComposite addComponent(int index, T element, ComponentEquality equality) { serialized = null; if (element instanceof Component) { components.add(index, (Component<?>) element); return this; } Serializer s = serializerForPosition(index); if (s == null) { s = SerializerTypeInferer.getSerializer(element); } String c = comparatorForPosition(index); if (c == null) { c = comparatorForSerializer(s); } components.add(index, new Component(element, null, s, c, equality)); return this; }
@SuppressWarnings("unchecked") public void deserialize(ByteBuffer b) { serialized = b.duplicate(); components = new ArrayList<Component<?>>(); String comparator = null; int i = 0; while ((comparator = getComparator(i, b)) != null) { ByteBuffer data = getWithShortLength(b); if (data != null) { Serializer<?> s = getSerializer(i, comparator); ComponentEquality equality = ComponentEquality.fromByte(b.get()); components.add(new Component(null, data.slice(), s, comparator, equality)); } else { throw new RuntimeException("Missing component data in composite type"); } i++; } }
@SuppressWarnings("unchecked") public <T> AbstractComposite addComponent(int index, T element, ComponentEquality equality) { serialized = null; if (element instanceof Component) { components.add(index, (Component<?>) element); return this; } Serializer s = serializerForPosition(index); if (s == null) { s = SerializerTypeInferer.getSerializer(element); } String c = comparatorForPosition(index); if (c == null) { c = comparatorForSerializer(s); } components.add(index, new Component(element, null, s, c, equality)); setSerializerByPosition(index, s); return this; }
@SuppressWarnings("unchecked") public void deserialize(ByteBuffer b) { serialized = b.duplicate(); components = new ArrayList<Component<?>>(); String comparator = null; int i = 0; while ((comparator = getComparator(i, b)) != null) { ByteBuffer data = getWithShortLength(b); if (data != null) { Serializer<?> s = getSerializer(i, comparator); ComponentEquality equality = ComponentEquality.fromByte(b.get()); components.add(new Component(null, data.slice(), s, comparator, equality)); } else { throw new RuntimeException("Missing component data in composite type"); } i++; } }
@SuppressWarnings("unchecked") public <T> AbstractComposite addComponent(int index, T value, Serializer<T> s, String comparator, ComponentEquality equality) { serialized = null; if (value == null) { throw new NullPointerException("Unable able to add null component"); } if (index < 0) { index = components.size(); } while (components.size() < index) { components.add(null); } components.add(index, new Component(value, null, s, comparator, equality)); return this; }
@SuppressWarnings("unchecked") public <T> AbstractComposite addComponent(int index, T value, Serializer<T> s, String comparator, ComponentEquality equality) { serialized = null; if (value == null) { throw new NullPointerException("Unable able to add null component"); } if (index < 0) { index = components.size(); } while (components.size() < index) { components.add(null); } components.add(index, new Component(value, null, s, comparator, equality)); return this; }
public T getValue() { return getValue(serializer); }
public ByteBuffer getBytes() { return getBytes(serializer); }
/** * remove(int) is the primary method that removes elements * from the list. All other remove methods end up calling * AbstractComposite.remove(int). */ @Override public Object remove(int index) { serialized = null; Component prev = components.remove(index); if (prev != null) { return prev.getValue(); } return null; }