Java Code Examples for org.apache.commons.lang3.mutable.MutableLong#getValue()
The following examples show how to use
org.apache.commons.lang3.mutable.MutableLong#getValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractAppDataSnapshotServer.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
@Override public Result executeQuery(Query query, Void metaQuery, MutableLong queueContext) { return new DataResultSnapshot(query, currentData, queueContext.getValue()); }
Example 2
Source File: ParquetGroupScanStatistics.java From Bats with Apache License 2.0 | 4 votes |
public long getColumnValueCount(SchemaPath column) { MutableLong count = columnValueCounts.get(column); return count != null ? count.getValue() : 0; }
Example 3
Source File: KinesisDataFetcherTest.java From Flink-CEPplus with Apache License 2.0 | 4 votes |
@Test public void testPeriodicWatermark() { final MutableLong clock = new MutableLong(); final MutableBoolean isTemporaryIdle = new MutableBoolean(); final List<Watermark> watermarks = new ArrayList<>(); String fakeStream1 = "fakeStream1"; StreamShardHandle shardHandle = new StreamShardHandle( fakeStream1, new Shard().withShardId(KinesisShardIdGenerator.generateFromShardOrder(0))); TestSourceContext<String> sourceContext = new TestSourceContext<String>() { @Override public void emitWatermark(Watermark mark) { watermarks.add(mark); } @Override public void markAsTemporarilyIdle() { isTemporaryIdle.setTrue(); } }; HashMap<String, String> subscribedStreamsToLastSeenShardIdsUnderTest = new HashMap<>(); final KinesisDataFetcher<String> fetcher = new TestableKinesisDataFetcher<String>( Collections.singletonList(fakeStream1), sourceContext, new java.util.Properties(), new KinesisDeserializationSchemaWrapper<>(new org.apache.flink.streaming.util.serialization.SimpleStringSchema()), 1, 1, new AtomicReference<>(), new LinkedList<>(), subscribedStreamsToLastSeenShardIdsUnderTest, FakeKinesisBehavioursFactory.nonReshardedStreamsBehaviour(new HashMap<>())) { @Override protected long getCurrentTimeMillis() { return clock.getValue(); } }; Whitebox.setInternalState(fetcher, "periodicWatermarkAssigner", watermarkAssigner); SequenceNumber seq = new SequenceNumber("fakeSequenceNumber"); // register shards to subsequently emit records int shardIndex = fetcher.registerNewSubscribedShardState( new KinesisStreamShardState( KinesisDataFetcher.convertToStreamShardMetadata(shardHandle), shardHandle, seq)); StreamRecord<String> record1 = new StreamRecord<>(String.valueOf(Long.MIN_VALUE), Long.MIN_VALUE); fetcher.emitRecordAndUpdateState(record1.getValue(), record1.getTimestamp(), shardIndex, seq); Assert.assertEquals(record1, sourceContext.getCollectedOutputs().poll()); fetcher.emitWatermark(); Assert.assertTrue("potential watermark equals previous watermark", watermarks.isEmpty()); StreamRecord<String> record2 = new StreamRecord<>(String.valueOf(1), 1); fetcher.emitRecordAndUpdateState(record2.getValue(), record2.getTimestamp(), shardIndex, seq); Assert.assertEquals(record2, sourceContext.getCollectedOutputs().poll()); fetcher.emitWatermark(); Assert.assertFalse("watermark advanced", watermarks.isEmpty()); Assert.assertEquals(new Watermark(record2.getTimestamp()), watermarks.remove(0)); Assert.assertFalse("not idle", isTemporaryIdle.booleanValue()); // test idle timeout long idleTimeout = 10; // advance clock idleTimeout clock.add(idleTimeout + 1); fetcher.emitWatermark(); Assert.assertFalse("not idle", isTemporaryIdle.booleanValue()); Assert.assertTrue("not idle, no new watermark", watermarks.isEmpty()); // activate idle timeout Whitebox.setInternalState(fetcher, "shardIdleIntervalMillis", idleTimeout); fetcher.emitWatermark(); Assert.assertTrue("idle", isTemporaryIdle.booleanValue()); Assert.assertTrue("idle, no watermark", watermarks.isEmpty()); }
Example 4
Source File: KinesisDataFetcherTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testPeriodicWatermark() { final MutableLong clock = new MutableLong(); final MutableBoolean isTemporaryIdle = new MutableBoolean(); final List<Watermark> watermarks = new ArrayList<>(); String fakeStream1 = "fakeStream1"; StreamShardHandle shardHandle = new StreamShardHandle( fakeStream1, new Shard().withShardId(KinesisShardIdGenerator.generateFromShardOrder(0))); TestSourceContext<String> sourceContext = new TestSourceContext<String>() { @Override public void emitWatermark(Watermark mark) { watermarks.add(mark); } @Override public void markAsTemporarilyIdle() { isTemporaryIdle.setTrue(); } }; HashMap<String, String> subscribedStreamsToLastSeenShardIdsUnderTest = new HashMap<>(); final KinesisDataFetcher<String> fetcher = new TestableKinesisDataFetcher<String>( Collections.singletonList(fakeStream1), sourceContext, new java.util.Properties(), new KinesisDeserializationSchemaWrapper<>(new org.apache.flink.streaming.util.serialization.SimpleStringSchema()), 1, 1, new AtomicReference<>(), new LinkedList<>(), subscribedStreamsToLastSeenShardIdsUnderTest, FakeKinesisBehavioursFactory.nonReshardedStreamsBehaviour(new HashMap<>())) { @Override protected long getCurrentTimeMillis() { return clock.getValue(); } }; Whitebox.setInternalState(fetcher, "periodicWatermarkAssigner", watermarkAssigner); SequenceNumber seq = new SequenceNumber("fakeSequenceNumber"); // register shards to subsequently emit records int shardIndex = fetcher.registerNewSubscribedShardState( new KinesisStreamShardState( KinesisDataFetcher.convertToStreamShardMetadata(shardHandle), shardHandle, seq)); StreamRecord<String> record1 = new StreamRecord<>(String.valueOf(Long.MIN_VALUE), Long.MIN_VALUE); fetcher.emitRecordAndUpdateState(record1.getValue(), record1.getTimestamp(), shardIndex, seq); Assert.assertEquals(record1, sourceContext.getCollectedOutputs().poll()); fetcher.emitWatermark(); Assert.assertTrue("potential watermark equals previous watermark", watermarks.isEmpty()); StreamRecord<String> record2 = new StreamRecord<>(String.valueOf(1), 1); fetcher.emitRecordAndUpdateState(record2.getValue(), record2.getTimestamp(), shardIndex, seq); Assert.assertEquals(record2, sourceContext.getCollectedOutputs().poll()); fetcher.emitWatermark(); Assert.assertFalse("watermark advanced", watermarks.isEmpty()); Assert.assertEquals(new Watermark(record2.getTimestamp()), watermarks.remove(0)); Assert.assertFalse("not idle", isTemporaryIdle.booleanValue()); // test idle timeout long idleTimeout = 10; // advance clock idleTimeout clock.add(idleTimeout + 1); fetcher.emitWatermark(); Assert.assertFalse("not idle", isTemporaryIdle.booleanValue()); Assert.assertTrue("not idle, no new watermark", watermarks.isEmpty()); // activate idle timeout Whitebox.setInternalState(fetcher, "shardIdleIntervalMillis", idleTimeout); fetcher.emitWatermark(); Assert.assertTrue("idle", isTemporaryIdle.booleanValue()); Assert.assertTrue("idle, no watermark", watermarks.isEmpty()); }
Example 5
Source File: GlobalVisitStats.java From fasten with Apache License 2.0 | 4 votes |
public static Result reaches(final KnowledgeBase kb, final long startSig, final int maxRevs, final ProgressLogger pl) { final LongOpenHashSet result = new LongOpenHashSet(); final Object2ObjectOpenHashMap<String, IntOpenHashSet> product2Revs = new Object2ObjectOpenHashMap<>(); final MutableLong totRevs = new MutableLong(); // Visit queue final LongArrayFIFOQueue queue = new LongArrayFIFOQueue(); queue.enqueue(startSig); result.add(startSig); String p = kb.callGraphs.get(index(startSig)).product; IntOpenHashSet revs = new IntOpenHashSet(); revs.add(index(startSig)); product2Revs.put(p, revs); totRevs.increment(); pl.itemsName = "nodes"; pl.info = new Object() { @Override public String toString() { return "[nodes: " + result.size() + " products: " + product2Revs.size() + " revisions: " + totRevs.getValue() + "]"; } }; pl.start("Visiting reachable nodes..."); while (!queue.isEmpty()) { final long node = queue.dequeueLong(); for (final long s : kb.successors(node)) if (!result.contains(s)) { p = kb.callGraphs.get(index(s)).product; final long gid = gid(s); if (badGIDs.contains(gid)) continue; final String targetNameSpace = kb.new Node(gid, index(s)).toFastenURI().getRawNamespace(); if (targetNameSpace.startsWith("java.") || targetNameSpace.startsWith("javax.") || targetNameSpace.startsWith("jdk.")) { badGIDs.add(gid); continue; } revs = product2Revs.get(p); if (revs == null) product2Revs.put(p, revs = new IntOpenHashSet()); if (revs.contains(index(s)) || revs.size() < maxRevs) { queue.enqueue(s); result.add(s); //System.out.println(kb.new Node(gid(node), index(node)).toFastenURI() + " -> " + kb.new Node(gid(s), index(s)).toFastenURI()); if (revs.add(index(s))) totRevs.increment(); } } pl.lightUpdate(); } pl.done(); return new Result(result, product2Revs.size(), totRevs.getValue().longValue()); }
Example 6
Source File: GlobalVisitStats.java From fasten with Apache License 2.0 | 4 votes |
public static Result coreaches(final KnowledgeBase kb, final long startSig, final int maxRevs, final ProgressLogger pl) { final LongOpenHashSet result = new LongOpenHashSet(); final Object2ObjectOpenHashMap<String, IntOpenHashSet> product2Revs = new Object2ObjectOpenHashMap<>(); final MutableLong totRevs = new MutableLong(); // Visit queue final LongArrayFIFOQueue queue = new LongArrayFIFOQueue(); queue.enqueue(startSig); result.add(startSig); String p = kb.callGraphs.get(index(startSig)).product; IntOpenHashSet revs = new IntOpenHashSet(); revs.add(index(startSig)); product2Revs.put(p, revs); totRevs.increment(); pl.itemsName = "nodes"; pl.info = new Object() { @Override public String toString() { return "[nodes: " + result.size() + " products: " + product2Revs.size() + " revisions: " + totRevs.getValue() + "]"; } }; pl.start("Visiting coreachable nodes..."); while (!queue.isEmpty()) { final long node = queue.dequeueLong(); for (final long s : kb.predecessors(node)) if (!result.contains(s)) { p = kb.callGraphs.get(index(s)).product; final String targetNameSpace = kb.new Node(gid(s), index(s)).toFastenURI().getRawNamespace(); if (targetNameSpace.startsWith("java.") || targetNameSpace.startsWith("javax.") || targetNameSpace.startsWith("jdk.")) continue; revs = product2Revs.get(p); if (revs == null) product2Revs.put(p, revs = new IntOpenHashSet()); if (revs.contains(index(s)) || revs.size() < maxRevs) { queue.enqueue(s); result.add(s); //System.out.println(kb.new Node(gid(node), index(node)).toFastenURI() + " -> " + kb.new Node(gid(s), index(s)).toFastenURI()); if (revs.add(index(s))) totRevs.increment(); } } pl.lightUpdate(); } pl.done(); return new Result(result, product2Revs.size(), totRevs.getValue().longValue()); }
Example 7
Source File: Count.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
@Override public Long getOutput(MutableLong accumulatedValue) { return accumulatedValue.getValue(); }
Example 8
Source File: SumAccumulation.java From attic-apex-malhar with Apache License 2.0 | 4 votes |
@Override public Long getOutput(MutableLong accumulatedValue) { return accumulatedValue.getValue(); }
Example 9
Source File: KinesisDataFetcherTest.java From flink with Apache License 2.0 | 4 votes |
@Test public void testPeriodicWatermark() { final MutableLong clock = new MutableLong(); final MutableBoolean isTemporaryIdle = new MutableBoolean(); final List<Watermark> watermarks = new ArrayList<>(); String fakeStream1 = "fakeStream1"; StreamShardHandle shardHandle = new StreamShardHandle( fakeStream1, new Shard().withShardId(KinesisShardIdGenerator.generateFromShardOrder(0))); TestSourceContext<String> sourceContext = new TestSourceContext<String>() { @Override public void emitWatermark(Watermark mark) { watermarks.add(mark); } @Override public void markAsTemporarilyIdle() { isTemporaryIdle.setTrue(); } }; HashMap<String, String> subscribedStreamsToLastSeenShardIdsUnderTest = new HashMap<>(); final KinesisDataFetcher<String> fetcher = new TestableKinesisDataFetcher<String>( Collections.singletonList(fakeStream1), sourceContext, new java.util.Properties(), new KinesisDeserializationSchemaWrapper<>(new org.apache.flink.streaming.util.serialization.SimpleStringSchema()), 1, 1, new AtomicReference<>(), new LinkedList<>(), subscribedStreamsToLastSeenShardIdsUnderTest, FakeKinesisBehavioursFactory.nonReshardedStreamsBehaviour(new HashMap<>())) { @Override protected long getCurrentTimeMillis() { return clock.getValue(); } }; Whitebox.setInternalState(fetcher, "periodicWatermarkAssigner", watermarkAssigner); SequenceNumber seq = new SequenceNumber("fakeSequenceNumber"); // register shards to subsequently emit records int shardIndex = fetcher.registerNewSubscribedShardState( new KinesisStreamShardState( KinesisDataFetcher.convertToStreamShardMetadata(shardHandle), shardHandle, seq)); StreamRecord<String> record1 = new StreamRecord<>(String.valueOf(Long.MIN_VALUE), Long.MIN_VALUE); fetcher.emitRecordAndUpdateState(record1.getValue(), record1.getTimestamp(), shardIndex, seq); Assert.assertEquals(record1, sourceContext.getCollectedOutputs().poll()); fetcher.emitWatermark(); Assert.assertTrue("potential watermark equals previous watermark", watermarks.isEmpty()); StreamRecord<String> record2 = new StreamRecord<>(String.valueOf(1), 1); fetcher.emitRecordAndUpdateState(record2.getValue(), record2.getTimestamp(), shardIndex, seq); Assert.assertEquals(record2, sourceContext.getCollectedOutputs().poll()); fetcher.emitWatermark(); Assert.assertFalse("watermark advanced", watermarks.isEmpty()); Assert.assertEquals(new Watermark(record2.getTimestamp()), watermarks.remove(0)); Assert.assertFalse("not idle", isTemporaryIdle.booleanValue()); // test idle timeout long idleTimeout = 10; // advance clock idleTimeout clock.add(idleTimeout + 1); fetcher.emitWatermark(); Assert.assertFalse("not idle", isTemporaryIdle.booleanValue()); Assert.assertTrue("not idle, no new watermark", watermarks.isEmpty()); // activate idle timeout Whitebox.setInternalState(fetcher, "shardIdleIntervalMillis", idleTimeout); fetcher.emitWatermark(); Assert.assertTrue("idle", isTemporaryIdle.booleanValue()); Assert.assertTrue("idle, no watermark", watermarks.isEmpty()); }