Java Code Examples for org.apache.lucene.util.OpenBitSet#nextSetBit()
The following examples show how to use
org.apache.lucene.util.OpenBitSet#nextSetBit() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FDTree.java From winter with Apache License 2.0 | 6 votes |
public FDTreeElement addGeneralization(OpenBitSet lhs, OpenBitSet rhs) { FDTreeElement currentNode = this; currentNode.addRhsAttributes(rhs); boolean newElement = false; for (int i = lhs.nextSetBit(0); i >= 0; i = lhs.nextSetBit(i + 1)) { if (currentNode.getChildren() == null) { currentNode.setChildren(new FDTreeElement[this.numAttributes]); currentNode.getChildren()[i] = new FDTreeElement(this.numAttributes); newElement = true; } else if (currentNode.getChildren()[i] == null) { currentNode.getChildren()[i] = new FDTreeElement(this.numAttributes); newElement = true; } currentNode = currentNode.getChildren()[i]; currentNode.addRhsAttributes(rhs); } if (newElement) return currentNode; return null; }
Example 2
Source File: ClusterTreeElement.java From winter with Apache License 2.0 | 6 votes |
public boolean add(int[][] compressedRecords, OpenBitSet lhs, int nextLhsAttr, int recordId, int content) { if (nextLhsAttr < 0) return this.content != -1 && this.content == content; int nextCluster = compressedRecords[recordId][nextLhsAttr]; if (nextCluster < 0) return true; ClusterTreeElement child = this.children.get(nextCluster); if (child == null) { child = new ClusterTreeElement(compressedRecords, lhs, lhs.nextSetBit(nextLhsAttr + 1), recordId, content); this.children.put(nextCluster, child); return true; } return child.add(compressedRecords, lhs, lhs.nextSetBit(nextLhsAttr + 1), recordId, content); }
Example 3
Source File: FDTreeElement.java From winter with Apache License 2.0 | 6 votes |
protected void getFdAndGeneralizations(OpenBitSet lhs, int rhs, int currentLhsAttr, OpenBitSet currentLhs, List<OpenBitSet> foundLhs) { if (this.isFd(rhs)) foundLhs.add(currentLhs.clone()); if (this.children == null) return; while (currentLhsAttr >= 0) { int nextLhsAttr = lhs.nextSetBit(currentLhsAttr + 1); if ((this.children[currentLhsAttr] != null) && (this.children[currentLhsAttr].hasRhsAttribute(rhs))) { currentLhs.set(currentLhsAttr); this.children[currentLhsAttr].getFdAndGeneralizations(lhs, rhs, nextLhsAttr, currentLhs, foundLhs); currentLhs.clear(currentLhsAttr); } currentLhsAttr = nextLhsAttr; } }
Example 4
Source File: FDTree.java From winter with Apache License 2.0 | 6 votes |
public FDTreeElement addGeneralization(OpenBitSet lhs, int rhs) { FDTreeElement currentNode = this; currentNode.addRhsAttribute(rhs); boolean newElement = false; for (int i = lhs.nextSetBit(0); i >= 0; i = lhs.nextSetBit(i + 1)) { if (currentNode.getChildren() == null) { currentNode.setChildren(new FDTreeElement[this.numAttributes]); currentNode.getChildren()[i] = new FDTreeElement(this.numAttributes); newElement = true; } else if (currentNode.getChildren()[i] == null) { currentNode.getChildren()[i] = new FDTreeElement(this.numAttributes); newElement = true; } currentNode = currentNode.getChildren()[i]; currentNode.addRhsAttribute(rhs); } if (newElement) return currentNode; return null; }
Example 5
Source File: FDTreeElement.java From winter with Apache License 2.0 | 6 votes |
protected void filterGeneralizations(OpenBitSet lhs, int rhs, int currentLhsAttr, OpenBitSet currentLhs) { if (currentLhs.equals(lhs)) return; this.rhsFds.clear(rhs); // Is the dependency already read and we have not yet found a generalization? if (currentLhsAttr < 0) return; if (this.children != null) { for (int nextLhsAttr = lhs.nextSetBit(currentLhsAttr); nextLhsAttr >= 0; nextLhsAttr = lhs.nextSetBit(nextLhsAttr + 1)) { if ((this.children[nextLhsAttr] != null) && (this.children[nextLhsAttr].hasRhsAttribute(rhs))) { currentLhs.set(nextLhsAttr); this.children[nextLhsAttr].filterGeneralizations(lhs, rhs, lhs.nextSetBit(nextLhsAttr + 1), currentLhs); currentLhs.clear(nextLhsAttr); } } } }
Example 6
Source File: LhsTrieElement.java From winter with Apache License 2.0 | 6 votes |
protected void getLhsAndGeneralizations(OpenBitSet lhs, int currentLhsAttr, OpenBitSet currentLhs, List<OpenBitSet> foundLhs) { if (this.children == null) { foundLhs.add(currentLhs.clone()); return; } while (currentLhsAttr >= 0) { int nextLhsAttr = lhs.nextSetBit(currentLhsAttr + 1); if (this.children[currentLhsAttr] != null) { currentLhs.set(currentLhsAttr); this.children[currentLhsAttr].getLhsAndGeneralizations(lhs, nextLhsAttr, currentLhs, foundLhs); currentLhs.clear(currentLhsAttr); } currentLhsAttr = nextLhsAttr; } }
Example 7
Source File: FDTree.java From winter with Apache License 2.0 | 5 votes |
public boolean containsFd(OpenBitSet lhs, int rhs) { FDTreeElement element = this; for (int i = lhs.nextSetBit(0); i >= 0; i = lhs.nextSetBit(i + 1)) { if ((element.getChildren() == null) || (element.getChildren()[i] == null)) return false; element = element.getChildren()[i]; } return element.isFd(rhs); }
Example 8
Source File: FDTree.java From winter with Apache License 2.0 | 5 votes |
public List<OpenBitSet> getFdAndGeneralizations(OpenBitSet lhs, int rhs) { List<OpenBitSet> foundLhs = new ArrayList<>(); OpenBitSet currentLhs = new OpenBitSet(); int nextLhsAttr = lhs.nextSetBit(0); this.getFdAndGeneralizations(lhs, rhs, nextLhsAttr, currentLhs, foundLhs); return foundLhs; }
Example 9
Source File: FDTree.java From winter with Apache License 2.0 | 5 votes |
public boolean containsFunctionalDependency(OpenBitSet lhs, int rhs) { FDTreeElement currentNode = this; for (int i = lhs.nextSetBit(0); i >= 0; i = lhs.nextSetBit(i + 1)) { if ((currentNode.getChildren() == null) || (currentNode.getChildren()[i] == null)) return false; currentNode = currentNode.getChildren()[i]; } return currentNode.isFd(rhs); }
Example 10
Source File: ClusterTree.java From winter with Apache License 2.0 | 5 votes |
public boolean add(int[][] compressedRecords, OpenBitSet lhs, int recordId, int content) { int firstLhsAttr = lhs.nextSetBit(0); int firstCluster = compressedRecords[recordId][firstLhsAttr]; if (firstCluster < 0) return true; ClusterTreeElement child = this.children.get(firstCluster); if (child == null) { child = new ClusterTreeElement(compressedRecords, lhs, lhs.nextSetBit(firstLhsAttr + 1), recordId, content); this.children.put(firstCluster, child); return true; } return child.add(compressedRecords, lhs, lhs.nextSetBit(firstLhsAttr + 1), recordId, content); }
Example 11
Source File: FDTreeWrapper.java From winter with Apache License 2.0 | 5 votes |
protected void listFDs(FDTreeElement fds, OpenBitSet lhs, Map<Set<TableColumn>,Set<TableColumn>> result) { Set<TableColumn> lhsIDs = new HashSet<>(); for(int i = lhs.nextSetBit(0); i >= 0; i = lhs.nextSetBit(i + 1)) { lhsIDs.add(idxToAtt[i]); } Set<TableColumn> rhsIDs = new HashSet<>(); for(int i = fds.getFds().nextSetBit(0); i >= 0; i = fds.getFds().nextSetBit(i + 1)) { rhsIDs.add(idxToAtt[i]); } rhsIDs = new HashSet<>(Q.without(rhsIDs, lhsIDs)); if(rhsIDs.size()>0) { result.put(lhsIDs, rhsIDs); } if(fds.getChildren()!=null) { for(int childAttr = 0; childAttr < fds.getNumAttributes(); childAttr++) { FDTreeElement element = fds.getChildren()[childAttr]; if(element!=null) { lhs.set(childAttr); listFDs(element, lhs, result); lhs.clear(childAttr); } } } }
Example 12
Source File: BlurUtil.java From incubator-retired-blur with Apache License 2.0 | 5 votes |
private static int getStartingPosition(OpenBitSet docsInRowSpanToFetch, int start) { int docStartingPosition = docsInRowSpanToFetch.nextSetBit(0); int offset = 0; while (offset < start) { docStartingPosition = docsInRowSpanToFetch.nextSetBit(docStartingPosition + 1); offset++; } return docStartingPosition; }
Example 13
Source File: LhsTrie.java From winter with Apache License 2.0 | 5 votes |
public List<OpenBitSet> getLhsAndGeneralizations(OpenBitSet lhs) { List<OpenBitSet> foundLhs = new ArrayList<>(); OpenBitSet currentLhs = new OpenBitSet(); int nextLhsAttr = lhs.nextSetBit(0); this.getLhsAndGeneralizations(lhs, nextLhsAttr, currentLhs, foundLhs); return foundLhs; }
Example 14
Source File: FDTree.java From winter with Apache License 2.0 | 5 votes |
public OpenBitSet getFdOrGeneralization(OpenBitSet lhs, int rhs) { OpenBitSet foundLhs = new OpenBitSet(); int nextLhsAttr = lhs.nextSetBit(0); if (this.getFdOrGeneralization(lhs, rhs, nextLhsAttr, foundLhs)) return foundLhs; return null; }
Example 15
Source File: FDTreeElement.java From winter with Apache License 2.0 | 5 votes |
public int addFunctionalDependenciesInto(FunctionalDependencyResultReceiver resultReceiver, OpenBitSet lhs, ObjectArrayList<ColumnIdentifier> columnIdentifiers, List<PositionListIndex> plis) throws CouldNotReceiveResultException, ColumnNameMismatchException { int numFDs = 0; for (int rhs = this.rhsFds.nextSetBit(0); rhs >= 0; rhs = this.rhsFds.nextSetBit(rhs + 1)) { ColumnIdentifier[] columns = new ColumnIdentifier[(int) lhs.cardinality()]; int j = 0; for (int i = lhs.nextSetBit(0); i >= 0; i = lhs.nextSetBit(i + 1)) { int columnId = plis.get(i).getAttribute(); // Here we translate the column i back to the real column i before the sorting columns[j++] = columnIdentifiers.get(columnId); } ColumnCombination colCombination = new ColumnCombination(columns); int rhsId = plis.get(rhs).getAttribute(); // Here we translate the column rhs back to the real column rhs before the sorting FunctionalDependency fdResult = new FunctionalDependency(colCombination, columnIdentifiers.get(rhsId)); resultReceiver.receiveResult(fdResult); numFDs++; } if (this.getChildren() == null) return numFDs; for (int childAttr = 0; childAttr < this.numAttributes; childAttr++) { FDTreeElement element = this.getChildren()[childAttr]; if (element != null) { lhs.set(childAttr); numFDs += element.addFunctionalDependenciesInto(resultReceiver, lhs, columnIdentifiers, plis); lhs.clear(childAttr); } } return numFDs; }
Example 16
Source File: FDTreeElement.java From winter with Apache License 2.0 | 5 votes |
public void addFunctionalDependenciesInto(List<FunctionalDependency> functionalDependencies, OpenBitSet lhs, ObjectArrayList<ColumnIdentifier> columnIdentifiers, List<PositionListIndex> plis) { for (int rhs = this.rhsFds.nextSetBit(0); rhs >= 0; rhs = this.rhsFds.nextSetBit(rhs + 1)) { ColumnIdentifier[] columns = new ColumnIdentifier[(int) lhs.cardinality()]; int j = 0; for (int i = lhs.nextSetBit(0); i >= 0; i = lhs.nextSetBit(i + 1)) { int columnId = plis.get(i).getAttribute(); // Here we translate the column i back to the real column i before the sorting columns[j++] = columnIdentifiers.get(columnId); } ColumnCombination colCombination = new ColumnCombination(columns); int rhsId = plis.get(rhs).getAttribute(); // Here we translate the column rhs back to the real column rhs before the sorting FunctionalDependency fdResult = new FunctionalDependency(colCombination, columnIdentifiers.get(rhsId)); functionalDependencies.add(fdResult); } if (this.getChildren() == null) return; for (int childAttr = 0; childAttr < this.numAttributes; childAttr++) { FDTreeElement element = this.getChildren()[childAttr]; if (element != null) { lhs.set(childAttr); element.addFunctionalDependenciesInto(functionalDependencies, lhs, columnIdentifiers, plis); lhs.clear(childAttr); } } }
Example 17
Source File: FDTreeElement.java From winter with Apache License 2.0 | 5 votes |
protected void addOneSmallerGeneralizations(OpenBitSet currentLhs, int maxCurrentLhsAttribute, OpenBitSet rhs, FDTree tree) { for (int lhsAttribute = currentLhs.nextSetBit(0); lhsAttribute != maxCurrentLhsAttribute; lhsAttribute = currentLhs.nextSetBit(lhsAttribute + 1)) { currentLhs.clear(lhsAttribute); tree.addGeneralization(currentLhs, rhs); currentLhs.set(lhsAttribute); } }
Example 18
Source File: FDTreeElement.java From winter with Apache License 2.0 | 4 votes |
protected void maximizeNegativeRecursive(PositionListIndex currentPli, OpenBitSet currentLhs, int numAttributes, int[][] rhsPlis, FDTree invalidFds) { PositionListIndex[] childPlis = new PositionListIndex[numAttributes]; // Traverse the tree depth-first, left-first; generate plis for children and pass them over; store the child plis locally to reuse them for the checking afterwards if (this.children != null) { for (int attr = 0; attr < numAttributes; attr++) { if (this.children[attr] != null) { childPlis[attr] = currentPli.intersect(rhsPlis[attr]); currentLhs.set(attr); this.children[attr].maximizeNegativeRecursive(childPlis[attr], currentLhs, numAttributes, rhsPlis, invalidFds); currentLhs.clear(attr); } } } // On the way back, check all rhs-FDs that all their possible supersets are valid FDs; check with refines or, if available, with previously calculated plis // which supersets to consider: add all attributes A with A notIn lhs and A notequal rhs; // for newLhs->rhs check that no FdOrSpecialization exists, because it is invalid then; this check might be slower than the FD check on high levels but faster on low levels in particular in the root! this check is faster on the negative cover, because we look for a non-FD for (int rhs = this.rhsFds.nextSetBit(0); rhs >= 0; rhs = this.rhsFds.nextSetBit(rhs + 1)) { OpenBitSet extensions = currentLhs.clone(); extensions.flip(0, numAttributes); extensions.clear(rhs); for (int extensionAttr = extensions.nextSetBit(0); extensionAttr >= 0; extensionAttr = extensions.nextSetBit(extensionAttr + 1)) { currentLhs.set(extensionAttr); if (childPlis[extensionAttr] == null) childPlis[extensionAttr] = currentPli.intersect(rhsPlis[extensionAttr]); // If a superset is a non-FD, mark this as not rhsFD, add the superset as a new node, filterGeneralizations() of the new node, call maximizeNegative() on the new supersets node // if the superset node is in a right node of the tree, it will be checked anyways later; hence, only check supersets that are left or in the same tree path if (!childPlis[extensionAttr].refines(rhsPlis[rhs])) { this.rhsFds.clear(rhs); FDTreeElement newElement = invalidFds.addFunctionalDependency(currentLhs, rhs); //invalidFds.filterGeneralizations(currentLhs, rhs); // TODO: test effect newElement.maximizeNegativeRecursive(childPlis[extensionAttr], currentLhs, numAttributes, rhsPlis, invalidFds); } currentLhs.clear(extensionAttr); } } }
Example 19
Source File: FDTree.java From winter with Apache License 2.0 | 4 votes |
public void filterGeneralizations(OpenBitSet lhs, int rhs) { OpenBitSet currentLhs = new OpenBitSet(this.numAttributes); int nextLhsAttr = lhs.nextSetBit(0); this.filterGeneralizations(lhs, rhs, nextLhsAttr, currentLhs); }
Example 20
Source File: Validator.java From winter with Apache License 2.0 | 4 votes |
public ValidationResult call() throws Exception { ValidationResult result = new ValidationResult(); FDTreeElement element = this.elementLhsPair.getElement(); OpenBitSet lhs = this.elementLhsPair.getLhs(); OpenBitSet rhs = element.getFds(); int rhsSize = (int) rhs.cardinality(); if (rhsSize == 0) return result; result.validations = result.validations + rhsSize; if (Validator.this.level == 0) { // Check if rhs is unique for (int rhsAttr = rhs.nextSetBit(0); rhsAttr >= 0; rhsAttr = rhs.nextSetBit(rhsAttr + 1)) { if (!Validator.this.plis.get(rhsAttr).isConstant(Validator.this.numRecords)) { element.removeFd(rhsAttr); result.invalidFDs.add(new FD(lhs, rhsAttr)); } result.intersections++; } } else if (Validator.this.level == 1) { // Check if lhs from plis refines rhs int lhsAttribute = lhs.nextSetBit(0); for (int rhsAttr = rhs.nextSetBit(0); rhsAttr >= 0; rhsAttr = rhs.nextSetBit(rhsAttr + 1)) { if (!Validator.this.plis.get(lhsAttribute).refines(Validator.this.compressedRecords, rhsAttr)) { element.removeFd(rhsAttr); result.invalidFDs.add(new FD(lhs, rhsAttr)); } result.intersections++; } } else { // Check if lhs from plis plus remaining inverted plis refines rhs int firstLhsAttr = lhs.nextSetBit(0); lhs.clear(firstLhsAttr); OpenBitSet validRhs = Validator.this.plis.get(firstLhsAttr).refines(Validator.this.compressedRecords, lhs, rhs, result.comparisonSuggestions); lhs.set(firstLhsAttr); result.intersections++; rhs.andNot(validRhs); // Now contains all invalid FDs element.setFds(validRhs); // Sets the valid FDs in the FD tree for (int rhsAttr = rhs.nextSetBit(0); rhsAttr >= 0; rhsAttr = rhs.nextSetBit(rhsAttr + 1)) result.invalidFDs.add(new FD(lhs, rhsAttr)); } return result; }