public SequenceID getAndIncrement() { SequenceID val = new SequenceID(value); increment(); return val; }
public boolean equals(Object o) { if (o == this) return true; if (o instanceof SequenceID) { return 0 == this.compareTo((SequenceID) o); } return false; } }
public static SequenceID parseValue(String str) { String[] tok = str.split("\\."); byte[] digits = new byte[tok.length]; for (int i = tok.length; i >= 0; i--) { digits[tok.length - i] = Byte.parseByte(tok[i]); } return new SequenceID(digits); }
/** * @see stream.io.Source#read() */ @Override public Data read() throws Exception { synchronized (lock) { // log.debug("Queue contents: {}", queue); // nextItem will automagically be set in the "write" // method calls // log.debug("nextItem: {}", nextItem); while (!closed && nextItem == null) { lock.wait(); } if (closed && nextItem == null && this.queue.isEmpty()) return null; Data item = nextItem; log.debug("Returning item: {}", item); nextOut.increment(); log.debug("Next SequenceID is: {}", nextOut); nextItem = findNext(); return item; } }
/** * @see stream.io.Stream#read() */ public synchronized Data read() throws Exception { if (closed || (limit > 0 && count >= limit)) return null; Data datum = readNext(); if (datum == null) { log.debug("End-of-stream reached!"); return null; } if (this.id != null) datum.put(SOURCE_KEY, this.id); if (this.sequenceKey != null) { SequenceID next = this.seqId.getAndIncrement(); datum.put(sequenceKey, next); } if (prefix != null && !prefix.trim().isEmpty()) { Data prefixed = DataFactory.create(); for (String key : datum.keySet()) { prefixed.put(prefix + ":" + key, datum.get(key)); } datum = prefixed; } count++; return datum; }
public static SequenceID parseValue(String str) { String[] tok = str.split("\\."); byte[] digits = new byte[tok.length]; for (int i = tok.length; i >= 0; i--) { digits[tok.length - i] = Byte.parseByte(tok[i]); } return new SequenceID(digits); }
/** * @see stream.io.Source#read() */ @Override public Data read() throws Exception { synchronized (lock) { // log.debug("Queue contents: {}", queue); // nextItem will automagically be set in the "write" // method calls // log.debug("nextItem: {}", nextItem); while (!closed && nextItem == null) { lock.wait(); } if (closed && nextItem == null && this.queue.isEmpty()) return null; Data item = nextItem; log.debug("Returning item: {}", item); nextOut.increment(); log.debug("Next SequenceID is: {}", nextOut); nextItem = findNext(); return item; } }
/** * @see stream.io.Stream#read() */ public Data read() throws Exception { if (closed || (limit > 0 && count >= limit)) return null; Data datum = readNext(); if (datum == null) { log.debug("End-of-stream reached!"); return null; } if (this.id != null) datum.put("@stream", this.id); if (this.sequenceKey != null) { SequenceID next = this.seqId.getAndIncrement(); datum.put(sequenceKey, next); } if (prefix != null && !prefix.trim().isEmpty()) { Data prefixed = DataFactory.create(); for (String key : datum.keySet()) { prefixed.put(prefix + ":" + key, datum.get(key)); } datum = prefixed; } count++; return datum; }
public SequenceID getAndIncrement() { SequenceID val = new SequenceID(value); increment(); return val; }
public boolean equals(Object o) { if (o == this) return true; if (o instanceof SequenceID) { return 0 == this.compareTo((SequenceID) o); } return false; } }
public synchronized SequenceID nextValue() { return new SequenceID(value).increment(); }
private Data findNext() { log.debug("looking for next item with ID '{}'", nextOut); for (int i = 0; i < queue.size(); i++) { Data cur = queue.get(i); SequenceID id = (SequenceID) cur.get(sequenceKey); if (id.compareTo(nextOut) == 0) { nextItem = cur; queue.remove(i); return nextItem; } if (id.compareTo(nextOut) > 0) { break; } else { queue.remove(i); } } return null; }
public synchronized SequenceID nextValue() { return new SequenceID(value).increment(); }
private Data findNext() { log.debug("looking for next item with ID '{}'", nextOut); for (int i = 0; i < queue.size(); i++) { Data cur = queue.get(i); SequenceID id = (SequenceID) cur.get(sequenceKey); if (id.compareTo(nextOut) == 0) { nextItem = cur; queue.remove(i); return nextItem; } if (id.compareTo(nextOut) > 0) { break; } else { queue.remove(i); } } return null; }