Example usage for org.apache.hadoop.io IntWritable get

List of usage examples for org.apache.hadoop.io IntWritable get

Introduction

In this page you can find the example usage for org.apache.hadoop.io IntWritable get.

Prototype

public int get() 

Source Link

Document

Return the value of this IntWritable.

Usage

From source file:org.apache.giraph.types.IntWritableToLongUnwrapper.java

License:Apache License

@Override
public Long unwrap(IntWritable writableValue) {
    return (long) writableValue.get();
}

From source file:org.apache.giraph.types.ops.collections.array.WIntArrayList.java

License:Apache License

@Override
public void addW(IntWritable value) {
    add(value.get());
}

From source file:org.apache.giraph.types.ops.collections.array.WIntArrayList.java

License:Apache License

@Override
public void setW(int index, IntWritable value) {
    set(index, value.get());
}

From source file:org.apache.giraph.types.ops.collections.array.WIntArrayList.java

License:Apache License

@Override
public void fillW(int from, int to, IntWritable value) {
    if (to > size()) {
        throw new ArrayIndexOutOfBoundsException(
                "End index (" + to + ") is greater than array length (" + size() + ")");
    }//  w  w  w  . j  a  v  a2  s.com
    Arrays.fill(elements(), from, to, value.get());
}

From source file:org.apache.giraph.types.ops.IntTypeOps.java

License:Apache License

@Override
public IntWritable createCopy(IntWritable from) {
    return new IntWritable(from.get());
}

From source file:org.apache.giraph.types.ops.IntTypeOps.java

License:Apache License

@Override
public void set(IntWritable to, IntWritable from) {
    to.set(from.get());
}

From source file:org.apache.hama.bsp.Counters.java

License:Apache License

private static String getBlock(String str, char open, char close, IntWritable index) throws ParseException {
    StringBuilder split = new StringBuilder();
    int next = StringUtils.findNext(str, open, StringUtils.ESCAPE_CHAR, index.get(), split);
    split.setLength(0); // clear the buffer
    if (next >= 0) {
        ++next; // move over '('

        next = StringUtils.findNext(str, close, StringUtils.ESCAPE_CHAR, next, split);
        if (next >= 0) {
            ++next; // move over ')'
            index.set(next);//  w  w  w  .ja  v a2  s.c  om
            return split.toString(); // found a block
        } else {
            throw new ParseException("Unexpected end of block", next);
        }
    }
    return null; // found nothing
}

From source file:org.apache.hama.bsp.message.TestHadoopMessageManager.java

License:Apache License

private static void messagingInternal(Configuration conf) throws Exception {
    conf.set(MessageManagerFactory.MESSAGE_MANAGER_CLASS,
            "org.apache.hama.bsp.message.HadoopMessageManagerImpl");
    MessageManager<IntWritable> messageManager = MessageManagerFactory.getMessageManager(conf);

    assertTrue(messageManager instanceof HadoopMessageManagerImpl);

    InetSocketAddress peer = new InetSocketAddress(BSPNetUtils.getCanonicalHostname(),
            BSPNetUtils.getFreePort() + (increment++));
    BSPPeer<?, ?, ?, ?, IntWritable> dummyPeer = new BSPPeerImpl<NullWritable, NullWritable, NullWritable, NullWritable, IntWritable>(
            conf, FileSystem.get(conf), new Counters());
    TaskAttemptID id = new TaskAttemptID("1", 1, 1, 1);
    messageManager.init(id, dummyPeer, conf, peer);
    String peerName = peer.getHostName() + ":" + peer.getPort();

    messageManager.send(peerName, new IntWritable(1337));

    Iterator<Entry<InetSocketAddress, MessageQueue<IntWritable>>> messageIterator = messageManager
            .getMessageIterator();/*from  w  ww.  j a  v  a 2  s.c o m*/

    Entry<InetSocketAddress, MessageQueue<IntWritable>> entry = messageIterator.next();

    assertEquals(entry.getKey(), peer);

    assertTrue(entry.getValue().size() == 1);

    BSPMessageBundle<IntWritable> bundle = new BSPMessageBundle<IntWritable>();
    for (IntWritable msg : entry.getValue()) {
        bundle.addMessage(msg);
    }

    messageManager.transfer(peer, bundle);

    messageManager.clearOutgoingQueues();

    assertTrue(messageManager.getNumCurrentMessages() == 1);
    IntWritable currentMessage = messageManager.getCurrentMessage();

    assertEquals(currentMessage.get(), 1337);
    messageManager.close();
}

From source file:org.apache.hama.bsp.message.TestHamaAsyncMessageManager.java

License:Apache License

private static void messagingInternal(HamaConfiguration conf) throws Exception {
    conf.set(MessageManagerFactory.MESSAGE_MANAGER_CLASS,
            "org.apache.hama.bsp.message.HamaAsyncMessageManagerImpl");
    MessageManager<IntWritable> messageManager = MessageManagerFactory.getMessageManager(conf);

    assertTrue(messageManager instanceof HamaAsyncMessageManagerImpl);

    InetSocketAddress peer = new InetSocketAddress(BSPNetUtils.getCanonicalHostname(),
            BSPNetUtils.getFreePort() + (increment++));
    conf.set(Constants.PEER_HOST, Constants.DEFAULT_PEER_HOST);
    conf.setInt(Constants.PEER_PORT, Constants.DEFAULT_PEER_PORT);

    BSPPeer<?, ?, ?, ?, IntWritable> dummyPeer = new BSPPeerImpl<NullWritable, NullWritable, NullWritable, NullWritable, IntWritable>(
            conf, FileSystem.get(conf), new Counters());
    TaskAttemptID id = new TaskAttemptID("1", 1, 1, 1);
    messageManager.init(id, dummyPeer, conf, peer);
    peer = messageManager.getListenerAddress();
    String peerName = peer.getHostName() + ":" + peer.getPort();
    System.out.println("Peer is " + peerName);
    messageManager.send(peerName, new IntWritable(1337));

    Iterator<Entry<InetSocketAddress, BSPMessageBundle<IntWritable>>> messageIterator = messageManager
            .getOutgoingBundles();//from w ww .j a v a 2s  . co  m

    Entry<InetSocketAddress, BSPMessageBundle<IntWritable>> entry = messageIterator.next();

    assertEquals(entry.getKey(), peer);

    assertTrue(entry.getValue().size() == 1);

    BSPMessageBundle<IntWritable> bundle = new BSPMessageBundle<IntWritable>();
    Iterator<IntWritable> it = entry.getValue().iterator();
    while (it.hasNext()) {
        bundle.addMessage(it.next());
    }

    messageManager.transfer(peer, bundle);

    messageManager.clearOutgoingMessages();

    assertTrue(messageManager.getNumCurrentMessages() == 1);
    IntWritable currentMessage = messageManager.getCurrentMessage();

    assertEquals(currentMessage.get(), 1337);
    messageManager.close();
}

From source file:org.apache.hama.bsp.message.TestHamaMessageManager.java

License:Apache License

private static void messagingInternal(HamaConfiguration conf) throws Exception {
    conf.set(MessageManagerFactory.MESSAGE_MANAGER_CLASS, "org.apache.hama.bsp.message.HamaMessageManagerImpl");
    MessageManager<IntWritable> messageManager = MessageManagerFactory.getMessageManager(conf);

    assertTrue(messageManager instanceof HamaMessageManagerImpl);

    InetSocketAddress peer = new InetSocketAddress(BSPNetUtils.getCanonicalHostname(),
            BSPNetUtils.getFreePort() + (increment++));
    conf.set(Constants.PEER_HOST, Constants.DEFAULT_PEER_HOST);
    conf.setInt(Constants.PEER_PORT, Constants.DEFAULT_PEER_PORT);

    BSPPeer<?, ?, ?, ?, IntWritable> dummyPeer = new BSPPeerImpl<NullWritable, NullWritable, NullWritable, NullWritable, IntWritable>(
            conf, FileSystem.get(conf), new Counters());
    TaskAttemptID id = new TaskAttemptID("1", 1, 1, 1);
    messageManager.init(id, dummyPeer, conf, peer);
    peer = messageManager.getListenerAddress();
    String peerName = peer.getHostName() + ":" + peer.getPort();
    System.out.println("Peer is " + peerName);
    messageManager.send(peerName, new IntWritable(1337));

    Iterator<Entry<InetSocketAddress, BSPMessageBundle<IntWritable>>> messageIterator = messageManager
            .getOutgoingBundles();/* ww  w. j  a  v  a2  s.  com*/

    Entry<InetSocketAddress, BSPMessageBundle<IntWritable>> entry = messageIterator.next();

    assertEquals(entry.getKey(), peer);

    assertTrue(entry.getValue().size() == 1);

    BSPMessageBundle<IntWritable> bundle = new BSPMessageBundle<IntWritable>();
    Iterator<IntWritable> it = entry.getValue().iterator();
    while (it.hasNext()) {
        bundle.addMessage(it.next());
    }

    messageManager.transfer(peer, bundle);

    messageManager.clearOutgoingMessages();

    assertTrue(messageManager.getNumCurrentMessages() == 1);
    IntWritable currentMessage = messageManager.getCurrentMessage();

    assertEquals(currentMessage.get(), 1337);
    messageManager.close();
}