Permalink
Browse files

Merge branch 'dhiller'

Conflicts:
	input/javasrc/com/alvazan/orm/impl/meta/scan/ScannerForClass.java
  • Loading branch information...
2 parents 05973dc + 93b444b commit 4729acd36d3ef3a1d816dbcf29de927995a7cba8 @nrelbuilder nrelbuilder committed Oct 3, 2012
Showing with 1,038 additions and 501 deletions.
  1. +6 −0 input/javasrc/com/alvazan/orm/api/base/anno/NoSqlEntity.java
  2. +21 −0 input/javasrc/com/alvazan/orm/api/base/anno/NoSqlVirtualCf.java
  3. +2 −3 input/javasrc/com/alvazan/orm/api/util/PerformanceWriteTest.java
  4. +9 −8 input/javasrc/com/alvazan/orm/api/z5api/NoSqlSession.java
  5. +4 −2 input/javasrc/com/alvazan/orm/api/z8spi/Cache.java
  6. +5 −4 input/javasrc/com/alvazan/orm/api/z8spi/NoSqlRawSession.java
  7. +11 −10 input/javasrc/com/alvazan/orm/api/z8spi/ScanInfo.java
  8. +3 −1 input/javasrc/com/alvazan/orm/api/z8spi/action/Action.java
  9. +5 −3 input/javasrc/com/alvazan/orm/api/z8spi/action/Persist.java
  10. +6 −4 input/javasrc/com/alvazan/orm/api/z8spi/action/Remove.java
  11. +15 −12 input/javasrc/com/alvazan/orm/api/z8spi/action/RemoveIndex.java
  12. +49 −0 input/javasrc/com/alvazan/orm/api/z8spi/iter/IterToVirtual.java
  13. +2 −3 input/javasrc/com/alvazan/orm/api/z8spi/meta/DboColumnCommonMeta.java
  14. +58 −5 input/javasrc/com/alvazan/orm/api/z8spi/meta/DboColumnIdMeta.java
  15. +142 −111 input/javasrc/com/alvazan/orm/api/z8spi/meta/DboColumnMeta.java
  16. +2 −3 input/javasrc/com/alvazan/orm/api/z8spi/meta/DboColumnToOneMeta.java
  17. +53 −7 input/javasrc/com/alvazan/orm/api/z8spi/meta/DboTableMeta.java
  18. +5 −5 input/javasrc/com/alvazan/orm/api/z8spi/meta/InfoForIndex.java
  19. +6 −1 input/javasrc/com/alvazan/orm/api/z8spi/meta/RowToPersist.java
  20. +11 −8 input/javasrc/com/alvazan/orm/impl/meta/data/MetaAbstractClass.java
  21. +2 −5 input/javasrc/com/alvazan/orm/impl/meta/data/MetaAbstractField.java
  22. +3 −2 input/javasrc/com/alvazan/orm/impl/meta/data/MetaClass.java
  23. +2 −2 input/javasrc/com/alvazan/orm/impl/meta/data/MetaClassInheritance.java
  24. +8 −5 input/javasrc/com/alvazan/orm/impl/meta/data/MetaClassSingle.java
  25. +1 −2 input/javasrc/com/alvazan/orm/impl/meta/data/MetaCommonField.java
  26. +1 −1 input/javasrc/com/alvazan/orm/impl/meta/data/MetaCursorField.java
  27. +19 −5 input/javasrc/com/alvazan/orm/impl/meta/data/MetaIdField.java
  28. +3 −4 input/javasrc/com/alvazan/orm/impl/meta/data/MetaProxyField.java
  29. +10 −5 input/javasrc/com/alvazan/orm/impl/meta/data/NoSqlProxyImpl.java
  30. +7 −4 input/javasrc/com/alvazan/orm/impl/meta/data/collections/CursorProxy.java
  31. +3 −3 input/javasrc/com/alvazan/orm/impl/meta/data/collections/Holder.java
  32. +1 −2 input/javasrc/com/alvazan/orm/impl/meta/data/collections/ListProxyFetchAll.java
  33. +9 −3 input/javasrc/com/alvazan/orm/impl/meta/data/collections/MapProxyFetchAll.java
  34. +12 −5 input/javasrc/com/alvazan/orm/impl/meta/data/collections/OurAbstractCollection.java
  35. +1 −2 input/javasrc/com/alvazan/orm/impl/meta/data/collections/SetProxyFetchAll.java
  36. +25 −11 input/javasrc/com/alvazan/orm/impl/meta/scan/ScannerForClass.java
  37. +20 −20 input/javasrc/com/alvazan/orm/layer0/base/BaseEntityManagerImpl.java
  38. +5 −1 input/javasrc/com/alvazan/orm/layer0/base/CursorRow.java
  39. +8 −5 input/javasrc/com/alvazan/orm/layer0/base/IterableKey.java
  40. +3 −2 input/javasrc/com/alvazan/orm/layer3/typed/CursorTypedResp.java
  41. +38 −11 input/javasrc/com/alvazan/orm/layer3/typed/NoSqlTypedSessionImpl.java
  42. +3 −2 input/javasrc/com/alvazan/orm/layer5/nosql/cache/EmptyCache.java
  43. +13 −13 input/javasrc/com/alvazan/orm/layer5/nosql/cache/NoSqlReadCacheImpl.java
  44. +17 −17 input/javasrc/com/alvazan/orm/layer5/nosql/cache/NoSqlWriteCacheImpl.java
  45. +25 −20 input/javasrc/com/alvazan/orm/layer9z/spi/db/cassandra/CassandraSession.java
  46. +113 −70 input/javasrc/com/alvazan/orm/layer9z/spi/db/cassandra/ColumnFamilyHelper.java
  47. +12 −8 input/javasrc/com/alvazan/orm/layer9z/spi/db/cassandra/CursorKeysToRows.java
  48. +2 −2 input/javasrc/com/alvazan/orm/layer9z/spi/db/cassandra/Info.java
  49. +14 −10 input/javasrc/com/alvazan/orm/layer9z/spi/db/hadoop/HadoopSession.java
  50. +4 −3 input/javasrc/com/alvazan/orm/layer9z/spi/db/inmemory/CursorKeysToRows.java
  51. +26 −19 input/javasrc/com/alvazan/orm/layer9z/spi/db/inmemory/InMemorySession.java
  52. +9 −12 input/javasrc/com/alvazan/orm/logging/NoSqlDevLogger.java
  53. +19 −26 input/javasrc/com/alvazan/orm/logging/NoSqlRawLogger.java
  54. +1 −1 input/javasrc/com/alvazan/test/MockFacade.java
  55. +6 −6 input/javasrc/com/alvazan/test/TestColumnSlice.java
  56. +1 −1 input/javasrc/com/alvazan/test/TestIndexes.java
  57. +1 −1 input/javasrc/com/alvazan/test/TestNewRawLayer.java
  58. +1 −0 input/javasrc/com/alvazan/test/TestOneToMany.java
  59. +163 −0 input/javasrc/com/alvazan/test/TestVirtualCf.java
  60. +2 −0 input/javasrc/com/alvazan/test/db/AAPartitionedTrade.java
  61. +4 −0 input/javasrc/com/alvazan/test/db/Activity.java
  62. +2 −0 input/javasrc/com/alvazan/test/db/InheritanceSuper.java
  63. +2 −0 input/javasrc/com/alvazan/test/db/PartitionedSingleTrade.java
  64. +2 −0 input/javasrc/com/alvazan/test/db/TimeSeriesData.java
@@ -8,5 +8,11 @@
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface NoSqlEntity {
+ /**
+ * This is the NAME of the column family OR the name of the virtual column family IF you use @NoSqlVirtualCf annotation
+ * Virtual Cf's are for when you play to have 1000's of Cf's as EVERY node in cassandra uses more memory every time you
+ * add a CF :(. If you want nearly infinite CF's, you need to use virtual CF's which is what we did for a project.
+ * @return
+ */
String columnfamily() default "";
}
@@ -0,0 +1,21 @@
+package com.alvazan.orm.api.base.anno;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface NoSqlVirtualCf {
+ /**
+ * You can put a whole slew of tables in ONE ColumnFamily. This maps which column family the entity
+ * will be stored in.
+ * @return
+ */
+ String storedInCf();
+
+ //This will be the prefix of every key for this entity
+ //String keyPrefix();
+
+}
@@ -99,7 +99,7 @@ private DboTableMeta setupMetaData(int numColumns, NoSqlEntityManagerFactory fac
}
DboTableMeta table = new DboTableMeta();
- table.setColumnFamily("testWrites");
+ table.setup(null, "testWrites");
DboColumnIdMeta idMeta = new DboColumnIdMeta();
idMeta.setup(table, "id", String.class, false);
@@ -139,7 +139,6 @@ public void run() {
NoSqlEntityManager mgr = mgrFactory.createEntityManager();
NoSqlSession session = mgr.getSession();
- String colFamily = table.getColumnFamily();
while(shouldRun) {
@@ -148,7 +147,7 @@ public void run() {
String rowKey = UniqueKeyGenerator.generateKey();
byte[] key = table.getIdColumnMeta().convertToStorage2(rowKey);
List<Column> columns = createColumns(i, table);
- session.put(colFamily, key, columns);
+ session.put(table, key, columns);
count++;
}
addCount(count);
@@ -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.meta.DboTableMeta;
import com.alvazan.orm.layer5.nosql.cache.NoSqlWriteCacheImpl;
import com.google.inject.ImplementedBy;
@@ -28,18 +29,18 @@
*/
public NoSqlRawSession getRawSession();
- public void persistIndex(String colFamily, String indexColFamily, byte[] rowKey, IndexColumn column);
- public void removeFromIndex(String colFamily, String indexColFamily, byte[] rowKeyBytes, IndexColumn c);
+ public void persistIndex(DboTableMeta colFamily, String indexColFamily, byte[] rowKey, IndexColumn column);
+ public void removeFromIndex(DboTableMeta colFamily, String indexColFamily, byte[] rowKeyBytes, IndexColumn c);
- public void put(String colFamily, byte[] rowKey, List<Column> columns);
+ public void put(DboTableMeta colFamily, byte[] rowKey, List<Column> columns);
/**
* Remove entire row.
*
* @param colFamily
* @param rowKey
*/
- public void remove(String colFamily, byte[] rowKey);
+ public void remove(DboTableMeta colFamily, byte[] rowKey);
/**
* Remove specific columns from a row, mainly
@@ -48,11 +49,11 @@
* @param rowKey
* @param columns
*/
- public void remove(String colFamily, byte[] rowKey, Collection<byte[]> columnNames);
+ public void remove(DboTableMeta colFamily, byte[] rowKey, Collection<byte[]> columnNames);
- public AbstractCursor<KeyValue<Row>> find(String colFamily, Iterable<byte[]> rowKeys, boolean skipCache, Integer batchSize);
+ public AbstractCursor<KeyValue<Row>> find(DboTableMeta colFamily, Iterable<byte[]> rowKeys, boolean skipCache, Integer batchSize);
- public Row find(String colFamily, byte[] rowKey);
+ public Row find(DboTableMeta colFamily, byte[] rowKey);
public void flush();
@@ -72,7 +73,7 @@
public AbstractCursor<IndexColumn> scanIndex(ScanInfo info, Key from, Key to, Integer batchSize);
public AbstractCursor<IndexColumn> scanIndex(ScanInfo scanInfo, List<byte[]> values);
- public AbstractCursor<Column> columnSlice(String colFamily, byte[] rowKey, byte[] from, byte[] to, Integer batchSize);
+ public AbstractCursor<Column> columnSlice(DboTableMeta colFamily, byte[] rowKey, byte[] from, byte[] to, Integer batchSize);
public void setOrmSessionForMeta(MetaLookup entityMgr);
@@ -1,11 +1,13 @@
package com.alvazan.orm.api.z8spi;
+import com.alvazan.orm.api.z8spi.meta.DboTableMeta;
+
public interface Cache {
- RowHolder<Row> fromCache(String colFamily, byte[] key);
+ RowHolder<Row> fromCache(DboTableMeta colFamily, byte[] key);
- void cacheRow(String colFamily, byte[] b, Row value);
+ void cacheRow(DboTableMeta colFamily, byte[] b, Row value);
}
@@ -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.meta.DboTableMeta;
@@ -25,7 +26,7 @@
public void close();
- public AbstractCursor<Column> columnSlice(String colFamily, byte[] rowKey, byte[] from, byte[] to, Integer batchSize, BatchListener l);
+ public AbstractCursor<Column> columnSlice(DboTableMeta colFamily, byte[] rowKey, byte[] from, byte[] to, Integer batchSize, BatchListener l, MetaLookup mgr);
/**
*
@@ -35,11 +36,11 @@
* @param batchSize
* @return
*/
- public AbstractCursor<IndexColumn> scanIndex(ScanInfo scan, Key from, Key to, Integer batchSize, BatchListener l);
+ public AbstractCursor<IndexColumn> scanIndex(ScanInfo scan, Key from, Key to, Integer batchSize, BatchListener l, MetaLookup mgr);
- public AbstractCursor<IndexColumn> scanIndex(ScanInfo scanInfo, List<byte[]> values, BatchListener list);
+ public AbstractCursor<IndexColumn> scanIndex(ScanInfo scanInfo, List<byte[]> values, BatchListener list, MetaLookup mgr);
- public AbstractCursor<KeyValue<Row>> find(String colFamily, Iterable<byte[]> rowKeys, Cache cache, int batchSize, BatchListener list);
+ public AbstractCursor<KeyValue<Row>> find(DboTableMeta colFamily, Iterable<byte[]> rowKeys, Cache cache, int batchSize, BatchListener list, MetaLookup mgr);
public void readMetaAndCreateTable(MetaLookup ormSession, String colFamily);
@@ -4,31 +4,32 @@
import com.alvazan.orm.api.z8spi.conv.StandardConverters;
import com.alvazan.orm.api.z8spi.meta.DboColumnMeta;
+import com.alvazan.orm.api.z8spi.meta.DboTableMeta;
public class ScanInfo {
private String indexColFamily;
private byte[] rowKey;
+ private DboTableMeta entityColFamily;
+
//optional but logging won't work without it
- private String entityColFamily;
- //optional but logging won't work without it
- private String columnName;
+ private DboColumnMeta columnName;
public static ScanInfo createScanInfo(DboColumnMeta colMeta, String partitionBy, String partitionId) {
- String realColFamily = colMeta.getOwner().getColumnFamily();
- String colName = colMeta.getColumnName();
+ DboTableMeta realColFamily = colMeta.getOwner();
String columnFamily = colMeta.getIndexTableName();
String indexRowKey = colMeta.getIndexRowKey(partitionBy, partitionId);
byte[] rowKey = StandardConverters.convertToBytes(indexRowKey);
- ScanInfo scanInfo = new ScanInfo(realColFamily, colName, columnFamily, rowKey);
+ ScanInfo scanInfo = new ScanInfo(realColFamily, colMeta, columnFamily, rowKey);
return scanInfo;
}
- public ScanInfo(String indexColFamily, byte[] rowKey2) {
+ public ScanInfo(String indexColFamily, DboTableMeta realColFamily, byte[] rowKey2) {
this.indexColFamily = indexColFamily;
+ this.entityColFamily = realColFamily;
this.rowKey = rowKey2;
}
- public ScanInfo(String realColFamily, String colName, String indexColFamily,
+ public ScanInfo(DboTableMeta realColFamily, DboColumnMeta colName, String indexColFamily,
byte[] rowKey2) {
this.entityColFamily = realColFamily;
this.columnName = colName;
@@ -42,10 +43,10 @@ public String getIndexColFamily() {
public byte[] getRowKey() {
return rowKey;
}
- public String getEntityColFamily() {
+ public DboTableMeta getEntityColFamily() {
return entityColFamily;
}
- public String getColumnName() {
+ public DboColumnMeta getColumnName() {
return columnName;
}
@@ -1,7 +1,9 @@
package com.alvazan.orm.api.z8spi.action;
+import com.alvazan.orm.api.z8spi.meta.DboTableMeta;
+
public interface Action {
- String getColFamily();
+ DboTableMeta getColFamily();
}
@@ -2,10 +2,12 @@
import java.util.List;
+import com.alvazan.orm.api.z8spi.meta.DboTableMeta;
+
public class Persist implements Action {
- private String colFamily;
+ private DboTableMeta colFamily;
private byte[] rowKey;
private long timestamp;
private List<Column> columns;
@@ -16,10 +18,10 @@ public long getTimestamp() {
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
- public String getColFamily() {
+ public DboTableMeta getColFamily() {
return colFamily;
}
- public void setColFamily(String colFamily) {
+ public void setColFamily(DboTableMeta colFamily) {
this.colFamily = colFamily;
}
public byte[] getRowKey() {
@@ -2,9 +2,11 @@
import java.util.Collection;
+import com.alvazan.orm.api.z8spi.meta.DboTableMeta;
+
public class Remove implements Action {
- private String colFamily;
+ private DboTableMeta colFamily;
private byte[] rowKey;
private RemoveEnum action;
private Collection<byte[]> columns;
@@ -15,11 +17,11 @@ public RemoveEnum getAction() {
public void setAction(RemoveEnum action) {
this.action = action;
}
- public String getColFamily() {
+ public DboTableMeta getColFamily() {
return colFamily;
}
- public void setColFamily(String colFamily) {
- this.colFamily = colFamily;
+ public void setColFamily(DboTableMeta colFamily2) {
+ this.colFamily = colFamily2;
}
public byte[] getRowKey() {
return rowKey;
@@ -1,19 +1,21 @@
package com.alvazan.orm.api.z8spi.action;
+import com.alvazan.orm.api.z8spi.meta.DboTableMeta;
+
public class RemoveIndex implements Action {
- private String colFamily;
+ private DboTableMeta colFamily;
private byte[] rowKey;
private IndexColumn column;
- private String realColFamily;
+ private String indexCfName;
- public String getColFamily() {
+ public DboTableMeta getColFamily() {
return colFamily;
}
- public void setColFamily(String colFamily) {
- this.colFamily = colFamily;
+ public void setColFamily(DboTableMeta indexColFamily) {
+ this.colFamily = indexColFamily;
}
public byte[] getRowKey() {
return rowKey;
@@ -27,14 +29,15 @@ public IndexColumn getColumn() {
public void setColumn(IndexColumn column) {
this.column = column;
}
- public String getRealColFamily() {
- return realColFamily;
- }
- public void setRealColFamily(String realColFamily) {
- this.realColFamily = realColFamily;
- }
@Override
public String toString() {
- return "indexChg to:"+realColFamily+"."+column.getColumnName();
+ return "indexChg to:"+colFamily.getColumnFamily()+"."+column.getColumnName();
}
+ public String getIndexCfName() {
+ return indexCfName;
+ }
+ public void setIndexCfName(String indexCfName) {
+ this.indexCfName = indexCfName;
+ }
+
}
@@ -0,0 +1,49 @@
+package com.alvazan.orm.api.z8spi.iter;
+
+import java.util.Iterator;
+
+import com.alvazan.orm.api.z8spi.meta.DboColumnIdMeta;
+import com.alvazan.orm.api.z8spi.meta.DboTableMeta;
+
+public class IterToVirtual implements Iterable<byte[]> {
+
+ private DboTableMeta meta;
+ private Iterable<byte[]> noSqlKeys;
+
+ public IterToVirtual(DboTableMeta meta, Iterable<byte[]> noSqlKeys) {
+ this.meta = meta;
+ this.noSqlKeys = noSqlKeys;
+ }
+
+ @Override
+ public Iterator<byte[]> iterator() {
+ return new IteratorToVirtual(meta, noSqlKeys.iterator());
+ }
+
+ private static class IteratorToVirtual implements Iterator<byte[]> {
+
+ private Iterator<byte[]> iterator;
+ private DboColumnIdMeta idMeta;
+
+ public IteratorToVirtual(DboTableMeta meta, Iterator<byte[]> iterator) {
+ this.idMeta = meta.getIdColumnMeta();
+ this.iterator = iterator;
+ }
+
+ @Override
+ public boolean hasNext() {
+ return iterator.hasNext();
+ }
+
+ @Override
+ public byte[] next() {
+ byte[] next = iterator.next();
+ return idMeta.formVirtRowKey(next);
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException("not supported");
+ }
+ }
+}
@@ -65,9 +65,8 @@ public void translateToColumn(InfoForIndex<TypedRow> info) {
col.setName(getColumnNameAsBytes());
col.setValue(byteVal);
- StorageTypeEnum storageType = this.getStorageType();
- addIndexInfo(info, value, byteVal, storageType);
- removeIndexInfo(info, value, byteVal, storageType);
+ addIndexInfo(info, value, byteVal);
+ removeIndexInfo(info, value, byteVal);
}
@Override
Oops, something went wrong.

0 comments on commit 4729acd

Please sign in to comment.