Examples of OpenIntIntHashMap


Examples of org.apache.mahout.math.map.OpenIntIntHashMap

    for (int i = 0; i < tree.getHeaderTableCount(); i++) {
      int currentAttribute = tree.getAttributeAtIndex(i);
      int nextNode = tree.getHeaderNext(currentAttribute);

      OpenIntIntHashMap prevNode = new OpenIntIntHashMap();
      int justPrevNode = -1;
      while (nextNode != -1) {

        int parent = tree.parent(nextNode);

        if (prevNode.containsKey(parent)) {
          int prevNodeId = prevNode.get(parent);
          if (tree.childCount(prevNodeId) <= 1 && tree.childCount(nextNode) <= 1) {
            tree.addCount(prevNodeId, tree.count(nextNode));
            tree.addCount(nextNode, -1 * tree.count(nextNode));
            if (tree.childCount(nextNode) == 1) {
              tree.addChild(prevNodeId, tree.childAtIndex(nextNode, 0));
              tree.setParent(tree.childAtIndex(nextNode, 0), prevNodeId);
            }
            tree.setNext(justPrevNode, tree.next(nextNode));
          }
        } else {
          prevNode.put(parent, nextNode);
        }
        justPrevNode = nextNode;
        nextNode = tree.next(nextNode);
      }
    }
View Full Code Here

Examples of org.apache.mahout.math.map.OpenIntIntHashMap

    boolean laxPrecision = (flags & VectorWritable.FLAG_LAX_PRECISION) != 0;
    Preconditions.checkState(!dense && !sequential, "Only for reading sparse vectors!");

    Varint.readUnsignedVarInt(in);

    OpenIntIntHashMap values = new OpenIntIntHashMap();
    int numNonDefaultElements = Varint.readUnsignedVarInt(in);
    for (int i = 0; i < numNonDefaultElements; i++) {
      int index = Varint.readUnsignedVarInt(in);
      double value = laxPrecision ? in.readFloat() : in.readDouble();
      values.put(index, (int) value);
    }
    return values;
  }
View Full Code Here

Examples of org.apache.mahout.math.map.OpenIntIntHashMap

    rowSimilarityJob.run(new String[] { "--input", inputFile.getAbsolutePath(), "--output", outputDir.getAbsolutePath(),
        "--numberOfColumns", String.valueOf(5), "--similarityClassname", TanimotoCoefficientSimilarity.class.getName(),
        "--tempDir", tmpDir.getAbsolutePath() });


    OpenIntIntHashMap observationsPerColumn =
        Vectors.readAsIntMap(new Path(tmpDir.getAbsolutePath(), "observationsPerColumn.bin"), conf);
    assertEquals(4, observationsPerColumn.size());
    assertEquals(1, observationsPerColumn.get(0));
    assertEquals(2, observationsPerColumn.get(2));
    assertEquals(2, observationsPerColumn.get(3));
    assertEquals(1, observationsPerColumn.get(4));

    Matrix similarityMatrix = MathHelper.readMatrix(conf, new Path(outputDir.getAbsolutePath(), "part-r-00000"), 3, 3);

    assertNotNull(similarityMatrix);
    assertEquals(3, similarityMatrix.numCols());
View Full Code Here

Examples of org.apache.mahout.math.map.OpenIntIntHashMap

    for (int i = 0; i < tree.getHeaderTableCount(); i++) {
      int currentAttribute = tree.getAttributeAtIndex(i);
      int nextNode = tree.getHeaderNext(currentAttribute);

      OpenIntIntHashMap prevNode = new OpenIntIntHashMap();
      int justPrevNode = -1;
      while (nextNode != -1) {

        int parent = tree.parent(nextNode);

        if (prevNode.containsKey(parent)) {
          int prevNodeId = prevNode.get(parent);
          if (tree.childCount(prevNodeId) <= 1 && tree.childCount(nextNode) <= 1) {
            tree.addCount(prevNodeId, tree.count(nextNode));
            tree.addCount(nextNode, -1 * tree.count(nextNode));
            if (tree.childCount(nextNode) == 1) {
              tree.addChild(prevNodeId, tree.childAtIndex(nextNode, 0));
              tree.setParent(tree.childAtIndex(nextNode, 0), prevNodeId);
            }
            tree.setNext(justPrevNode, tree.next(nextNode));
          }
        } else {
          prevNode.put(parent, nextNode);
        }
        justPrevNode = nextNode;
        nextNode = tree.next(nextNode);
      }
    }
View Full Code Here

Examples of org.apache.mahout.math.map.OpenIntIntHashMap

    boolean laxPrecision = (flags & VectorWritable.FLAG_LAX_PRECISION) != 0;
    Preconditions.checkState(!dense && !sequential, "Only for reading sparse vectors!");

    Varint.readUnsignedVarInt(in);

    OpenIntIntHashMap values = new OpenIntIntHashMap();
    int numNonDefaultElements = Varint.readUnsignedVarInt(in);
    for (int i = 0; i < numNonDefaultElements; i++) {
      int index = Varint.readUnsignedVarInt(in);
      double value = laxPrecision ? in.readFloat() : in.readDouble();
      values.put(index, (int) value);
    }
    return values;
  }
View Full Code Here

Examples of org.apache.mahout.math.map.OpenIntIntHashMap

public class MahoutMap extends MapImplementation<OpenIntIntHashMap>
{
    public MahoutMap()
    {
        super(new OpenIntIntHashMap(
            IntIntOpenHashMap.DEFAULT_CAPACITY,
            AbstractIntIntMap.DEFAULT_MIN_LOAD_FACTOR,
            IntIntOpenHashMap.DEFAULT_LOAD_FACTOR));
    }
View Full Code Here

Examples of org.apache.mahout.math.map.OpenIntIntHashMap

    public int get(int k) { return instance.get(k); }

    @Override
    public int containKeys(int [] keys)
    {
        final OpenIntIntHashMap prepared = this.instance;
        int count = 0;
        for (int i = 0; i < keys.length; i++)
            count += prepared.containsKey(keys[i]) ? 1 : 0;
        return count;
    }
View Full Code Here

Examples of org.apache.mahout.math.map.OpenIntIntHashMap

    }

    @Override
    public int putAll(int [] keys, int [] values)
    {
        final OpenIntIntHashMap instance = this.instance;
        int count = 0;
        for (int i = 0; i < keys.length; i++)
        {
            count += instance.put(keys[i], values[i]) ? 1 : 0;
        }
        return count;
    }
View Full Code Here

Examples of org.apache.mahout.math.map.OpenIntIntHashMap

  }

  private void initCaches() {
    this.caches = new OpenIntIntHashMap[getProbes()];
    for (int probe = 0; probe < getProbes(); probe++) {
      caches[probe] = new OpenIntIntHashMap();
    }
  }
View Full Code Here

Examples of org.apache.mahout.math.map.OpenIntIntHashMap

  }

  private void initCaches() {
    caches = new OpenIntIntHashMap[getProbes()];
    for (int probe = 0; probe < getProbes(); probe++) {
      caches[probe] = new OpenIntIntHashMap();
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.