Search in sources :

Example 1 with RangeTombstoneMarker

use of org.apache.cassandra.db.rows.RangeTombstoneMarker in project cassandra by apache.

the class JsonTransformer method serializePartition.

private void serializePartition(UnfilteredRowIterator partition) {
    try {
        json.writeStartObject();
        json.writeFieldName("partition");
        json.writeStartObject();
        json.writeFieldName("key");
        serializePartitionKey(partition.partitionKey());
        json.writeNumberField("position", this.currentScanner.getCurrentPosition());
        if (!partition.partitionLevelDeletion().isLive())
            serializeDeletion(partition.partitionLevelDeletion());
        json.writeEndObject();
        if (partition.hasNext() || partition.staticRow() != null) {
            json.writeFieldName("rows");
            json.writeStartArray();
            updatePosition();
            if (!partition.staticRow().isEmpty())
                serializeRow(partition.staticRow());
            Unfiltered unfiltered;
            updatePosition();
            while (partition.hasNext()) {
                unfiltered = partition.next();
                if (unfiltered instanceof Row) {
                    serializeRow((Row) unfiltered);
                } else if (unfiltered instanceof RangeTombstoneMarker) {
                    serializeTombstone((RangeTombstoneMarker) unfiltered);
                }
                updatePosition();
            }
            json.writeEndArray();
            json.writeEndObject();
        }
    } catch (IOException e) {
        String key = metadata.partitionKeyType.getString(partition.partitionKey().getKey());
        logger.error("Fatal error parsing partition: {}", key, e);
    }
}
Also used : RangeTombstoneMarker(org.apache.cassandra.db.rows.RangeTombstoneMarker) Row(org.apache.cassandra.db.rows.Row) IOException(java.io.IOException) Unfiltered(org.apache.cassandra.db.rows.Unfiltered)

Aggregations

IOException (java.io.IOException)1 RangeTombstoneMarker (org.apache.cassandra.db.rows.RangeTombstoneMarker)1 Row (org.apache.cassandra.db.rows.Row)1 Unfiltered (org.apache.cassandra.db.rows.Unfiltered)1