Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
Refactor: extract interface from SuperRow and move it to the api package
Browse files Browse the repository at this point in the history
  • Loading branch information
rantav committed Sep 19, 2010
1 parent 7dbfeae commit bf7d85e
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.Map;

import me.prettyprint.hector.api.beans.OrderedSuperRows;
import me.prettyprint.hector.api.beans.SuperRow;

import org.apache.cassandra.thrift.SuperColumn;

Expand All @@ -25,7 +26,7 @@ public OrderedSuperRowsImpl(LinkedHashMap<String, List<SuperColumn>> thriftRet,
super(thriftRet, sNameSerializer, nameSerializer, valueSerializer);
rowsList = new ArrayList<SuperRow<SN,N,V>>(thriftRet.size());
for (Map.Entry<String, List<SuperColumn>> entry: thriftRet.entrySet()) {
rowsList.add(new SuperRow<SN,N,V>(entry.getKey(), entry.getValue(), sNameSerializer,
rowsList.add(new SuperRowImpl<SN,N,V>(entry.getKey(), entry.getValue(), sNameSerializer,
nameSerializer, valueSerializer));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.List;

import me.prettyprint.cassandra.utils.Assert;
import me.prettyprint.hector.api.beans.SuperRow;

import org.apache.cassandra.thrift.SuperColumn;

Expand All @@ -19,23 +20,25 @@
* Column value type
*
*/
public final class SuperRow<SN, N, V> {
public final class SuperRowImpl<SN, N, V> implements SuperRow<SN, N, V> {

private final String rowKey;
private final SuperSlice<SN, N, V> slice;

/*package*/SuperRow(String rowKey, List<SuperColumn> thriftSuperColumns,
/*package*/SuperRowImpl(String rowKey, List<SuperColumn> thriftSuperColumns,
Serializer<SN> sNameSerializer, Serializer<N> nameSerializer, Serializer<V> valueSerializer) {
Assert.noneNull(rowKey, thriftSuperColumns, nameSerializer, valueSerializer);
this.rowKey = rowKey;
slice = new SuperSlice<SN, N, V>(thriftSuperColumns, sNameSerializer, nameSerializer,
valueSerializer);
}

@Override
public String getKey() {
return rowKey;
}

@Override
public SuperSlice<SN, N, V> getSuperSlice() {
return slice;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Map;

import me.prettyprint.cassandra.utils.Assert;
import me.prettyprint.hector.api.beans.SuperRow;
import me.prettyprint.hector.api.beans.SuperRows;

import org.apache.cassandra.thrift.SuperColumn;
Expand All @@ -27,7 +28,7 @@ public SuperRowsImpl(Map<String, List<SuperColumn>> thriftSuperColumns, Serializ
Assert.noneNull(thriftSuperColumns, sNameSerializer, nameSerializer, valueSerializer);
rows = new HashMap<String, SuperRow<SN, N, V>>(thriftSuperColumns.size());
for (Map.Entry<String, List<SuperColumn>> entry : thriftSuperColumns.entrySet()) {
rows.put(entry.getKey(), new SuperRow<SN, N, V>(entry.getKey(), entry.getValue(),
rows.put(entry.getKey(), new SuperRowImpl<SN, N, V>(entry.getKey(), entry.getValue(),
sNameSerializer, nameSerializer, valueSerializer));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import java.util.List;

import me.prettyprint.cassandra.model.SuperRow;

public interface OrderedSuperRows<SN, N, V> extends SuperRows<SN, N, V>{

/**
Expand Down
24 changes: 24 additions & 0 deletions src/main/java/me/prettyprint/hector/api/beans/SuperRow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package me.prettyprint.hector.api.beans;

import me.prettyprint.cassandra.model.SuperSlice;

/**
* A SuperRow is a touple consisting of a Key and a SuperSlice.
*
* A Row may be used to hold the returned value from queries such as get_range_slices.
*
* @author Ran Tavory
*
* @param <N>
* Column name type
* @param <V>
* Column value type
*
*/
public interface SuperRow<SN, N, V> {

String getKey();

SuperSlice<SN, N, V> getSuperSlice();

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.prettyprint.hector.api.beans;

import me.prettyprint.cassandra.model.SuperRow;

/**
* Returned by a MultigetSuperSliceQuery (multiget_slice for supercolumns)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import me.prettyprint.hector.api.beans.OrderedSuperRows;
import me.prettyprint.hector.api.beans.Row;
import me.prettyprint.hector.api.beans.Rows;
import me.prettyprint.hector.api.beans.SuperRow;
import me.prettyprint.hector.api.beans.SuperRows;
import me.prettyprint.hector.api.query.ColumnQuery;
import me.prettyprint.hector.api.query.MultigetSliceQuery;
Expand Down

0 comments on commit bf7d85e

Please sign in to comment.