Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/java/org/apache/cassandra/db/rows/AbstractCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public boolean isTombstone()
return localDeletionTime() != NO_DELETION_TIME && ttl() == NO_TTL;
}

public long minDeletionTime()
{
long localDeletionTime = localDeletionTime();
boolean isTombstone = localDeletionTime != NO_DELETION_TIME && ttl() == NO_TTL;
return isTombstone ? Long.MIN_VALUE : localDeletionTime;
}

public boolean isExpiring()
{
return ttl() != NO_TTL;
Expand Down
32 changes: 2 additions & 30 deletions src/java/org/apache/cassandra/db/rows/ArrayCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,12 @@

import static org.apache.cassandra.utils.ByteArrayUtil.EMPTY_BYTE_ARRAY;

public class ArrayCell extends AbstractCell<byte[]>
public class ArrayCell extends HeapAbstractCell<byte[]>
{
private static final long EMPTY_SIZE = ObjectSizes.measure(new ArrayCell(ColumnMetadata.regularColumn("", "", "", ByteType.instance, ColumnMetadata.NO_UNIQUE_ID), 0L, 0, 0, EMPTY_BYTE_ARRAY, null));

// Careful: Adding vars here has an impact on memtable size
private final long timestamp;
private final int ttl;
private final int localDeletionTimeUnsignedInteger;

private final byte[] value;
private final CellPath path;

// Please keep both int/long overloaded ctros public. Otherwise silent casts will mess timestamps when one is not
// available.
Expand All @@ -52,12 +47,8 @@ public ArrayCell(ColumnMetadata column, long timestamp, int ttl, long localDelet

public ArrayCell(ColumnMetadata column, long timestamp, int ttl, int localDeletionTimeUnsignedInteger, byte[] value, CellPath path)
{
super(column);
this.timestamp = timestamp;
this.ttl = ttl;
this.localDeletionTimeUnsignedInteger = localDeletionTimeUnsignedInteger;
super(column, timestamp, ttl, localDeletionTimeUnsignedInteger, path);
this.value = value;
this.path = path;
}

public static ArrayCell live(ColumnMetadata column, long timestamp, byte[] value, CellPath path)
Expand All @@ -71,16 +62,6 @@ public static ArrayCell expiring(ColumnMetadata column, long timestamp, int ttl,
return new ArrayCell(column, timestamp, ttl, ExpirationDateOverflowHandling.computeLocalExpirationTime(nowInSec, ttl), value, path);
}

public long timestamp()
{
return timestamp;
}

public int ttl()
{
return ttl;
}

public byte[] value()
{
return value;
Expand All @@ -91,10 +72,6 @@ public ValueAccessor<byte[]> accessor()
return ByteArrayAccessor.instance;
}

public CellPath path()
{
return path;
}

public Cell<?> withUpdatedColumn(ColumnMetadata newColumn)
{
Expand Down Expand Up @@ -144,9 +121,4 @@ public long unsharedHeapSizeExcludingData()
return EMPTY_SIZE + ObjectSizes.sizeOfArray(value) - value.length + (path == null ? 0 : path.unsharedHeapSizeExcludingData());
}

@Override
protected int localDeletionTimeAsUnsignedInt()
{
return localDeletionTimeUnsignedInteger;
}
}
2 changes: 1 addition & 1 deletion src/java/org/apache/cassandra/db/rows/BTreeRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public static BTreeRow noCellLiveRow(Clustering<?> clustering, LivenessInfo prim

private static long minDeletionTime(Cell<?> cell)
{
return cell.isTombstone() ? Long.MIN_VALUE : cell.localDeletionTime();
return cell.minDeletionTime();
}

private static long minDeletionTime(LivenessInfo info)
Expand Down
33 changes: 2 additions & 31 deletions src/java/org/apache/cassandra/db/rows/BufferCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,12 @@

import static java.lang.String.format;

public class BufferCell extends AbstractCell<ByteBuffer>
public class BufferCell extends HeapAbstractCell<ByteBuffer>
{
private static final long EMPTY_SIZE = ObjectSizes.measure(new BufferCell(ColumnMetadata.regularColumn("", "", "", ByteType.instance, ColumnMetadata.NO_UNIQUE_ID), 0L, 0, 0, ByteBufferUtil.EMPTY_BYTE_BUFFER, null));

// Careful: Adding vars here has an impact on memtable size
private final long timestamp;
private final int ttl;
private final int localDeletionTimeUnsignedInteger;

private final ByteBuffer value;
private final CellPath path;

// Please keep both int/long overloaded ctros public. Otherwise silent casts will mess timestamps when one is not
// available.
Expand All @@ -51,14 +46,10 @@ public BufferCell(ColumnMetadata column, long timestamp, int ttl, long localDele

public BufferCell(ColumnMetadata column, long timestamp, int ttl, int localDeletionTimeUnsignedInteger, ByteBuffer value, CellPath path)
{
super(column);
super(column, timestamp, ttl, localDeletionTimeUnsignedInteger, path);
assert !column.isPrimaryKeyColumn();
assert column.isComplex() == (path != null) : format("Column %s.%s(%s: %s) isComplex: %b with cellpath: %s", column.ksName, column.cfName, column.name, column.type.toString(), column.isComplex(), path);
this.timestamp = timestamp;
this.ttl = ttl;
this.localDeletionTimeUnsignedInteger = localDeletionTimeUnsignedInteger;
this.value = value;
this.path = path;
}

public static BufferCell live(ColumnMetadata column, long timestamp, ByteBuffer value)
Expand Down Expand Up @@ -92,16 +83,6 @@ public static BufferCell tombstone(ColumnMetadata column, long timestamp, long n
return new BufferCell(column, timestamp, NO_TTL, nowInSec, ByteBufferUtil.EMPTY_BYTE_BUFFER, path);
}

public long timestamp()
{
return timestamp;
}

public int ttl()
{
return ttl;
}

public ByteBuffer value()
{
return value;
Expand All @@ -112,10 +93,6 @@ public ValueAccessor<ByteBuffer> accessor()
return ByteBufferAccessor.instance;
}

public CellPath path()
{
return path;
}

public Cell<?> withUpdatedColumn(ColumnMetadata newColumn)
{
Expand Down Expand Up @@ -163,10 +140,4 @@ public long unsharedHeapSizeExcludingData()
{
return EMPTY_SIZE + ObjectSizes.sizeOnHeapExcludingDataOf(value) + (path == null ? 0 : path.unsharedHeapSizeExcludingData());
}

@Override
protected int localDeletionTimeAsUnsignedInt()
{
return localDeletionTimeUnsignedInteger;
}
}
2 changes: 2 additions & 0 deletions src/java/org/apache/cassandra/db/rows/Cell.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ public long localDeletionTime()
return deletionTimeUnsignedIntegerToLong(localDeletionTimeAsUnsignedInt());
}

public abstract long minDeletionTime();

/**
* Whether the cell is a tombstone or not.
*
Expand Down
64 changes: 64 additions & 0 deletions src/java/org/apache/cassandra/db/rows/HeapAbstractCell.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.cassandra.db.rows;

import org.apache.cassandra.schema.ColumnMetadata;

public abstract class HeapAbstractCell<V> extends AbstractCell<V>
{
// Careful: Adding vars here has an impact on memtable size
protected final long timestamp;
protected final int ttl;
protected final int localDeletionTimeUnsignedInteger;

protected final CellPath path;

protected HeapAbstractCell(ColumnMetadata column, long timestamp, int ttl, int localDeletionTimeUnsignedInteger, CellPath path)
{
super(column);
this.timestamp = timestamp;
this.ttl = ttl;
this.localDeletionTimeUnsignedInteger = localDeletionTimeUnsignedInteger;
this.path = path;
}

@Override
public long timestamp()
{
return timestamp;
}

@Override
public int ttl()
{
return ttl;
}

@Override
protected int localDeletionTimeAsUnsignedInt()
{
return localDeletionTimeUnsignedInteger;
}

@Override
public CellPath path()
{
return path;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ public long localDeletionTime()
return cell.localDeletionTime();
}

@Override
public long minDeletionTime()
{
return cell.minDeletionTime();
}

@Override
public boolean isTombstone()
{
Expand Down