Skip to content

Commit

Permalink
Storage engine refactor, a.k.a CASSANDRA-8099
Browse files Browse the repository at this point in the history
Initial patch, see ticket for details
  • Loading branch information
Sylvain Lebresne committed Jun 30, 2015
1 parent 5c31a86 commit a991b64
Show file tree
Hide file tree
Showing 645 changed files with 49,381 additions and 42,227 deletions.
56 changes: 0 additions & 56 deletions bin/sstablekeys

This file was deleted.

41 changes: 0 additions & 41 deletions bin/sstablekeys.bat

This file was deleted.

2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<property name="maven-repository-url" value="https://repository.apache.org/content/repositories/snapshots"/>
<property name="maven-repository-id" value="apache.snapshots.https"/>

<property name="test.timeout" value="60000" />
<property name="test.timeout" value="1200000" />
<property name="test.long.timeout" value="600000" />
<property name="test.burn.timeout" value="600000" />

Expand Down
376 changes: 376 additions & 0 deletions guide_8099.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/java/org/apache/cassandra/cache/AutoSavingCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ else if (cacheType == CacheService.CacheType.COUNTER_CACHE)
else
type = OperationType.UNKNOWN;

info = new CompactionInfo(CFMetaData.denseCFMetaData(SystemKeyspace.NAME, cacheType.toString(), BytesType.instance),
info = new CompactionInfo(CFMetaData.createFake(SystemKeyspace.NAME, cacheType.toString()),
type,
0,
keysEstimate,
Expand Down
29 changes: 22 additions & 7 deletions src/java/org/apache/cassandra/cache/CounterCacheKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,44 @@
import java.util.Arrays;
import java.util.UUID;

import org.apache.cassandra.db.composites.CellName;
import org.apache.cassandra.db.composites.CellNames;
import org.apache.cassandra.config.ColumnDefinition;
import org.apache.cassandra.db.*;
import org.apache.cassandra.db.rows.CellPath;
import org.apache.cassandra.db.marshal.CompositeType;
import org.apache.cassandra.utils.*;

public class CounterCacheKey implements CacheKey
{
private static final long EMPTY_SIZE = ObjectSizes.measure(new CounterCacheKey(null, ByteBufferUtil.EMPTY_BYTE_BUFFER, CellNames.simpleDense(ByteBuffer.allocate(1))))
private static final long EMPTY_SIZE = ObjectSizes.measure(new CounterCacheKey(null, ByteBufferUtil.EMPTY_BYTE_BUFFER, ByteBuffer.allocate(1)))
+ ObjectSizes.measure(new UUID(0, 0));

public final UUID cfId;
public final byte[] partitionKey;
public final byte[] cellName;

private CounterCacheKey(UUID cfId, ByteBuffer partitionKey, CellName cellName)
public CounterCacheKey(UUID cfId, ByteBuffer partitionKey, ByteBuffer cellName)
{
this.cfId = cfId;
this.partitionKey = ByteBufferUtil.getArray(partitionKey);
this.cellName = ByteBufferUtil.getArray(cellName.toByteBuffer());
this.cellName = ByteBufferUtil.getArray(cellName);
}

public static CounterCacheKey create(UUID cfId, ByteBuffer partitionKey, CellName cellName)
public static CounterCacheKey create(UUID cfId, ByteBuffer partitionKey, Clustering clustering, ColumnDefinition c, CellPath path)
{
return new CounterCacheKey(cfId, partitionKey, cellName);
return new CounterCacheKey(cfId, partitionKey, makeCellName(clustering, c, path));
}

private static ByteBuffer makeCellName(Clustering clustering, ColumnDefinition c, CellPath path)
{
int cs = clustering.size();
ByteBuffer[] values = new ByteBuffer[cs + 1 + (path == null ? 0 : path.size())];
for (int i = 0; i < cs; i++)
values[i] = clustering.get(i);
values[cs] = c.name.bytes;
if (path != null)
for (int i = 0; i < path.size(); i++)
values[cs + 1 + i] = path.get(i);
return CompositeType.build(values);
}

public UUID getCFId()
Expand Down
8 changes: 4 additions & 4 deletions src/java/org/apache/cassandra/cache/OHCProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import com.google.common.base.Function;

import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.db.ColumnFamily;
import org.apache.cassandra.db.TypeSizes;
import org.apache.cassandra.db.partitions.CachedPartition;
import org.apache.cassandra.io.util.DataOutputPlus;
import org.apache.cassandra.io.util.Memory;
import org.apache.cassandra.net.MessagingService;
Expand Down Expand Up @@ -159,15 +159,15 @@ public void serialize(IRowCacheEntry entry, DataOutput out) throws IOException
if (isSentinel)
out.writeLong(((RowCacheSentinel) entry).sentinelId);
else
ColumnFamily.serializer.serialize((ColumnFamily) entry, new DataOutputPlusAdapter(out), MessagingService.current_version);
CachedPartition.cacheSerializer.serialize((CachedPartition)entry, new DataOutputPlusAdapter(out));
}

public IRowCacheEntry deserialize(DataInput in) throws IOException
{
boolean isSentinel = in.readBoolean();
if (isSentinel)
return new RowCacheSentinel(in.readLong());
return ColumnFamily.serializer.deserialize(in, MessagingService.current_version);
return CachedPartition.cacheSerializer.deserialize(in);
}

public int serializedSize(IRowCacheEntry entry)
Expand All @@ -177,7 +177,7 @@ public int serializedSize(IRowCacheEntry entry)
if (entry instanceof RowCacheSentinel)
size += typeSizes.sizeof(((RowCacheSentinel) entry).sentinelId);
else
size += ColumnFamily.serializer.serializedSize((ColumnFamily) entry, typeSizes, MessagingService.current_version);
size += CachedPartition.cacheSerializer.serializedSize((CachedPartition) entry, typeSizes);
return size;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.io.IOException;

import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.db.ColumnFamily;
import org.apache.cassandra.db.TypeSizes;
import org.apache.cassandra.db.partitions.CachedPartition;
import org.apache.cassandra.io.ISerializer;
import org.apache.cassandra.io.util.DataOutputPlus;
import org.apache.cassandra.net.MessagingService;
Expand All @@ -45,15 +45,16 @@ public void serialize(IRowCacheEntry entry, DataOutputPlus out) throws IOExcepti
if (isSentinel)
out.writeLong(((RowCacheSentinel) entry).sentinelId);
else
ColumnFamily.serializer.serialize((ColumnFamily) entry, out, MessagingService.current_version);
CachedPartition.cacheSerializer.serialize((CachedPartition)entry, out);
}

public IRowCacheEntry deserialize(DataInput in) throws IOException
{
boolean isSentinel = in.readBoolean();
if (isSentinel)
return new RowCacheSentinel(in.readLong());
return ColumnFamily.serializer.deserialize(in, MessagingService.current_version);

return CachedPartition.cacheSerializer.deserialize(in);
}

public long serializedSize(IRowCacheEntry entry, TypeSizes typeSizes)
Expand All @@ -62,7 +63,7 @@ public long serializedSize(IRowCacheEntry entry, TypeSizes typeSizes)
if (entry instanceof RowCacheSentinel)
size += typeSizes.sizeof(((RowCacheSentinel) entry).sentinelId);
else
size += ColumnFamily.serializer.serializedSize((ColumnFamily) entry, typeSizes, MessagingService.current_version);
size += CachedPartition.cacheSerializer.serializedSize((CachedPartition) entry, typeSizes);
return size;
}
}
Expand Down
Loading

0 comments on commit a991b64

Please sign in to comment.