final int numberDistinctPredicates,
final int numberDistinctObjects,
final boolean subjectDifferentFromPreviousTriple,
final boolean predicateDifferentFromPreviousTriple,
final boolean objectDifferentFromPreviousTriple) throws IOException {
final BitVector bits = new BitVector(7);
bits.set(0);
final Triple lastValue = (lastKey == null) ? null : lastKey.getTriple();
final Triple v = key.getTriple();
final boolean mustWriteLazyLiteralOriginalContent = (v.getObject() instanceof LazyLiteralOriginalContent)
&& (lastValue == null || !(lastValue.getObject().equals(v
.getObject())));
if (mustWriteLazyLiteralOriginalContent) {
bits.set(1);
} else {
bits.clear(1);
}
int value = 0;
if (lastValue == null) {
value = 3;
} else {
for (int i = 0; i < 3; i++) {
if (v.getPos(map[this.order.ordinal()][i]).equals(
lastValue.getPos(map[this.order.ordinal()][i]))) {
value++;
} else {
break;
}
}
}
if (value <= 1) {
bits.clear(2);
} else {
bits.set(2);
}
if (value % 2 == 0) {
bits.clear(3);
} else {
bits.set(3);
}
if (subjectDifferentFromPreviousTriple) {
bits.set(4);
} else {
bits.clear(4);
}
if (predicateDifferentFromPreviousTriple) {
bits.set(5);
} else {
bits.clear(5);
}
if (objectDifferentFromPreviousTriple) {
bits.set(6);
} else {
bits.clear(6);
}
int index = 7;
for (int i = 0; i < 3; i++) {
if (lastValue == null
|| !v.getPos(map[this.order.ordinal()][i]).equals(
lastValue.getPos(map[this.order.ordinal()][i]))) {
if (lastValue != null) {
// determine difference
final int diff = ((LazyLiteral) v.getPos(map[this.order
.ordinal()][i])).getCode()
- ((LazyLiteral) lastValue.getPos(map[this.order
.ordinal()][i])).getCode();
index = LazyLiteralNodeDeSerializer
.determineNumberOfBytesForRepresentation(diff,
bits, index, out);
}
for (int j = i + ((value == 3) ? 0 : 1); j < 3; j++) {
// deal with the "rest"
index = LazyLiteralNodeDeSerializer
.determineNumberOfBytesForRepresentation(
((LazyLiteral) v
.getPos(map[this.order.ordinal()][j]))
.getCode(), bits, index, out);
}
break;
}
}
if (mustWriteLazyLiteralOriginalContent) {
index = LazyLiteralNodeDeSerializer
.determineNumberOfBytesForRepresentation(
((LazyLiteralOriginalContent) v.getObject())
.getCodeOriginalContent(), bits, index, out);
}
index = LazyLiteralNodeDeSerializer
.determineNumberOfBytesForRepresentation(fileName, bits, index,
out);
index = LazyLiteralNodeDeSerializer
.determineNumberOfBytesForRepresentation(numberOfTriples, bits,
index, out);
index = LazyLiteralNodeDeSerializer
.determineNumberOfBytesForRepresentation(
numberDistinctSubjects, bits, index, out);
index = LazyLiteralNodeDeSerializer
.determineNumberOfBytesForRepresentation(
numberDistinctPredicates, bits, index, out);
index = LazyLiteralNodeDeSerializer
.determineNumberOfBytesForRepresentation(numberDistinctObjects,
bits, index, out);
bits.writeWithoutSize(out);
LazyLiteralNodeDeSerializer.writeIntWithoutLeadingZeros(fileName, out);
LazyLiteralNodeDeSerializer.writeIntWithoutLeadingZeros(
numberOfTriples, out);
LazyLiteralNodeDeSerializer.writeIntWithoutLeadingZeros(