/** * Does the location exist? * * @param location * @return whether the contents of the location are non null */ public synchronized boolean containsLocation(int[] location) { return (get(location) != null); }
/** * Recursively fetch contents of all nodes under the specified index array, * used by the prefix matching iteration strategy */ public synchronized List<Job> jobsWithPrefix(int[] prefix) { List<Job> jobs = new ArrayList<Job>(); NamedNode prefixNode = nodeAt(prefix); if (prefixNode != null) { getJobsUnder(prefixNode, jobs); } return jobs; }
private synchronized void printNode(NamedNode node, StringBuffer sb, String indent) { sb.append(indent+"Node ("+node.contents+")\n"); String newIndent = indent + " "; for (NamedNode child : node.children) { if (child == null) { sb.append(newIndent+"null\n"); } else { printNode(child, sb, newIndent); } } }
/** * Chop the cache off at the specified index * * @param indexArray */ public synchronized void cut(int[] indexArray) { if (indexArray.length > 0) { int[] newIndex = tail(indexArray); NamedNode node = nodeAt(newIndex); if (node != null) { if (node.children.size() >= indexArray[indexArray.length - 1]) { node.children.set(indexArray[indexArray.length - 1], null); } } } }
caches = new TreeCache[getChildCount()]; for (int i = 0; i < getChildCount(); i++) { caches[i] = new TreeCache(); caches[inputIndex].insertJob(newJob); matchingJobs = caches[1].jobsWithPrefix(prefixIndexArray); caches[1].cut(prefixIndexArray); if (caches[0].getIndexLength() > 0) { int[] prefix = new int[caches[0].getIndexLength()]; for (int i = 0; i < prefix.length; i++) { prefix[i] = newJob.getIndex()[i]; Job j = caches[0].get(prefix); if (j != null) { Map<String, T2Reference> newDataMap = new HashMap<String, T2Reference>();
TreeCache[] caches = new TreeCache[getChildCount()]; for (int i = 0; i < getChildCount(); i++) { caches[i] = new TreeCache(); caches[inputIndex].insertJob(newJob); int[] indexArray = newJob.getIndex(); boolean foundMatch = true; for (TreeCache cache : caches) { if (cache.containsLocation(indexArray)) { newDataMap.putAll(cache.get(indexArray).getData()); } else { foundMatch = false; cache.cut(indexArray);
private synchronized void getJobsUnder(NamedNode node, List<Job> jobs) { if (node.contents != null) { jobs.add(node.contents); } else { for (NamedNode child : node.children) { getJobsUnder(child, jobs); } } }
/** * Get the job object at the specified index array * * @param location * @return Job at the specified location or null if no such job was found */ public synchronized Job get(int[] location) { NamedNode n = nodeAt(location); if (n == null) { return null; } return n.contents; }
caches = new TreeCache[getChildCount()]; for (int i = 0; i < getChildCount(); i++) { caches[i] = new TreeCache(); caches[inputIndex].insertJob(newJob); matchingJobs = caches[1].jobsWithPrefix(prefixIndexArray); caches[1].cut(prefixIndexArray); if (caches[0].getIndexLength() > 0) { int[] prefix = new int[caches[0].getIndexLength()]; for (int i = 0; i < prefix.length; i++) { prefix[i] = newJob.getIndex()[i]; Job j = caches[0].get(prefix); if (j != null) { Map<String, T2Reference> newDataMap = new HashMap<String, T2Reference>();
TreeCache[] caches = new TreeCache[getChildCount()]; for (int i = 0; i < getChildCount(); i++) { caches[i] = new TreeCache(); caches[inputIndex].insertJob(newJob); int[] indexArray = newJob.getIndex(); boolean foundMatch = true; for (TreeCache cache : caches) { if (cache.containsLocation(indexArray)) { newDataMap.putAll(cache.get(indexArray).getData()); } else { foundMatch = false; cache.cut(indexArray);
/** * Chop the cache off at the specified index * * @param indexArray */ public synchronized void cut(int[] indexArray) { if (indexArray.length > 0) { int[] newIndex = tail(indexArray); NamedNode node = nodeAt(newIndex); if (node != null) { if (node.children.size() >= indexArray[indexArray.length - 1]) { node.children.set(indexArray[indexArray.length - 1], null); } } } }
private synchronized void getJobsUnder(NamedNode node, List<Job> jobs) { if (node.contents != null) { jobs.add(node.contents); } else { for (NamedNode child : node.children) { getJobsUnder(child, jobs); } } }
/** * Get the job object at the specified index array * * @param location * @return Job at the specified location or null if no such job was found */ public synchronized Job get(int[] location) { NamedNode n = nodeAt(location); if (n == null) { return null; } return n.contents; }
caches = new TreeCache[getChildCount()]; for (int i = 0; i < getChildCount(); i++) { caches[i] = new TreeCache(); caches[inputIndex].insertJob(newJob); matchingJobs = caches[1].jobsWithPrefix(prefixIndexArray); caches[1].cut(prefixIndexArray); if (caches[0].getIndexLength() > 0) { int[] prefix = new int[caches[0].getIndexLength()]; for (int i = 0; i < prefix.length; i++) { prefix[i] = newJob.getIndex()[i]; Job j = caches[0].get(prefix); if (j != null) { Map<String, EntityIdentifier> newDataMap = new HashMap<String, EntityIdentifier>();
TreeCache[] caches = new TreeCache[getChildCount()]; for (int i = 0; i < getChildCount(); i++) { caches[i] = new TreeCache(); caches[inputIndex].insertJob(newJob); int[] indexArray = newJob.getIndex(); boolean foundMatch = true; for (TreeCache cache : caches) { if (cache.containsLocation(indexArray)) { newDataMap.putAll(cache.get(indexArray).getData()); } else { foundMatch = false; cache.cut(indexArray);
/** * Recursively fetch contents of all nodes under the specified index array, * used by the prefix matching iteration strategy */ public synchronized List<Job> jobsWithPrefix(int[] prefix) { List<Job> jobs = new ArrayList<Job>(); NamedNode prefixNode = nodeAt(prefix); if (prefixNode != null) { getJobsUnder(prefixNode, jobs); } return jobs; }
/** * Chop the cache off at the specified index * * @param indexArray */ public synchronized void cut(int[] indexArray) { if (indexArray.length > 0) { int[] newIndex = tail(indexArray); NamedNode node = nodeAt(newIndex); if (node != null) { if (node.children.size() >= indexArray[indexArray.length - 1]) { node.children.set(indexArray[indexArray.length - 1], null); } } } }