Java Code Examples for it.unimi.dsi.fastutil.ints.IntList#isEmpty()

The following examples show how to use it.unimi.dsi.fastutil.ints.IntList#isEmpty() . 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: FindCoversGenerator.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
private void doRecusiveCrap(int currentAttribute, IntList currentOrdering, List<DifferenceSet> setsNotCovered,
                            IntList currentPath, List<DifferenceSet> originalDiffSet, List<FunctionalDependencyGroup2> result)
        throws CouldNotReceiveResultException, ColumnNameMismatchException {

    // Basic Case
    // FIXME
    if (!currentOrdering.isEmpty() && /* BUT */setsNotCovered.isEmpty()) {
        if (this.debugSysout)
            System.out.println("no FDs here");
        return;
    }

    if (setsNotCovered.isEmpty()) {

        List<BitSet> subSets = this.generateSubSets(currentPath);
        if (this.noOneCovers(subSets, originalDiffSet)) {
            FunctionalDependencyGroup2 fdg = new FunctionalDependencyGroup2(currentAttribute, currentPath);
            this.addFdToReceivers(fdg);
            result.add(fdg);
        } else {
            if (this.debugSysout) {
                System.out.println("FD not minimal");
                System.out.println(new FunctionalDependencyGroup2(currentAttribute, currentPath));
            }
        }

        return;
    }

    // Recusive Case
    for (int i = 0; i < currentOrdering.size(); i++) {

        List<DifferenceSet> next = this.generateNextNotCovered(currentOrdering.getInt(i), setsNotCovered);
        IntList nextOrdering = this.generateNextOrdering(next, currentOrdering, currentOrdering.getInt(i));
        IntList currentPathCopy = new IntArrayList(currentPath);
        currentPathCopy.add(currentOrdering.getInt(i));
        this.doRecusiveCrap(currentAttribute, nextOrdering, next, currentPathCopy, originalDiffSet, result);
    }

}
 
Example 2
Source File: ChunkUpgrader.java    From multiconnect with MIT License 4 votes vote down vote up
public static UpgradeData fixChunk(WorldChunk chunk) {
    IntList centerIndicesToUpgrade = new IntArrayList();
    int sidesToUpgrade = 0;

    BlockPos.Mutable otherPos = new BlockPos.Mutable();
    for (BlockPos pos : BlockPos.iterate(chunk.getPos().getStartX(), 0, chunk.getPos().getStartZ(),
            chunk.getPos().getEndX(), chunk.getHighestNonEmptySectionYOffset() + 15, chunk.getPos().getEndZ())) {
        BlockState state = chunk.getBlockState(pos);
        Block block = state.getBlock();
        inPlaceFix(chunk, state, pos, otherPos);

        int blockId = Registry.BLOCK.getRawId(block) & 4095;
        if (ChunkPalettedStorageFixAccessor.getBlocksNeedingSideUpdate().get(blockId)) {
            boolean west = (pos.getX() & 15) == 0;
            boolean east = (pos.getX() & 15) == 15;
            boolean north = (pos.getZ() & 15) == 0;
            boolean south = (pos.getZ() & 15) == 15;
            if (north) {
                if (east) {
                    sidesToUpgrade |= 2;
                } else if (west) {
                    sidesToUpgrade |= 128;
                } else {
                    sidesToUpgrade |= 1;
                }
            } else if (south) {
                if (west) {
                    sidesToUpgrade |= 32;
                } else if (east) {
                    sidesToUpgrade |= 8;
                } else {
                    sidesToUpgrade |= 16;
                }
            } else if (east) {
                sidesToUpgrade |= 4;
            } else if (west) {
                sidesToUpgrade |= 64;
            } else {
                centerIndicesToUpgrade.add(pos.getY() << 8 | (pos.getZ() & 15) << 4 | (pos.getX() & 15));
            }
        }
    }

    if (centerIndicesToUpgrade.isEmpty() && sidesToUpgrade == 0)
        return null;

    CompoundTag upgradeData = new CompoundTag();
    upgradeData.putInt("Sides", sidesToUpgrade);
    CompoundTag centerIndices = new CompoundTag();
    centerIndicesToUpgrade.forEach((IntConsumer) index -> {
        int low = index & 4095;
        int high = index >>> 12;
        Tag tag = centerIndices.get(String.valueOf(high));
        if (tag == null)
            centerIndices.put(String.valueOf(high), tag = new ListTag());
        ((ListTag) tag).add(IntTag.of(low));
    });
    for (String key : centerIndices.getKeys()) {
        //noinspection ConstantConditions
        centerIndices.put(key, new IntArrayTag(((ListTag) centerIndices.get(key)).stream().mapToInt(val -> ((IntTag) val).getInt()).toArray()));
    }
    upgradeData.put("Indices", centerIndices);
    return new UpgradeData(upgradeData);
}
 
Example 3
Source File: AnchorTernaryTrieDump.java    From tagme with Apache License 2.0 4 votes vote down vote up
@Override
protected AnchorTernaryTrie parseSet() throws IOException
{
	
	File indexDir = RepositoryDirs.ANCHORS.getDir(lang);
	long indexSize = FileUtils.sizeOfDirectory(indexDir);
	long maxMemory = Runtime.getRuntime().maxMemory();
	
	IndexReader anchors;
	if (indexSize < maxMemory * 0.8){
		
		log.info("MaxMemory is enough, loading Anchor index...");
		anchors = IndexReader.open(new RAMDirectory(new SimpleFSDirectory(indexDir)), true);
		log.info("Anchor index loaded.");
		
	} else {
		log.info("Not enough memory ["+maxMemory/1000000+"Mb] to load Anchor index (about "+indexSize/1000000+"Mb)");
		anchors = Indexes.getReader(RepositoryDirs.ANCHORS.getPath(lang));
	}

	
	AnchorTernaryTrie trie = new AnchorTernaryTrie();
	
	int maxdoc = anchors.maxDoc();
	
	IntList doclist = new IntArrayList();
	for(int i=0;i<maxdoc;i++) doclist.add(i);
	Random rnd = new Random(System.currentTimeMillis());
	
	PLogger plog = new PLogger(log, Step.TEN_MINUTES, "anchors", "skipped", "duplicates");
	plog.setEnd(0, maxdoc);
	plog.start("Inserting in to trie...");
	while(!doclist.isEmpty())
	{
		int docID = doclist.removeInt(rnd.nextInt(doclist.size()));
		
		plog.update(0);
		Document doc = anchors.document(docID);
		if (doc == null){
			plog.update(1);
			continue;
		}
		
		String anchorText = doc.get(AnchorIndexer.FIELD_TEXT);
		String serial = doc.get(AnchorIndexer.FIELD_OBJECT);
		Anchor anchorObj = Anchor.deserialize(serial);
		
		if (anchorObj == null){
			plog.update(1);
			continue;
		}
		
		boolean added = trie.add(anchorText, anchorObj);
		
		if (!added) plog.update(2);
	}
	plog.stop();
	
	return trie;
}