Skip to content

Commit

Permalink
Ported counter interation methods to Java.
Browse files Browse the repository at this point in the history
  • Loading branch information
bflorian committed Dec 11, 2012
1 parent 3d6dca1 commit eaa87db
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 32 deletions.
2 changes: 1 addition & 1 deletion CassandraOrmGrailsPlugin.groovy
Expand Up @@ -20,7 +20,7 @@ import com.reachlocal.grails.plugins.cassandra.uuid.UuidDynamicMethods
class CassandraOrmGrailsPlugin class CassandraOrmGrailsPlugin
{ {
// the plugin version // the plugin version
def version = "0.3.2" def version = "0.3.3"


// the version or versions of Grails the plugin is designed for // the version or versions of Grails the plugin is designed for
def grailsVersion = "2.0.0 > *" def grailsVersion = "2.0.0 > *"
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
@@ -1,4 +1,4 @@
<plugin name='cassandra-orm' version='0.3.2' grailsVersion='2.0.0 &gt; *'> <plugin name='cassandra-orm' version='0.3.3' grailsVersion='2.0.0 &gt; *'>
<author>Bob Florian</author> <author>Bob Florian</author>
<authorEmail>bob.florian@reachlocal.com</authorEmail> <authorEmail>bob.florian@reachlocal.com</authorEmail>
<title>Cassandra Object Persistence Framework</title> <title>Cassandra Object Persistence Framework</title>
Expand Down
Expand Up @@ -231,7 +231,7 @@ class CounterUtils
def groupKeys = KeyHelper.makeGroupKeyList(groupBy, 'yyyy-MM') def groupKeys = KeyHelper.makeGroupKeyList(groupBy, 'yyyy-MM')
def rowKey = KeyHelper.counterRowKey(findBy, groupKeys, filter) def rowKey = KeyHelper.counterRowKey(findBy, groupKeys, filter)


columnsList(persistence.getColumnRange( CounterHelper.columnsList(persistence.getColumnRange(
ks, ks,
cf, cf,
rowKey, rowKey,
Expand All @@ -247,7 +247,7 @@ class CounterUtils
def groupKeys = KeyHelper.makeGroupKeyList(groupBy, 'yyyy-MM-dd') def groupKeys = KeyHelper.makeGroupKeyList(groupBy, 'yyyy-MM-dd')
def rowKey = KeyHelper.counterRowKey(findBy, groupKeys, filter) def rowKey = KeyHelper.counterRowKey(findBy, groupKeys, filter)


columnsList(persistence.getColumnRange( CounterHelper.columnsList(persistence.getColumnRange(
ks, ks,
cf, cf,
rowKey, rowKey,
Expand All @@ -263,7 +263,7 @@ class CounterUtils
def groupKeys = groupBy //makeGroupKeyList(groupBy, "yyyy-MM-dd'T'HH") def groupKeys = groupBy //makeGroupKeyList(groupBy, "yyyy-MM-dd'T'HH")
def rowKey = KeyHelper.counterRowKey(findBy, groupKeys, filter) def rowKey = KeyHelper.counterRowKey(findBy, groupKeys, filter)


columnsList(persistence.getColumnRange( CounterHelper.columnsList(persistence.getColumnRange(
ks, ks,
cf, cf,
rowKey, rowKey,
Expand Down Expand Up @@ -293,7 +293,7 @@ class CounterUtils
cal.add(Calendar.YEAR, 1) cal.add(Calendar.YEAR, 1)
} }


columnsListFromRowList(persistence.getRowsColumnRange( CounterHelper.columnsListFromRowList(persistence.getRowsColumnRange(
ks, ks,
cf, cf,
rowKeys, rowKeys,
Expand Down Expand Up @@ -322,7 +322,7 @@ class CounterUtils
cal.add(Calendar.MONTH, 1) cal.add(Calendar.MONTH, 1)
} }


columnsListFromRowList(persistence.getRowsColumnRange( CounterHelper.columnsListFromRowList(persistence.getRowsColumnRange(
ks, ks,
cf, cf,
rowKeys, rowKeys,
Expand All @@ -342,28 +342,6 @@ class CounterUtils
cols?.size() ? persistence.name(persistence.getColumnByIndex(cols, 0)) : null cols?.size() ? persistence.name(persistence.getColumnByIndex(cols, 0)) : null
} }


static columnsList(columnsIterator)
{
// TODO - performance!
def cols = []
columnsIterator.each {
cols << it
}
cols
}

static columnsListFromRowList(rowList, persistence)
{
// TODO - performance!
def cols = []
rowList.each {row ->
persistence.getColumns(row).each {
cols << it
}
}
cols
}

static rollUpCounterDates(Map map, DateFormat fromFormat, grain, timeZone, toFormatArg) static rollUpCounterDates(Map map, DateFormat fromFormat, grain, timeZone, toFormatArg)
{ {
def toFormat = CounterHelper.toDateFormat(grain, timeZone, toFormatArg) def toFormat = CounterHelper.toDateFormat(grain, timeZone, toFormatArg)
Expand Down
Expand Up @@ -64,9 +64,9 @@ public interface PersistenceProvider
void execute(mutationBatch); void execute(mutationBatch);
Object getRow(rows, key); Object getRow(rows, key);
*/
Object getColumns(row); Iterable getColumns(Object row);
/*
Object getColumn(row, name); Object getColumn(row, name);
Object getColumnByIndex(row, index); Object getColumnByIndex(row, index);
Expand Down
Expand Up @@ -676,4 +676,25 @@ static public List<String> mergeNonDateKeys(List<String> rowKeys, List<String> c
return columnKeys; return columnKeys;
} }
} }

static public List columnsList(Iterable columnsIterator)
{
List<Object> cols = new ArrayList<Object>();
for (Object it: columnsIterator) {
cols.add(it);
}
return cols;
}

static public List columnsListFromRowList(Iterable rowList, PersistenceProvider persistence)
{
// TODO - performance!
List<Object> cols = new ArrayList<Object>();
for (Object row: rowList) {
for (Object it: persistence.getColumns(row)) {
cols.add(it);
}
}
return cols;
}
} }

0 comments on commit eaa87db

Please sign in to comment.