Examples of VIntWritable


Examples of org.apache.hadoop.io.VIntWritable

                "^"+JOINS.replace(".","[.]")+".*$";
        Map<String,VIntWritable> mapping= Maps.newHashMap();

        Map<String,String> targets=that.getValByRegex(prefixRegex);
        for(String keyNumber:targets.keySet()) {
            VIntWritable i=new VIntWritable(Integer.parseInt(lastSegment(keyNumber)));
            for(String path:commaSplitter.split(targets.get(keyNumber)))
                mapping.put(path,i);
        }

        return mapping;
View Full Code Here

Examples of org.apache.hadoop.io.VIntWritable

    @Override
    protected void map(LongWritable key, T value, Context context) throws IOException, InterruptedException {
        FileSplit split=(FileSplit) context.getInputSplit();
        String thePath=split.getPath().toString();
        VIntWritable currentTag = determineTag(mapping,thePath);
        context.write(newTaggedKey(value,currentTag),currentTag);
    }
View Full Code Here

Examples of org.apache.hadoop.io.VIntWritable

        VIntWritable currentTag = determineTag(mapping,thePath);
        context.write(newTaggedKey(value,currentTag),currentTag);
    }

    static VIntWritable determineTag(Map<String,VIntWritable> mapping,String thePath) {
        VIntWritable currentTag=new VIntWritable(0);
        for(String aPrefix:mapping.keySet())
            if(thePath.startsWith(aPrefix))
                currentTag=mapping.get(aPrefix);

        return currentTag;
View Full Code Here

Examples of org.apache.hadoop.io.VIntWritable

 
  @Override
  public void readFields(DataInput in) throws IOException {
    representedAsList = in.readBoolean();
   
    VIntWritable vInt = new VIntWritable();
    VLongWritable vLong = new VLongWritable();
   
    if (representedAsList) {
      transactionSet = new ArrayList<Pair<List<Integer>,Long>>();
      vInt.readFields(in);
      int numTransactions = vInt.get();
      for (int i = 0; i < numTransactions; i++) {
        vLong.readFields(in);
        Long support = vLong.get();
       
        vInt.readFields(in);
        int length = vInt.get();
       
        Integer[] items = new Integer[length];
        for (int j = 0; j < length; j++) {
          vInt.readFields(in);
          items[j] = vInt.get();
        }
        Pair<List<Integer>,Long> transaction = new Pair<List<Integer>,Long>(Arrays.asList(items), support);
        transactionSet.add(transaction);
      }
    } else {
      vInt.readFields(in);
      nodes = vInt.get();
      attribute = new int[nodes];
      nodeCount = new long[nodes];
      childCount = new int[nodes];
      nodeChildren = new int[nodes][];
      for (int i = 0; i < nodes; i++) {
        vInt.readFields(in);
        attribute[i] = vInt.get();
        vLong.readFields(in);
        nodeCount[i] = vLong.get();
        vInt.readFields(in);
        childCount[i] = vInt.get();
        nodeChildren[i] = new int[childCount[i]];
        for (int j = 0, k = childCount[i]; j < k; j++) {
          vInt.readFields(in);
          nodeChildren[i][j] = vInt.get();
        }
      }
    }
  }
View Full Code Here

Examples of org.apache.hadoop.io.VIntWritable

  }
 
  @Override
  public void write(DataOutput out) throws IOException {
    out.writeBoolean(representedAsList);
    VIntWritable vInt = new VIntWritable();
    VLongWritable vLong = new VLongWritable();
    if (representedAsList) {
      vInt.set(transactionSet.size());
      vInt.write(out);
      for (int i = 0, j = transactionSet.size(); i < j; i++) {
        Pair<List<Integer>,Long> transaction = transactionSet.get(i);
       
        vLong.set(transaction.getSecond());
        vLong.write(out);
       
        vInt.set(transaction.getFirst().size());
        vInt.write(out);
       
        for (Integer item : transaction.getFirst()) {
          vInt.set(item);
          vInt.write(out);
        }
      }
    } else {
      vInt.set(nodes);
      vInt.write(out);
      for (int i = 0; i < nodes; i++) {
        vInt.set(attribute[i]);
        vInt.write(out);
        vLong.set(nodeCount[i]);
        vLong.write(out);
        vInt.set(childCount[i]);
        vInt.write(out);
        for (int j = 0, k = childCount[i]; j < k; j++) {
          vInt.set(nodeChildren[i][j]);
          vInt.write(out);
        }
      }
    }
  }
View Full Code Here

Examples of org.apache.hadoop.io.VIntWritable

                       Iterator<VIntWritable> itemIterator,
                       OutputCollector<VIntWritable,VIntWritable> output,
                       Reporter reporter) throws IOException {
      Collection<VIntWritable> itemSet = new HashSet<VIntWritable>();
      while (itemIterator.hasNext()) {
        itemSet.add(new VIntWritable(itemIterator.next().get()));
      }
     
      if (itemSet.size() <= 2) {
        reporter.incrCounter(User.TOO_FEW_ITEMS, 1);
        return;
View Full Code Here

Examples of org.apache.hadoop.io.VIntWritable

        int curKeyId = curTuple.getInt(0);
        if (curKeyId == 0) {
          TupleWritable cachedTuple = new TupleWritable(3);
          int simItem = curTuple.getInt(1);
          double score = curTuple.getDouble(2);
          cachedTuple.set(0, new VIntWritable(seenItem));
          cachedTuple.set(1, new VIntWritable(simItem));
          cachedTuple.set(2, new DoubleWritable(score));
          cachedSimilarItems.add(cachedTuple);
        } else {
          // Encountered tuple from the 'user' relation (ID=1), Do the JOIN
          int userId = curTuple.getInt(1);
View Full Code Here

Examples of org.apache.hadoop.io.VIntWritable

      }
      return;

    case DataType.INTEGER:
      out.writeByte(DataType.INTEGER);
      new VIntWritable((Integer)val).write(out);
      return;

    case DataType.LONG:
      out.writeByte(DataType.LONG);
      new VLongWritable((Long)val).write(out);
View Full Code Here

Examples of org.apache.hadoop.io.VIntWritable

      byte[] buffer = new byte[in.readInt()];
      in.readFully(buffer);
      return new String(buffer,UTF8);

    case DataType.INTEGER:
      VIntWritable vint = new VIntWritable();
      vint.readFields(in);
      return vint.get();

    case DataType.LONG:
      VLongWritable vlong = new VLongWritable();
      vlong.readFields(in);
      return vlong.get();
View Full Code Here

Examples of org.apache.hadoop.io.VIntWritable

      byte[] buffer = new byte[in.readInt()];
      in.readFully(buffer);
      return new String(buffer, UTF8);

    case DataType.INTEGER:
      VIntWritable vint = new VIntWritable();
      vint.readFields(in);
      return vint.get();

    case DataType.LONG:
      VLongWritable vlong = new VLongWritable();
      vlong.readFields(in);
      return vlong.get();
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.