|
42 | 42 | import org.apache.sysds.runtime.compress.CompressedMatrixBlock; |
43 | 43 | import org.apache.sysds.runtime.controlprogram.caching.LazyWriteBuffer.RPolicy; |
44 | 44 | import org.apache.sysds.runtime.controlprogram.federated.FederationMap; |
| 45 | +import org.apache.sysds.runtime.controlprogram.parfor.LocalTaskQueue; |
45 | 46 | import org.apache.sysds.runtime.controlprogram.parfor.util.IDSequence; |
46 | 47 | import org.apache.sysds.runtime.instructions.cp.Data; |
47 | 48 | import org.apache.sysds.runtime.instructions.fed.InitFEDInstruction; |
48 | 49 | import org.apache.sysds.runtime.instructions.gpu.context.GPUContext; |
49 | 50 | import org.apache.sysds.runtime.instructions.gpu.context.GPUObject; |
50 | 51 | import org.apache.sysds.runtime.instructions.spark.data.BroadcastObject; |
| 52 | +import org.apache.sysds.runtime.instructions.spark.data.IndexedMatrixValue; |
51 | 53 | import org.apache.sysds.runtime.instructions.spark.data.RDDObject; |
52 | 54 | import org.apache.sysds.runtime.io.FileFormatProperties; |
53 | 55 | import org.apache.sysds.runtime.io.IOUtilFunctions; |
@@ -210,13 +212,15 @@ public enum CacheStatus { |
210 | 212 | private boolean _requiresLocalWrite = false; //flag if local write for read obj |
211 | 213 | private boolean _isAcquireFromEmpty = false; //flag if read from status empty |
212 | 214 |
|
213 | | - //spark-specific handles |
| 215 | + //backend-specific handles |
214 | 216 | //note: we use the abstraction of LineageObjects for two reasons: (1) to keep track of cleanup |
215 | 217 | //for lazily evaluated RDDs, and (2) as abstraction for environments that do not necessarily have spark libraries available |
216 | 218 | private RDDObject _rddHandle = null; //RDD handle |
217 | 219 | private BroadcastObject<T> _bcHandle = null; //Broadcast handle |
218 | 220 | protected HashMap<GPUContext, GPUObject> _gpuObjects = null; //Per GPUContext object allocated on GPU |
219 | | - |
| 221 | + //TODO generalize for frames |
| 222 | + private LocalTaskQueue<IndexedMatrixValue> _streamHandle = null; |
| 223 | + |
220 | 224 | private LineageItem _lineage = null; |
221 | 225 |
|
222 | 226 | /** |
@@ -460,6 +464,10 @@ public BroadcastObject<T> getBroadcastHandle() { |
460 | 464 | public boolean hasBroadcastHandle() { |
461 | 465 | return _bcHandle != null && _bcHandle.hasBackReference(); |
462 | 466 | } |
| 467 | + |
| 468 | + public LocalTaskQueue<IndexedMatrixValue> getStreamHandle() { |
| 469 | + return _streamHandle; |
| 470 | + } |
463 | 471 |
|
464 | 472 | @SuppressWarnings({ "rawtypes", "unchecked" }) |
465 | 473 | public void setBroadcastHandle( BroadcastObject bc ) { |
@@ -490,6 +498,10 @@ public synchronized void setGPUObject(GPUContext gCtx, GPUObject gObj) { |
490 | 498 | public synchronized void removeGPUObject(GPUContext gCtx) { |
491 | 499 | _gpuObjects.remove(gCtx); |
492 | 500 | } |
| 501 | + |
| 502 | + public synchronized void setStreamHandle(LocalTaskQueue<IndexedMatrixValue> q) { |
| 503 | + _streamHandle = q; |
| 504 | + } |
493 | 505 |
|
494 | 506 | // ********************************************* |
495 | 507 | // *** *** |
@@ -580,6 +592,9 @@ && getRDDHandle() == null) ) { |
580 | 592 | //mark for initial local write despite read operation |
581 | 593 | _requiresLocalWrite = false; |
582 | 594 | } |
| 595 | + else if( getStreamHandle() != null ) { |
| 596 | + _data = readBlobFromStream( getStreamHandle() ); |
| 597 | + } |
583 | 598 | else if( getRDDHandle()==null || getRDDHandle().allowsShortCircuitRead() ) { |
584 | 599 | if( DMLScript.STATISTICS ) |
585 | 600 | CacheStatistics.incrementHDFSHits(); |
@@ -1099,6 +1114,9 @@ protected abstract T readBlobFromHDFS(String fname, long[] dims) |
1099 | 1114 | protected abstract T readBlobFromRDD(RDDObject rdd, MutableBoolean status) |
1100 | 1115 | throws IOException; |
1101 | 1116 |
|
| 1117 | + protected abstract T readBlobFromStream(LocalTaskQueue<IndexedMatrixValue> stream) |
| 1118 | + throws IOException; |
| 1119 | + |
1102 | 1120 | // Federated read |
1103 | 1121 | protected T readBlobFromFederated(FederationMap fedMap) throws IOException { |
1104 | 1122 | if( LOG.isDebugEnabled() ) //common if instructions keep federated outputs |
|
0 commit comments