Permalink
Browse files

Merge pull request #10 from deanhiller/master

merging deanhiller with easility
  • Loading branch information...
2 parents 5604265 + 2541320 commit 58f7ee08ef717103ae8d9b36306b589c8f47e1e1 @easility easility committed Jan 10, 2013
Showing with 1,993 additions and 235 deletions.
  1. +0 −69 .classpath
  2. +15 −0 input/javasrc/com/alvazan/orm/api/base/CursorToManyImpl.java
  3. +4 −2 input/javasrc/com/alvazan/orm/api/z5api/NoSqlSession.java
  4. +2 −1 input/javasrc/com/alvazan/orm/api/z8spi/NoSqlRawSession.java
  5. +12 −0 input/javasrc/com/alvazan/orm/api/z8spi/iter/AbstractCursor.java
  6. +4 −0 input/javasrc/com/alvazan/orm/api/z8spi/iter/Cursor.java
  7. +4 −0 input/javasrc/com/alvazan/orm/api/z8spi/iter/DirectCursor.java
  8. +9 −0 input/javasrc/com/alvazan/orm/api/z8spi/iter/EmptyCursor.java
  9. +53 −0 input/javasrc/com/alvazan/orm/api/z8spi/iter/IndiceToVirtual.java
  10. +49 −0 input/javasrc/com/alvazan/orm/api/z8spi/iter/IterableWrappingCursor.java
  11. +51 −0 input/javasrc/com/alvazan/orm/api/z8spi/iter/ListWrappingCursor.java
  12. +22 −9 input/javasrc/com/alvazan/orm/api/z8spi/iter/ProxyTempCursor.java
  13. +0 −1 input/javasrc/com/alvazan/orm/api/z8spi/meta/ReflectionUtil.java
  14. +2 −1 input/javasrc/com/alvazan/orm/impl/meta/data/NoSqlProxyImpl.java
  15. +22 −4 input/javasrc/com/alvazan/orm/impl/meta/data/collections/CursorProxy.java
  16. +3 −2 input/javasrc/com/alvazan/orm/impl/meta/data/collections/MapProxyFetchAll.java
  17. +3 −2 input/javasrc/com/alvazan/orm/impl/meta/data/collections/OurAbstractCollection.java
  18. +17 −4 input/javasrc/com/alvazan/orm/layer0/base/BaseEntityManagerImpl.java
  19. +17 −0 input/javasrc/com/alvazan/orm/layer0/base/CursorRow.java
  20. +12 −0 input/javasrc/com/alvazan/orm/layer0/base/DebugCursor.java
  21. +1 −4 input/javasrc/com/alvazan/orm/layer0/base/QueryAdapter.java
  22. +52 −1 input/javasrc/com/alvazan/orm/layer3/typed/CursorAllViews.java
  23. +22 −0 input/javasrc/com/alvazan/orm/layer3/typed/CursorFillNulls.java
  24. +33 −0 input/javasrc/com/alvazan/orm/layer3/typed/CursorJoinedViews.java
  25. +13 −0 input/javasrc/com/alvazan/orm/layer3/typed/CursorProxyDirect.java
  26. +15 −0 input/javasrc/com/alvazan/orm/layer3/typed/CursorToIndexPoint.java
  27. +10 −0 input/javasrc/com/alvazan/orm/layer3/typed/CursorTypedResp.java
  28. +77 −0 input/javasrc/com/alvazan/orm/layer3/typed/IndiceCursorProxy.java
  29. +6 −5 input/javasrc/com/alvazan/orm/layer3/typed/NoSqlTypedSessionImpl.java
  30. +3 −2 input/javasrc/com/alvazan/orm/layer3/typed/QueryResultImpl.java
  31. +50 −0 input/javasrc/com/alvazan/orm/layer3/typed/TypedProxyWrappingCursor.java
  32. +2 −1 input/javasrc/com/alvazan/orm/layer5/nosql/cache/NoSqlReadCacheImpl.java
  33. +4 −2 input/javasrc/com/alvazan/orm/layer5/nosql/cache/NoSqlWriteCacheImpl.java
  34. +40 −3 input/javasrc/com/alvazan/orm/layer5/query/CachingCursor.java
  35. +82 −0 input/javasrc/com/alvazan/orm/layer5/query/CursorForAnd.java
  36. +67 −3 input/javasrc/com/alvazan/orm/layer5/query/CursorForJoin.java
  37. +58 −31 input/javasrc/com/alvazan/orm/layer5/query/CursorForOr.java
  38. +27 −5 input/javasrc/com/alvazan/orm/layer5/query/CursorForPrimaryKey.java
  39. +18 −0 input/javasrc/com/alvazan/orm/layer5/query/CursorSimpleTranslator.java
  40. +28 −3 input/javasrc/com/alvazan/orm/layer5/query/SpiIndexQueryImpl.java
  41. +35 −4 input/javasrc/com/alvazan/orm/layer9z/spi/db/cassandra/CassandraSession.java
  42. +73 −10 input/javasrc/com/alvazan/orm/layer9z/spi/db/cassandra/CursorColumnSlice.java
  43. +129 −11 input/javasrc/com/alvazan/orm/layer9z/spi/db/cassandra/CursorKeysToRows2.java
  44. +42 −2 input/javasrc/com/alvazan/orm/layer9z/spi/db/cassandra/CursorOfFutures.java
  45. +24 −0 input/javasrc/com/alvazan/orm/layer9z/spi/db/cassandra/CursorResult.java
  46. +21 −10 input/javasrc/com/alvazan/orm/layer9z/spi/db/cassandra/CursorReturnsEmptyRows.java
  47. +119 −0 input/javasrc/com/alvazan/orm/layer9z/spi/db/cassandra/OurColumnListIterator.java
  48. +5 −2 input/javasrc/com/alvazan/orm/layer9z/spi/db/cassandra/StartQueryManyKeys.java
  49. +2 −1 input/javasrc/com/alvazan/orm/layer9z/spi/db/hadoop/HadoopSession.java
  50. +153 −21 input/javasrc/com/alvazan/orm/layer9z/spi/db/inmemory/CursorKeysToRows.java
  51. +4 −3 input/javasrc/com/alvazan/orm/layer9z/spi/db/inmemory/InMemorySession.java
  52. +2 −1 input/javasrc/com/alvazan/orm/logging/NoSqlDevLogger.java
  53. +2 −1 input/javasrc/com/alvazan/orm/logging/NoSqlRawLogger.java
  54. +19 −3 input/javasrc/com/alvazan/orm/parser/antlr/ExpressionNode.java
  55. +7 −1 input/javasrc/com/alvazan/orm/parser/antlr/OptimizeAddJoinInfo.java
  56. +7 −1 input/javasrc/com/alvazan/orm/parser/antlr/ParsedNode.java
  57. +30 −0 input/javasrc/com/alvazan/orm/parser/antlr/ScannerSql.java
  58. +34 −0 input/javasrc/com/alvazan/play/logging/LogDao.java
  59. +1 −0 input/javasrc/com/alvazan/test/FactorySingleton.java
  60. +8 −0 input/javasrc/com/alvazan/test/TestGrammar.java
  61. +19 −1 input/javasrc/com/alvazan/test/TestIndexAndOrParens.java
  62. +33 −0 input/javasrc/com/alvazan/test/TestIndexes.java
  63. +235 −0 input/javasrc/com/alvazan/test/TestJoins.java
  64. +24 −1 input/javasrc/com/alvazan/test/TestOneToMany.java
  65. +41 −1 input/javasrc/com/alvazan/test/db/Account.java
  66. +15 −6 input/schemas/NoSql.g
View
@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="input/javasrc"/>
- <classpathentry kind="src" path="output/src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="input/libexclude/junit.jar"/>
- <classpathentry kind="lib" path="input/libexclude/play-1.2.x-dcdb1f3.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/antlr-jar-2.7.7.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/antlr-jar-3.2.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/antlr-runtime-jar-3.2.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/avro-jar-1.4.0-cassandra-1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/commons-cli-jar-1.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/commons-codec-jar-1.2.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/commons-lang-jar-2.4.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/commons-logging-jar-1.1.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/compress-lzf-bundle-0.8.4.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/concurrentlinkedhashmap-lru-jar-1.2.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/high-scale-lib-jar-1.1.2.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/httpclient-jar-4.0.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/httpcore-jar-4.0.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/jamm-jar-0.2.5.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/jetty-jar-6.1.22.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/jetty-util-jar-6.1.22.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/jline-jar-0.9.94.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/joda-time-jar-2.0.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/json-simple-jar-1.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/libthrift-jar-0.7.0.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/metrics-core-jar-2.0.3.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/org.apache.servicemix.bundles.commons-csv-bundle-1.0-r706900_3.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/servlet-api-jar-2.5-20081211.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/servlet-api-jar-2.5.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/slf4j-api-jar-1.6.4.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/snakeyaml-jar-1.6.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/snappy-java-bundle-1.0.4.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/snaptree-jar-0.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/stax-api-jar-1.0.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/stringtemplate-jar-3.2.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/junit-jar-4.9.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/javassist-jar-3.16.1-GA.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/activation-jar-1.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/aopalliance-jar-1.0.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/args4j-jar-2.0.16.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/asm-jar-3.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/cglib-jar-2.2.1-v20090111.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/geronimo-jms_1.1_spec-jar-1.0.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/groovy-all-jar-1.7.6.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/guice-jar-3.0.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/guice-javadoc-3.0.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/guice-source-3.0.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/hamcrest-core-jar-1.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/janino-jar-2.5.16.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/javax.inject-jar-1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/logback-classic-jar-1.0.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/logback-core-jar-1.0.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/mail-jar-1.4.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/servlet-api-jar-2.5.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-inmemory/slf4j-api-jar-1.6.4.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/jsr305-jar-1.3.9.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/astyanax-jar-1.56.18.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/cassandra-all-jar-1.1.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/cassandra-thrift-jar-1.1.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/guava-jar-11.0.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/jackson-core-asl-jar-1.9.2.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/jackson-mapper-asl-jar-1.9.2.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/jettison-bundle-1.2.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/joda-convert-jar-1.1.jar"/>
- <classpathentry kind="lib" path="output/jardist/playorm-astyanax/uuid-jar-3.2.jar"/>
- <classpathentry kind="output" path="eclipsegen"/>
-</classpath>
@@ -27,6 +27,13 @@ public CursorToManyImpl(List<T> elements) {
public void beforeFirst() {
index = -1;
}
+
+ @Override
+ public void afterLast() {
+ index = -1;
+ if (list!=null)
+ index=list.size();
+ }
@Override
public boolean next() {
@@ -35,6 +42,14 @@ public boolean next() {
return true;
return false;
}
+
+ @Override
+ public boolean previous() {
+ index--;
+ if(index >= 0)
+ return true;
+ return false;
+ }
@Override
public T getCurrent() {
@@ -12,6 +12,7 @@
import com.alvazan.orm.api.z8spi.action.Column;
import com.alvazan.orm.api.z8spi.action.IndexColumn;
import com.alvazan.orm.api.z8spi.iter.AbstractCursor;
+import com.alvazan.orm.api.z8spi.iter.DirectCursor;
import com.alvazan.orm.api.z8spi.meta.DboTableMeta;
import com.alvazan.orm.layer5.nosql.cache.NoSqlWriteCacheImpl;
import com.google.inject.ImplementedBy;
@@ -53,7 +54,7 @@
public void removeColumn(DboTableMeta colFamily, byte[] rowKey, byte[] columnName);
- public AbstractCursor<KeyValue<Row>> find(DboTableMeta colFamily, Iterable<byte[]> rowKeys, boolean skipReadCache, boolean cacheResults, Integer batchSize);
+ public AbstractCursor<KeyValue<Row>> find(DboTableMeta colFamily, DirectCursor<byte[]> rowKeys, boolean skipReadCache, boolean cacheResults, Integer batchSize);
public Row find(DboTableMeta colFamily, byte[] rowKey);
@@ -75,7 +76,8 @@
* @return
*/
public AbstractCursor<IndexColumn> scanIndex(ScanInfo info, Key from, Key to, Integer batchSize);
- public AbstractCursor<IndexColumn> scanIndex(ScanInfo scanInfo, List<byte[]> values);
+ public AbstractCursor<IndexColumn> scanIndex(ScanInfo scanInfo, List<byte[]> values);
+
public AbstractCursor<Column> columnSlice(DboTableMeta colFamily, byte[] rowKey, byte[] from, byte[] to, Integer batchSize);
@@ -7,6 +7,7 @@
import com.alvazan.orm.api.z8spi.action.Column;
import com.alvazan.orm.api.z8spi.action.IndexColumn;
import com.alvazan.orm.api.z8spi.iter.AbstractCursor;
+import com.alvazan.orm.api.z8spi.iter.DirectCursor;
import com.alvazan.orm.api.z8spi.meta.DboTableMeta;
@@ -40,7 +41,7 @@
public AbstractCursor<IndexColumn> scanIndex(ScanInfo scanInfo, List<byte[]> values, BatchListener list, MetaLookup mgr);
- public AbstractCursor<KeyValue<Row>> find(DboTableMeta colFamily, Iterable<byte[]> rowKeys, Cache cache, int batchSize, BatchListener list, MetaLookup mgr);
+ public AbstractCursor<KeyValue<Row>> find(DboTableMeta colFamily, DirectCursor<byte[]> rowKeys, Cache cache, int batchSize, BatchListener list, MetaLookup mgr);
public void readMetaAndCreateTable(MetaLookup ormSession, String colFamily);
@@ -14,8 +14,20 @@ public final boolean next() {
}
return true;
}
+
+ @Override
+ public final boolean previous() {
+ currentValue = previousImpl();
+ if(currentValue == null) {
+ //There is NO previous value so screw it, return false
+ return false;
+ }
+ return true;
+ }
public abstract Holder<T> nextImpl();
+
+ public abstract Holder<T> previousImpl();
@Override
public final T getCurrent() {
@@ -10,5 +10,9 @@
boolean next();
T getCurrent();
+
+ void afterLast();
+
+ boolean previous();
}
@@ -5,7 +5,11 @@
public interface DirectCursor<T> {
public Holder<T> nextImpl();
+
+ public Holder<T> previousImpl();
public void beforeFirst();
+ public void afterLast();
+
}
@@ -11,6 +11,15 @@ public void beforeFirst() {
public com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder<T> nextImpl() {
return null;
}
+
+ @Override
+ public void afterLast() {
+ }
+
+ @Override
+ public com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder<T> previousImpl() {
+ return null;
+ }
}
@@ -0,0 +1,53 @@
+package com.alvazan.orm.api.z8spi.iter;
+
+import com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder;
+import com.alvazan.orm.api.z8spi.meta.DboTableMeta;
+
+public class IndiceToVirtual implements DirectCursor<byte[]> {
+
+ private DboTableMeta meta;
+ private DirectCursor<byte[]> noSqlKeys;
+
+ public IndiceToVirtual(DboTableMeta meta, DirectCursor<byte[]> noSqlKeys) {
+ this.meta = meta;
+ this.noSqlKeys = noSqlKeys;
+ }
+
+ @Override
+ public String toString() {
+ String tabs = StringLocal.getAndAdd();
+ String retVal = "IndiceToVirtual(keyToVirtualKeyTranslatorCursor)["+tabs+noSqlKeys+tabs+"]";
+ StringLocal.set(tabs.length());
+ return retVal;
+ }
+
+
+ @Override
+ public Holder<byte[]> nextImpl() {
+ Holder<byte[]> nextHolder = noSqlKeys.nextImpl();
+ if (nextHolder == null)
+ return null;
+ byte[] next = nextHolder.getValue();
+ return new Holder<byte[]>(meta.getIdColumnMeta().formVirtRowKey(next));
+ }
+
+ @Override
+ public Holder<byte[]> previousImpl() {
+ Holder<byte[]> nextHolder = noSqlKeys.previousImpl();
+ if (nextHolder == null)
+ return null;
+ byte[] next = nextHolder.getValue();
+ return new Holder<byte[]>(meta.getIdColumnMeta().formVirtRowKey(next));
+ }
+
+ @Override
+ public void beforeFirst() {
+ noSqlKeys.beforeFirst();
+
+ }
+
+ @Override
+ public void afterLast() {
+ noSqlKeys.afterLast();
+ }
+}
@@ -0,0 +1,49 @@
+package com.alvazan.orm.api.z8spi.iter;
+
+import java.util.Iterator;
+
+import com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder;
+
+public class IterableWrappingCursor<T> implements DirectCursor<T> {
+
+ private Iterable<T> iter;
+ private Iterator<T> currentIterator;
+
+ public IterableWrappingCursor(Iterable<T> iter) {
+ this.iter = iter;
+ }
+
+ @Override
+ public String toString() {
+ String tabs = StringLocal.getAndAdd();
+ String retVal = "IteratorWrappingCursor(iteratorWrappingCursor)["+tabs+iter+tabs+"]";
+ StringLocal.set(tabs.length());
+ return retVal;
+ }
+
+
+ @Override
+ public Holder<T> nextImpl() {
+ if (currentIterator == null)
+ beforeFirst();
+ if (!currentIterator.hasNext())
+ return null;
+ return new Holder<T>(currentIterator.next());
+ }
+
+ @Override
+ public Holder<T> previousImpl() {
+ throw new UnsupportedOperationException("We can't go backward on a cursor that is wrapping an iterator");
+ }
+
+ @Override
+ public void beforeFirst() {
+ currentIterator = iter.iterator();
+
+ }
+
+ @Override
+ public void afterLast() {
+ throw new UnsupportedOperationException("We can't go backward on a cursor that is wrapping an iterator");
+ }
+}
@@ -0,0 +1,51 @@
+package com.alvazan.orm.api.z8spi.iter;
+
+import java.util.List;
+import java.util.ListIterator;
+
+import com.alvazan.orm.api.z8spi.iter.AbstractCursor.Holder;
+
+public class ListWrappingCursor<T> implements DirectCursor<T> {
+
+ private List<T> backingList;
+ private ListIterator<T> backingListIterator;
+
+ public ListWrappingCursor(List<T> list) {
+ backingList = list;
+ this.backingListIterator = list.listIterator();
+ }
+
+ @Override
+ public String toString() {
+ String tabs = StringLocal.getAndAdd();
+ String retVal = "ListWrappingCursor(ListWrappingCursor)["+tabs+backingListIterator+tabs+"]";
+ StringLocal.set(tabs.length());
+ return retVal;
+ }
+
+
+ @Override
+ public Holder<T> nextImpl() {
+ if (backingListIterator.hasNext())
+ return new Holder<T>(backingListIterator.next());
+ return null;
+ }
+
+ @Override
+ public Holder<T> previousImpl() {
+ if (backingListIterator.hasPrevious())
+ return new Holder<T>(backingListIterator.previous());
+ return null;
+ }
+
+ @Override
+ public void beforeFirst() {
+ backingListIterator = backingList.listIterator();
+ }
+
+ @Override
+ public void afterLast() {
+ while (backingListIterator.hasNext())
+ backingListIterator.next();
+ }
+}
Oops, something went wrong.

0 comments on commit 58f7ee0

Please sign in to comment.