Package org.apache.mahout.math.map

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) == false) {
          prevNode.put(parent, nextNode);
        } else {
          int prevNodeId = prevNode.get(parent);
          if (1 >= tree.childCount(prevNodeId)
              && 1 >= tree.childCount(nextNode)) {
            tree.addCount(prevNodeId, tree.count(nextNode));
            if (tree.childCount(nextNode) == 1) {
              tree.addChild(prevNodeId, tree.childAtIndex(nextNode, 0));
View Full Code Here


  }

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

  }

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

    protected void setup(Context ctx) throws IOException, InterruptedException {
      Configuration conf = ctx.getConfiguration();
      numVertices = Integer.parseInt(conf.get(NUM_VERTICES_PARAM));
      symmetric = conf.getBoolean(SYMMETRIC_PARAM, false);
      Path vertexIndexPath = new Path(conf.get(VERTEX_INDEX_PARAM));
      vertexIDsToIndex = new OpenIntIntHashMap(numVertices);
      for (Pair<IntWritable,IntWritable> indexAndVertexID :
          new SequenceFileIterable<IntWritable,IntWritable>(vertexIndexPath, true, conf)) {
        vertexIDsToIndex.put(indexAndVertexID.getSecond().get(), indexAndVertexID.getFirst().get());
      }
    }
View Full Code Here

    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)) {
          prevNode.put(parent, nextNode);
        } else {
          int prevNodeId = prevNode.get(parent);
          if (tree.childCount(prevNodeId) <= 1 && tree.childCount(nextNode) <= 1) {
            tree.addCount(prevNodeId, tree.count(nextNode));
            if (tree.childCount(nextNode) == 1) {
              tree.addChild(prevNodeId, tree.childAtIndex(nextNode, 0));
              tree.setParent(tree.childAtIndex(nextNode, 0), prevNodeId);
View Full Code Here

    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

    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

    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

  }

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

  }

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

TOP

Related Classes of org.apache.mahout.math.map.OpenIntIntHashMap

Copyright © 2018 www.massapicom. 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.