Update of /cvsroot/cweb/generic-native-test/src/java/org/CognitiveWeb/generic/core/ndx In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv6025/src/java/org/CognitiveWeb/generic/core/ndx Modified Files: TestUntypedHomogenousFloatIndex.java AbstractUntypedIndexTest.java TestDoubleTypeIndex.java TestByteTypeIndex.java TestFloatTypeIndex.java TestUntypedHomogenousStringIndex.java TestUntypedHomogenousIntegerIndex.java TestIntegerTypeIndex.java TestShortTypeIndex.java AbstractIndexTest.java TestStringTypeIndex.java TestCharacterTypeIndex.java TestLongTypeIndex.java Log Message: bigdata-gom is now running. Index: TestByteTypeIndex.java =================================================================== RCS file: /cvsroot/cweb/generic-native-test/src/java/org/CognitiveWeb/generic/core/ndx/TestByteTypeIndex.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestByteTypeIndex.java 10 Jun 2006 18:15:53 -0000 1.2 --- TestByteTypeIndex.java 5 Dec 2007 15:11:08 -0000 1.3 *************** *** 59,63 **** public class TestByteTypeIndex extends AbstractIndexTest { ! Class getType() { return Byte.class; } --- 59,63 ---- public class TestByteTypeIndex extends AbstractIndexTest { ! Class getTypeConstraint() { return Byte.class; } Index: TestDoubleTypeIndex.java =================================================================== RCS file: /cvsroot/cweb/generic-native-test/src/java/org/CognitiveWeb/generic/core/ndx/TestDoubleTypeIndex.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestDoubleTypeIndex.java 10 Jun 2006 18:15:53 -0000 1.2 --- TestDoubleTypeIndex.java 5 Dec 2007 15:11:08 -0000 1.3 *************** *** 59,63 **** public class TestDoubleTypeIndex extends AbstractIndexTest { ! Class getType() { return Double.class; } --- 59,63 ---- public class TestDoubleTypeIndex extends AbstractIndexTest { ! Class getTypeConstraint() { return Double.class; } Index: AbstractUntypedIndexTest.java =================================================================== RCS file: /cvsroot/cweb/generic-native-test/src/java/org/CognitiveWeb/generic/core/ndx/AbstractUntypedIndexTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AbstractUntypedIndexTest.java 10 Jun 2006 18:15:53 -0000 1.1 --- AbstractUntypedIndexTest.java 5 Dec 2007 15:11:08 -0000 1.2 *************** *** 77,81 **** * Returns <code>null</code>. */ ! final Class getType() { return null; } --- 77,81 ---- * Returns <code>null</code>. */ ! final Class getTypeConstraint() { return null; } *************** *** 86,90 **** */ final Object successor(Object key) throws NoSuccessorException { ! return SuccessorUtil.successor( new GValue( key ).getString() ); } --- 86,101 ---- */ final Object successor(Object key) throws NoSuccessorException { ! ! // return SuccessorUtil.successor( new GValue( key ).getString() ); ! ! /* ! * Note: Since the trailing nul character is often ignored when ! * producing a Unicode sort key I have followed it with a series of ! * characters designed to sort lower in practice than the other values ! * to which the successor will be compared. ! */ ! ! return new GValue( key ).getString()+"\0 aaaaaa"; ! } Index: TestFloatTypeIndex.java =================================================================== RCS file: /cvsroot/cweb/generic-native-test/src/java/org/CognitiveWeb/generic/core/ndx/TestFloatTypeIndex.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestFloatTypeIndex.java 10 Jun 2006 18:15:53 -0000 1.2 --- TestFloatTypeIndex.java 5 Dec 2007 15:11:08 -0000 1.3 *************** *** 59,63 **** public class TestFloatTypeIndex extends AbstractIndexTest { ! Class getType() { return Float.class; } --- 59,63 ---- public class TestFloatTypeIndex extends AbstractIndexTest { ! Class getTypeConstraint() { return Float.class; } Index: TestIntegerTypeIndex.java =================================================================== RCS file: /cvsroot/cweb/generic-native-test/src/java/org/CognitiveWeb/generic/core/ndx/TestIntegerTypeIndex.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TestIntegerTypeIndex.java 15 Jun 2006 15:47:01 -0000 1.4 --- TestIntegerTypeIndex.java 5 Dec 2007 15:11:08 -0000 1.5 *************** *** 59,63 **** public class TestIntegerTypeIndex extends AbstractIndexTest { ! Class getType() { return Integer.class; } --- 59,63 ---- public class TestIntegerTypeIndex extends AbstractIndexTest { ! Class getTypeConstraint() { return Integer.class; } Index: TestUntypedHomogenousFloatIndex.java =================================================================== RCS file: /cvsroot/cweb/generic-native-test/src/java/org/CognitiveWeb/generic/core/ndx/TestUntypedHomogenousFloatIndex.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestUntypedHomogenousFloatIndex.java 10 Jun 2006 18:15:53 -0000 1.1 --- TestUntypedHomogenousFloatIndex.java 5 Dec 2007 15:11:08 -0000 1.2 *************** *** 71,74 **** --- 71,80 ---- } + final Class getKeyConstraint() { + + return Float.class; + + } + Object[] getValues() { return new Float[] { new Float(1f), new Float(2f), new Float(3f) }; Index: TestUntypedHomogenousIntegerIndex.java =================================================================== RCS file: /cvsroot/cweb/generic-native-test/src/java/org/CognitiveWeb/generic/core/ndx/TestUntypedHomogenousIntegerIndex.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestUntypedHomogenousIntegerIndex.java 10 Jun 2006 18:15:53 -0000 1.1 --- TestUntypedHomogenousIntegerIndex.java 5 Dec 2007 15:11:08 -0000 1.2 *************** *** 55,63 **** * @version $Id$ */ - public class TestUntypedHomogenousIntegerIndex extends AbstractUntypedIndexTest { Object[] getValues() { ! return new Object[] { new Integer(10), new Integer(20), new Integer(30) }; } --- 55,74 ---- * @version $Id$ */ public class TestUntypedHomogenousIntegerIndex extends AbstractUntypedIndexTest { + final Class getKeyConstraint() { + + return Integer.class; + + } + Object[] getValues() { ! ! return new Object[] {// ! new Integer(10),// ! new Integer(20),// ! new Integer(30)// ! }; ! } Index: TestShortTypeIndex.java =================================================================== RCS file: /cvsroot/cweb/generic-native-test/src/java/org/CognitiveWeb/generic/core/ndx/TestShortTypeIndex.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestShortTypeIndex.java 10 Jun 2006 18:15:53 -0000 1.2 --- TestShortTypeIndex.java 5 Dec 2007 15:11:08 -0000 1.3 *************** *** 59,63 **** public class TestShortTypeIndex extends AbstractIndexTest { ! Class getType() { return Short.class; } --- 59,63 ---- public class TestShortTypeIndex extends AbstractIndexTest { ! Class getTypeConstraint() { return Short.class; } Index: TestStringTypeIndex.java =================================================================== RCS file: /cvsroot/cweb/generic-native-test/src/java/org/CognitiveWeb/generic/core/ndx/TestStringTypeIndex.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** TestStringTypeIndex.java 30 Nov 2007 21:53:57 -0000 1.7 --- TestStringTypeIndex.java 5 Dec 2007 15:11:08 -0000 1.8 *************** *** 49,52 **** --- 49,53 ---- import org.CognitiveWeb.generic.core.LinkSetIndex; + import org.CognitiveWeb.generic.gql.GValue; /** *************** *** 59,63 **** public class TestStringTypeIndex extends AbstractIndexTest { ! Class getType() { return String.class; --- 60,64 ---- public class TestStringTypeIndex extends AbstractIndexTest { ! Class getTypeConstraint() { return String.class; *************** *** 73,78 **** Object successor(Object key) throws NoSuccessorException { ! return SuccessorUtil.successor((String) key); } --- 74,88 ---- Object successor(Object key) throws NoSuccessorException { ! // return SuccessorUtil.successor((String) key); ! ! /* ! * Note: Since the trailing nul character is often ignored when ! * producing a Unicode sort key I have followed it with a series of ! * characters designed to sort lower in practice than the other values ! * to which the successor will be compared. ! */ + return new GValue( key ).getString()+"\0 aaaaaa"; + } Index: TestUntypedHomogenousStringIndex.java =================================================================== RCS file: /cvsroot/cweb/generic-native-test/src/java/org/CognitiveWeb/generic/core/ndx/TestUntypedHomogenousStringIndex.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** TestUntypedHomogenousStringIndex.java 10 Jun 2006 18:15:53 -0000 1.1 --- TestUntypedHomogenousStringIndex.java 5 Dec 2007 15:11:08 -0000 1.2 *************** *** 55,63 **** * @version $Id$ */ - public class TestUntypedHomogenousStringIndex extends AbstractUntypedIndexTest { Object[] getValues() { return new Object[]{"a","b","c"}; } --- 55,70 ---- * @version $Id$ */ public class TestUntypedHomogenousStringIndex extends AbstractUntypedIndexTest { + final Class getKeyConstraint() { + + return String.class; + + } + Object[] getValues() { + return new Object[]{"a","b","c"}; + } Index: AbstractIndexTest.java =================================================================== RCS file: /cvsroot/cweb/generic-native-test/src/java/org/CognitiveWeb/generic/core/ndx/AbstractIndexTest.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** AbstractIndexTest.java 4 Dec 2007 20:30:32 -0000 1.8 --- AbstractIndexTest.java 5 Dec 2007 15:11:08 -0000 1.9 *************** *** 77,84 **** * @version $Id$ * - * FIXME {@link TestUntypedHomogenousIntegerIndex} and friends should select their - * keys randomly from the appropriate value type rather than choosing the value - * type randomly. - * * @todo Add tests for more of the methods on the ILinkSetIndex API. Are there * features being tested by <code>generic-test</code> that are not being --- 77,80 ---- *************** *** 122,128 **** * untyped. */ ! abstract Class getType(); /** * <p> * Return an array of three values that are consistent with the index type. --- 118,142 ---- * untyped. */ ! abstract Class getTypeConstraint(); /** + * Return the type constraint on the generated keys. For strongly typed + * indices this MUST be the same non-<code>null</code> value returned by + * {@link #getTypeConstraint()} (this is the default behavior). For an + * untyped index, this MAY be non-<code>null</code> in order to in + * constrain the generated keys without imposing a type constraint on the + * index itself. + * + * @return The type constraint on the generated keys or <code>null</code> + * if the generated keys will not be constraint to a specific data + * type. + */ + Class getKeyConstraint() { + + return getTypeConstraint(); + + } + + /** * <p> * Return an array of three values that are consistent with the index type. *************** *** 151,158 **** * computing the successor. * </p> * * @param key * A non-null key consistent with the type returned by ! * {@link #getType()} * * @return The sucessor of the key. --- 165,179 ---- * computing the successor. * </p> + * <p> + * Note: The precise formulation of the successor of a key is in fact + * backend specific. However, it is sufficient for the purposes of this test + * suite if this method returns an application key that is the successor of + * the given key where the given key is one of those returned by + * {@link #getValues()}. + * </p> * * @param key * A non-null key consistent with the type returned by ! * {@link #getTypeConstraint()} * * @return The sucessor of the key. *************** *** 186,190 **** * the explicit intention for this test. */ ! pc.setType( getType() ); // Collects link set. --- 207,211 ---- * the explicit intention for this test. */ ! pc.setType( getTypeConstraint() ); // Collects link set. *************** *** 321,325 **** * Test case for an index constrained to NOT allow duplicate keys. */ - public void test_distinctKeys() throws NoSuccessorException { --- 342,345 ---- *************** *** 334,338 **** * the explicit intention for this test. */ ! pc.setType( getType() ); // Collects link set. --- 354,358 ---- * the explicit intention for this test. */ ! pc.setType( getTypeConstraint() ); // Collects link set. *************** *** 376,382 **** // verify the total ordering. assertSameIndexRanges( ! new IGeneric[][] { new IGeneric[] { g1 }, ! new IGeneric[] { g2 }, new IGeneric[] { g3 } }, 3, ndx ! .iterator()); // verify fromKey == toKey yeilds empty range. --- 396,407 ---- // verify the total ordering. assertSameIndexRanges( ! new IGeneric[][] { ! new IGeneric[] { g1 }, ! new IGeneric[] { g2 }, ! new IGeneric[] { g3 } ! }, ! 3, ! ndx.iterator() ! ); // verify fromKey == toKey yeilds empty range. *************** *** 385,410 **** /* * We use getPoints() to verify successor is computed correctly. ! * getPoints() is written to use the successor semantics of the key. We ! * add an entry under the successor of the key. getPoints() will pull ! * back exactly the entry(s) for the specified key but not the entry ! * under the successor of the key iff the index successor semantics are ! * correct. * ! * The index now contains: (v1=>g1),(v2=>g2), (v3=>g3) */ ! Object key = v1; ! Object successor = successor( v1 ); assertSameIndexRanges(new IGeneric[][] { new IGeneric[] { g1 } }, 1, ! ndx.getPoints(key)); assertSameIndexRanges(new IGeneric[][] { new IGeneric[] { g1 } }, 1, ! ndx.getRange(key, successor)); /* * Verify specific points. Since the keys are distinct it is not ! * possible for their to be more than one value for any given key. */ assertTrue( ndx.contains( v1 ) ); assertTrue( ndx.contains( v2 ) ); assertTrue( ndx.contains( v3 ) ); assertFalse( ndx.contains( successor(v2) ) ); assertParanoidEquals( g1, ndx.getPoint(v1)); --- 410,436 ---- /* * We use getPoints() to verify successor is computed correctly. ! * getPoints() is written to use the successor semantics of the key. * ! * Note: The index now contains: (v1=>g1),(v2=>g2), (v3=>g3) */ ! showLinkSet(g.getLinkSet(ac), pc); ! showIndex(ndx, pc); assertSameIndexRanges(new IGeneric[][] { new IGeneric[] { g1 } }, 1, ! ndx.getPoints(v1)); assertSameIndexRanges(new IGeneric[][] { new IGeneric[] { g1 } }, 1, ! ndx.getRange(v1, successor(v1))); /* * Verify specific points. Since the keys are distinct it is not ! * possible for there to be more than one value for any given key. */ assertTrue( ndx.contains( v1 ) ); assertTrue( ndx.contains( v2 ) ); assertTrue( ndx.contains( v3 ) ); + /* + * Note: This test can not be written since the manner in which + * successor of a key that is coerced to a String is specific to the + * backend. + */ assertFalse( ndx.contains( successor(v2) ) ); assertParanoidEquals( g1, ndx.getPoint(v1)); *************** *** 435,439 **** * Set the index type constraint (if any). */ ! pc.setType( getType() ); // Collects link set. --- 461,465 ---- * Set the index type constraint (if any). */ ! pc.setType( getTypeConstraint() ); // Collects link set. *************** *** 1041,1044 **** --- 1067,1072 ---- final ObjectManager om = getNativeObjectManager(); + + int counter = om.beginNativeTransaction(); final PropertyClass ac = (PropertyClass) om.getPropertyClass( getUniquePropertyName("assoc")); *************** *** 1046,1055 **** final PropertyClass pc = (PropertyClass) om.getPropertyClass( getUniquePropertyName("value")); ! final Class cls = getType(); ! ! final IKeyGenerator keyGen = new KeyGenerator(ntrials/* maxDistinct */, cls); pc.setType( cls ); ! Generic g = new Generic( om ); --- 1074,1083 ---- final PropertyClass pc = (PropertyClass) om.getPropertyClass( getUniquePropertyName("value")); ! final Class cls = getTypeConstraint(); pc.setType( cls ); ! ! final IKeyGenerator keyGen = new KeyGenerator(ntrials/* maxDistinct */, getKeyConstraint()); ! Generic g = new Generic( om ); *************** *** 1151,1154 **** --- 1179,1184 ---- verify(linkSet, ndx); } + + counter = om.commitNativeTransaction(counter); } *************** *** 1250,1259 **** */ ! final Class cls = getType(); ! ! final IKeyGenerator keyGen = new KeyGenerator(maxCreated/* maxDistinct */, cls); valueClass.setType( cls ); ! /* * @todo indexEverything, duplicateKeys, sortNullsToEnd --- 1280,1289 ---- */ ! final Class cls = getTypeConstraint(); valueClass.setType( cls ); ! ! final IKeyGenerator keyGen = new KeyGenerator(maxCreated/* maxDistinct */, getKeyConstraint()); ! /* * @todo indexEverything, duplicateKeys, sortNullsToEnd *************** *** 1271,1280 **** final Vector oids = new Vector(); // of created objects. - boolean done = false; int[] opsum = new int[Op.lastOp + 1]; // #of times we do each // operation. ! long optotal = 0; ! while (!done && (maxCreated == 0 || oids.size() < maxCreated)) { // next operation. always an insert if there are no records in the --- 1301,1310 ---- final Vector oids = new Vector(); // of created objects. int[] opsum = new int[Op.lastOp + 1]; // #of times we do each // operation. ! int optotal = 0; ! while ((maxCreated == 0 || oids.size() < maxCreated) ! && (maxOps == 0 || optotal < maxOps)) { // next operation. always an insert if there are no records in the *************** *** 1825,1828 **** } ! } --- 1855,1858 ---- } ! } Index: TestCharacterTypeIndex.java =================================================================== RCS file: /cvsroot/cweb/generic-native-test/src/java/org/CognitiveWeb/generic/core/ndx/TestCharacterTypeIndex.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TestCharacterTypeIndex.java 30 Nov 2007 21:53:57 -0000 1.3 --- TestCharacterTypeIndex.java 5 Dec 2007 15:11:08 -0000 1.4 *************** *** 59,63 **** public class TestCharacterTypeIndex extends AbstractIndexTest { ! Class getType() { return Character.class; --- 59,63 ---- public class TestCharacterTypeIndex extends AbstractIndexTest { ! Class getTypeConstraint() { return Character.class; Index: TestLongTypeIndex.java =================================================================== RCS file: /cvsroot/cweb/generic-native-test/src/java/org/CognitiveWeb/generic/core/ndx/TestLongTypeIndex.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TestLongTypeIndex.java 4 Dec 2007 20:30:32 -0000 1.4 --- TestLongTypeIndex.java 5 Dec 2007 15:11:08 -0000 1.5 *************** *** 64,68 **** public class TestLongTypeIndex extends AbstractIndexTest { ! Class getType() { return Long.class; } --- 64,68 ---- public class TestLongTypeIndex extends AbstractIndexTest { ! Class getTypeConstraint() { return Long.class; } *************** *** 161,165 **** */ ! final Class cls = getType(); valueClass.setType( cls ); --- 161,165 ---- */ ! final Class cls = getTypeConstraint(); valueClass.setType( cls ); |