Skip to content

Commit

Permalink
remove dependency of CFS in storage engine API
Browse files Browse the repository at this point in the history
  • Loading branch information
DikangGu committed Oct 27, 2017
1 parent f1c69f6 commit 68c0fe2
Showing 1 changed file with 74 additions and 15 deletions.
89 changes: 74 additions & 15 deletions src/java/org/apache/cassandra/engine/StorageEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,49 +19,108 @@
package org.apache.cassandra.engine;

import java.util.Collection;
import java.util.UUID;

import org.apache.cassandra.db.ColumnFamilyStore;
import org.apache.cassandra.db.SinglePartitionReadCommand;
import org.apache.cassandra.db.Clustering;
import org.apache.cassandra.db.DecoratedKey;
import org.apache.cassandra.db.DeletionTime;
import org.apache.cassandra.db.RegularAndStaticColumns;
import org.apache.cassandra.db.Slices;
import org.apache.cassandra.db.filter.ColumnFilter;
import org.apache.cassandra.db.partitions.PartitionUpdate;
import org.apache.cassandra.db.rows.EncodingStats;
import org.apache.cassandra.db.rows.Row;
import org.apache.cassandra.db.rows.UnfilteredRowIterator;
import org.apache.cassandra.dht.Range;
import org.apache.cassandra.dht.Token;
import org.apache.cassandra.engine.streaming.AbstractStreamReceiveTask;
import org.apache.cassandra.engine.streaming.AbstractStreamTransferTask;
import org.apache.cassandra.schema.TableMetadata;
import org.apache.cassandra.streaming.StreamSession;
import org.apache.cassandra.streaming.StreamSummary;
import org.apache.cassandra.utils.SearchIterator;

public interface StorageEngine
{
void openColumnFamilyStore(ColumnFamilyStore cfs);
/**
* This method should create all necessary files but does not need to open the table.
*/
void create(String tableName);

/**
* Before any read or write operations are performaned on a table, the cassandra server
* will call the open method to open the table data.
*/
void open(String tableName);

/**
* Apply a mutation to storage engine
*/
void applyMutate(String tableName,
PartitionUpdate partitionUpdate,
boolean writeCommitLog);

/**
* In-memory representation of a Partition.
*
* Storage engine needs to implement iterators (UnfilteredRowIterator) to
* avoid "materializing" a full partition/query response in memory as much as possible.
*/
public interface Partition
{
public TableMetadata metadata();
public DecoratedKey partitionKey();
public DeletionTime partitionLevelDeletion();

public RegularAndStaticColumns columns();

public EncodingStats stats();

/**
* Whether the partition object has no informations at all, including any deletion informations.
*/
public boolean isEmpty();

/**
* Returns the row corresponding to the provided clustering, or null if there is not such row.
*/
public Row getRow(Clustering clustering);

/**
* Returns an iterator that allows to search specific rows efficiently.
*/
public SearchIterator<Clustering, Row> searchIterator(ColumnFilter columns, boolean reversed);

void apply(final ColumnFamilyStore cfs,
final PartitionUpdate partitionUpdate,
final boolean writeCommitLog);
/**
* Returns an UnfilteredRowIterator over all the rows/RT contained by this partition.
*/
public UnfilteredRowIterator unfilteredIterator();

UnfilteredRowIterator queryStorage(ColumnFamilyStore cfs,
SinglePartitionReadCommand readCommand);
/**
* Returns an UnfilteredRowIterator over the rows/RT contained by this partition
* selected by the provided slices.
*/
public UnfilteredRowIterator unfilteredIterator(ColumnFilter columns, Slices slices, boolean reversed);
}

void forceFlush(final ColumnFamilyStore cfs);
void forceFlush(String tableName);

void truncate(final ColumnFamilyStore cfs);
void truncate(String tableName);

void close(final ColumnFamilyStore cfs);
void close(String tableName);

void setCompactionThroughputMbPerSec(int throughputMbPerSec);

void forceMajorCompaction(ColumnFamilyStore cfs);
void forceMajorCompaction(String tableName);

/**
* Streaming APIs
*/
AbstractStreamTransferTask getStreamTransferTask(StreamSession session,
UUID cfId,
String tableName,
Collection<Range<Token>> ranges);

AbstractStreamReceiveTask getStreamReceiveTask(StreamSession session,
StreamSummary summary);

boolean cleanUpRanges(final ColumnFamilyStore cfs);
boolean cleanUpRanges(final String tableName);
}

0 comments on commit 68c0fe2

Please sign in to comment.