/* * (non-Javadoc) * @see eu.stratosphere.pact.common.stubs.Stub#open(eu.stratosphere.nephele.configuration.Configuration) */ @Override public void open(final Configuration parameters) throws Exception { SopremoEnvironment.getInstance().setConfigurationAndContext(parameters, getRuntimeContext()); this.context = SopremoEnvironment.getInstance().getEvaluationContext(); this.collector = createCollector(SopremoEnvironment.getInstance().getLayout()); this.cachedIterator1 = new RecordToJsonIterator<LeftElem>(); this.cachedIterator2 = new RecordToJsonIterator<RightElem>(); SopremoUtil.configureWithTransferredState(this, GenericSopremoCoGroup.class, parameters); this.leftArray.setNodeIterator(this.cachedIterator1); this.rightArray.setNodeIterator(this.cachedIterator2); }
/* * (non-Javadoc) * @see eu.stratosphere.core.io.IOReadableWritable#read(java.io.DataInput) */ @Override public void read(final DataInput in) throws IOException { this.mode = ExecutionMode.values()[in.readInt()]; final ArrayList<String> requiredPackages = new ArrayList<String>(); for (int count = in.readInt(); count > 0; count--) requiredPackages.add(in.readUTF()); this.query = null; final byte[] planBuffer = new byte[in.readInt()]; in.readFully(planBuffer); final JobID dummId = new JobID(); try { LibraryCacheManager.register( dummId, requiredPackages.toArray(new String[requiredPackages.size()])); SopremoEnvironment.getInstance().setClassLoader(LibraryCacheManager.getClassLoader(dummId)); this.query = SopremoUtil.deserialize(planBuffer, SopremoPlan.class); } catch (final IOException e) { e.printStackTrace(); } finally { try { LibraryCacheManager.unregister(dummId); } catch (final IOException e) { } } }
public static Collection<IJsonNode> readFromFile(final File file, final SopremoFormat format) throws IOException { final Configuration config = new Configuration(); SopremoEnvironment.getInstance().save(config); SopremoUtil.transferFieldsToConfiguration( format, SopremoFormat.class, config, format.getInputFormat(), InputFormat.class); @SuppressWarnings("unchecked") final SopremoFileInputFormat inputFormat = FormatUtil.openInput( (Class<? extends SopremoFileInputFormat>) format.getInputFormat(), file.toURI().toString(), config); final List<IJsonNode> values = new ArrayList<IJsonNode>(); while (!inputFormat.reachedEnd()) { final SopremoRecord record = new SopremoRecord(); if (inputFormat.nextRecord(record)) values.add(record.getNode().clone()); } inputFormat.close(); return values; }