Skip to content

Commit

Permalink
Passing all test batteries.
Browse files Browse the repository at this point in the history
  • Loading branch information
neocoretechs committed Sep 19, 2017
1 parent afabdf1 commit fa2785d
Show file tree
Hide file tree
Showing 9 changed files with 347 additions and 43 deletions.
1 change: 1 addition & 0 deletions battery.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -ea -DBigSack.properties="c:/users/jg/relatrix/BigSack.properties" -cp \Progra~1\apache\apache-tomcat\lib\BigSack.jar;\Progra~1\apache\apache-tomcat\lib\Relatrix.jar. com.neocoretechs.relatrix.test.BatteryRelatrix "C:/users/jg/Relatrix/TESTRelatrix"
1 change: 1 addition & 0 deletions battery2.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -ea -DBigSack.properties="c:/users/jg/relatrix/BigSack.properties" -cp \Progra~1\apache\apache-tomcat\lib\BigSack.jar;\Progra~1\apache\apache-tomcat\lib\Relatrix.jar. com.neocoretechs.relatrix.test.BatteryRelatrix2 "C:/users/jg/Relatrix/TESTRelatrix"
42 changes: 25 additions & 17 deletions src/com/neocoretechs/relatrix/Relatrix.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
* Wrapper for structural (relationship) morphism identity objects and the representable operators that retrieve them<dd>
* Utilizes the Morphism subclasses which contain reference for domain, map, range
* The lynch pin is the Morphism and its subclasses, which store and retrieve the identity morphisms indexed
* in all possible permutations of the domain,map,and range of the morphism, the identities. Conceptually, these wrappers
* swim in 2 oceans: The storage ocean and the retrieval sea. For storage, the compareTo and fullCompareTo of Morphism
* needs to account for differing classes and values. For retrieval, a partial template is constructed to retrieve the
* proper Morphism subclass and partially construct a morphism, a so-called 'representable' to partially
* in all possible permutations of the domain,map,and range of the morphism and these comprise the identities sorted
* with most significant part of the triplet first so we can retrieve ranges in all the sort orders.
* The compareTo and fullCompareTo of Morphism drive the process.
* For retrieval, a partial template is constructed of the proper Morphism subclass which puts the three elements
* in the proper sort order. To retrieve the proper Morphism subclass partially construct a morphism template to
* order the result set. The representable operator allows us to go from Cat->Set. Specifically to 'poset'.<br/>
* The critical element about retrieving relationships is to remember that the number of elements from each passed
* iteration of a RelatrixIterator is dependent on the number of "?" operators in a 'findSet'. For example,
Expand All @@ -26,15 +27,18 @@
* domain->map->range relationships, or the case of findSet(object,object,object), which return one element matching the
* relationships of the 3 objects, the returned elements(s) constitute identities in the sense of these morphisms satisfying
* the requirement to be 'categorical'. In general, all 3 element arrays returned by the Cat->set representable operators are
* the mathematical identity, or constitute the unique key in database terms.
* the mathematical identity. To follow Categorical rules, the unique key in database terms are the first 2 elements, the domain and map,
* since a conceptually a Morphism is a domain acted upon by the map function yielding the range.
* A given domain run through a 'map function' always yields the same range,
* as any function that processes an element yields one consistent result.
* Some of this work is based on a DBMS described by Alfonso F. Cardenas and Dennis McLeod (1990). Research Foundations
* in Object-Oriented and Semantic Database Systems. Prentice Hall.
* See also Category Theory, Set theory, morphisms, functors, function composition, group homomorphism
* @author jg, Groff (C) NeoCoreTechs 1997,2013,2014,2015
*/
public final class Relatrix {
private static boolean DEBUG = false;
private static boolean DEBUGREMOVE = true;
private static boolean DEBUGREMOVE = false;
private static boolean TRACE = true;

public static char OPERATOR_WILDCARD_CHAR = '*';
Expand Down Expand Up @@ -237,7 +241,7 @@ public static synchronized void remove(Comparable<?> c) throws IOException, Ille
System.out.println("Relatrix.remove iterated perm 1 "+o[0]+" of type "+o[0].getClass().getName());
m.add((Morphism) o[0]);
}
} catch(RuntimeException re) { re.printStackTrace();}
} catch(RuntimeException re) { /*re.printStackTrace();*/} // We can get this exception if the class types differ in domain
try {
Iterator<?> it = findSet("*",c,"*");
while(it.hasNext()) {
Expand All @@ -246,7 +250,7 @@ public static synchronized void remove(Comparable<?> c) throws IOException, Ille
System.out.println("Relatrix.remove iterated perm 2 "+o[0]+" of type "+o[0].getClass().getName());
m.add((Morphism) o[0]);
}
} catch(RuntimeException re) {re.printStackTrace();}
} catch(RuntimeException re) {/*re.printStackTrace();*/} // we can get this exception if map class types differ
try {
Iterator<?> it = findSet("*","*",c);
while(it.hasNext()) {
Expand All @@ -255,7 +259,8 @@ public static synchronized void remove(Comparable<?> c) throws IOException, Ille
System.out.println("Relatrix.remove iterated perm 3 "+o[0]+" of type "+o[0].getClass().getName());
m.add((Morphism) o[0]);
}
} catch(RuntimeException re) { re.printStackTrace(); }
} catch(RuntimeException re) { /*re.printStackTrace();*/ } // we can get this exception if range class types differ
// Process our array of candidates
for(Morphism mo : m) {
if( DEBUG || DEBUGREMOVE)
System.out.println("Relatrix.remove removing"+mo);
Expand Down Expand Up @@ -296,33 +301,32 @@ public static synchronized void remove(Comparable<?> d, Comparable<?> m, Compara
if( transactionTreeSets[5] == null ) {
transactionTreeSets[5] = BigSackAdapter.getBigSackSetTransaction(rmd);
}
if( DEBUG )
if( DEBUG || DEBUGREMOVE )
System.out.println("Relatrix.remove removing dmr:"+dmr);
transactionTreeSets[0].remove(dmr);

if( DEBUG )
if( DEBUG || DEBUGREMOVE )
System.out.println("Relatrix.remove removing drm:"+drm);
transactionTreeSets[1].remove(drm);

if( DEBUG )
if( DEBUG || DEBUGREMOVE )
System.out.println("Relatrix.remove removing mdr:"+mdr);
transactionTreeSets[2].remove(mdr);

if( DEBUG )
if( DEBUG || DEBUGREMOVE )
System.out.println("Relatrix.remove removing mrd:"+mrd);
transactionTreeSets[3].remove(mrd);

if( DEBUG )
if( DEBUG || DEBUGREMOVE )
System.out.println("Relatrix.remove removing rdm:"+rdm);
transactionTreeSets[4].remove(rdm);

if( DEBUG )
if( DEBUG || DEBUGREMOVE )
System.out.println("Relatrix.remove removing rmd:"+rmd);
transactionTreeSets[5].remove(rmd);

}


/**
* Retrieve from the targeted relationship those elements from the relationship to the end of relationships
* matching the given set of operators and/or objects. Essentially this is the default permutation which
Expand Down Expand Up @@ -353,11 +357,12 @@ public static synchronized Iterator<?> findSet(Object darg, Object marg, Object
/**
* Retrieve from the targeted relationship those elements from the relationship to the end of relationships
* matching the given set of operators and/or objects.
* Returns a view of the portion of this set whose elements are greater than or equal to fromElement.
* The parameters can be objects and/or operators. Semantically,
* this set-based retrieval makes no sense without at least one object to supply a value to
* work against, so in this method that check is performed. If you are going to anchor a set
* retrieval and declare it a 'head' or 'tail' relative to an object, you need a concrete object to assert that retrieval.
* @param darg Object for domain of relationship or a class template
* @param darg Object for domain of relationship
* @param marg Object for the map of relationship or a class template
* @param rarg Object for the range of the relationship or a class template
* @exception IOException low-level access or problems modifiying schema
Expand All @@ -380,6 +385,7 @@ public static synchronized Iterator<?> findTailSet(Object darg, Object marg, Obj
/**
* Retrieve the given set of relationships from the start of the elements matching the operators and/or objects
* passed, to the given relationship, should the relationship contain an object as at least one of its components.
* Returns a view of the portion of this set whose elements are strictly less than toElement.
* Semantically,this set-based retrieval makes no sense without at least one object to supply a value to
* work against, so in this method that check is performed in the createHeadsetFactory method. If you are going to anchor a set
* retrieval and declare it a 'head' or 'tail' relative to an object, you need a concrete object to assert that retrieval.
Expand All @@ -403,6 +409,8 @@ public static synchronized Iterator<?> findHeadSet(Object darg, Object marg, Obj
* arguments to the ending point of the associated variable number of parameters, which must match the number of objects
* passed in the first three arguments. If a passed argument in the first 3 parameters is neither "*" (wildcard)
* or "?" (return the object from the retrieved tuple morphism) then it is presumed to be an object.
* Returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive.
* (If fromElement and toElement are equal, the returned set is empty.)
* Semantically, this set-based retrieval makes no sense without at least one object to supply a value to
* work against, so in this method that check is performed. If you are going to anchor a set
* retrieval and declare it a 'head' or 'tail' relative to an object, you need a concrete object to assert that retrieval.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class FindSubSetMode2 extends FindSetMode2 {
public FindSubSetMode2(char dop, Object marg, char rop, Object ... xarg ) {
super(dop, marg, rop);
this.xarg = xarg;
assert(xarg.length == 1) : "Wrong variable argument length to FindSubsetMode2, expected 2 got "+xarg.length;
assert(xarg.length == 2) : "Wrong variable argument length to FindSubsetMode2, expected 2 got "+xarg.length;
}
/**
* @return Iterator for the set, each iterator return is a Comparable array of tuples of arity n=?'s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class FindSubSetMode4 extends FindSetMode4 {
public FindSubSetMode4(Object darg, char mop, char rop, Object ... xarg) {
super(darg, mop, rop);
this.xarg = xarg;
assert(xarg.length == 2) : "Wrong variable argument length to FindSubsetMode4, expected 1 got "+xarg.length;
assert(xarg.length == 1) : "Wrong variable argument length to FindSubsetMode4, expected 1 got "+xarg.length;
}
/**
* @return Iterator for the set, each iterator return is a Comparable array of tuples of arity n=?'s
Expand Down
31 changes: 24 additions & 7 deletions src/com/neocoretechs/relatrix/iterator/RelatrixIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,26 @@
import com.neocoretechs.bigsack.session.TransactionalTreeSet;
import com.neocoretechs.relatrix.Morphism;
/**
* Our main representable analog. Instances of this class deliver the set of identity morphisms, or
* deliver sets of compositions of morphisms representing new group homomorphisms as functors. More plainly, an array of iterators is returned representing the
* N return tuple '?' elements of the query. If its an identity morphism (instance of Morphism) of three keys (as in the *,*,* query)
* then N = 1 for returned Comparable elements in next(), since 1 full tuple element at an iteration is returned, that being the identity morphism.
* Implementation of the standard Iterator interface which operates on Morphisms formed into a template
* to set the lower bound of the correct range search for the properly ordered set of Morphism subclasses;
* The N return tuple '?' elements of the query. If its an identity morphism (instance of Morphism) of three keys (as in the *,*,* query)
* then N = 1 for returned Comparable elements in next(), since 1 full tuple element at an iteration is returned,
* that being the identity morphism.
* For tuples the array size is relative to the '?' query predicates. <br/>
* The critical element about retrieving relationships is to remember that the number of elements from each passed
* Stated again, The critical element about retrieving relationships is to remember that the number of elements from each passed
* iteration of a RelatrixIterator is dependent on the number of "?" operators in a 'findSet'. For example,
* if we declare findHeadSet("*","?","*") we get back a Comparable[] of one element. For findSet("?",object,"?") we
* would get back a Comparable[2] array, with each element of the array containing the relationship returned.<br/>
* @author jg Copyright (C) NeoCoreTechs 2014,2015
* findSet("*","*","*") = Comparable[1] containing identity in [0] of instance DomainMapRange
* findSet("*","*",object) = Comparable[1] identity in [0] of RangeDomainMap where 'object' is range
* findSet("*",object,object) = Comparable[1] identity in [0] of MapRangeDomain matching the 2 concrete objects
* findSet(object,object,object) = Comparable[1] identity in [0] of DomainMapRange matching 3 objects
* and the findHeadSet and findSubSet work the same way.
* findSet("?","?","?") = Comparable[3] return all, for each element in the database.
* findSet("?","?",object) = Comparable[2] return all domain and map objects for a given range object
* findSet("?","*","?") = Comparable[2] return all elements of domain and range
* etc.
* @author jg Copyright (C) NeoCoreTechs 2014,2015,2017
*
*/
public class RelatrixIterator implements Iterator<Comparable[]> {
Expand Down Expand Up @@ -164,7 +174,14 @@ protected static boolean isIdentity(short[] dmr_return) {
}
return true;
}

/**
* Determine if a range search has produced an element in range, since we deal with headSet, tailSets and subSets we have
* to check our iterator to keep it in range for concrete object keys.
* @param template
* @param record
* @param dmr_return
* @return
*/
private static boolean templateMatches(Morphism template, Morphism record, short[] dmr_return) {
if( DEBUG )
System.out.println("RelatrixIterator.templateMatches "+template+" "+record+" "+dmr_return[0]+" "+dmr_return[1]+" "+dmr_return[2]+" "+dmr_return[3]);
Expand Down
6 changes: 3 additions & 3 deletions src/com/neocoretechs/relatrix/test/ApacheLogFOODBMS.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.DirectoryStream;
Expand Down Expand Up @@ -93,6 +92,7 @@ public void getFiles(String dir) throws IOException, ParseException {
baos.flush();
load = baos.toByteArray();
baos.close();
fis.close();
}
System.out.println(" payload: "+load.length);
try {
Expand Down Expand Up @@ -135,7 +135,7 @@ public void processPayload(byte[] pl) throws IOException, ParseException, Duplic
try {
readAndProcess(line);
Comparable rel = Relatrix.transactionalStore(accessLogEntryEpoch,"accessed by",remoteHost);
Relatrix.transactionalStore(rel, "remote user", remoteUser); // unreliable
Relatrix.transactionalStore(rel, "remote user", remoteUser); // unreliable info field remoteUser
//Relatrix.transactionalStore(rel, "access time",accessLogEntryEpoch);
Relatrix.transactionalStore(rel, "client request",clientRequest);
Relatrix.transactionalStore(rel, "http status",httpStatusCode);
Expand Down Expand Up @@ -165,7 +165,7 @@ public void readAndProcess(String line) throws ParseException {
else
{
remoteHost = accessLogEntryMatcher.group(1);
remoteUser = accessLogEntryMatcher.group(2); // unreliable
remoteUser = accessLogEntryMatcher.group(2); // unreliable info in this field
requestTime=accessLogEntryMatcher.group(4);
accessLogEntryEpoch = (accesslogDateFormat.parse(requestTime)).getTime();
//System.out.println("Got time:"+accessLogEntryEpoch);
Expand Down
Loading

0 comments on commit fa2785d

Please sign in to comment.