/** * @param readType the {@link tachyon.client.ReadType} for this operation. Setting this will * override the TachyonStorageType. * @return the builder */ public Builder setReadType(ReadType readType) { mTachyonStorageType = readType.getTachyonStorageType(); return this; }
/** * Creates a new builder for {@link InStreamOptions}. * * @param conf a Tachyon configuration */ public Builder(TachyonConf conf) { ReadType defaultReadType = conf.getEnum(Constants.USER_FILE_READ_TYPE_DEFAULT, ReadType.class); mTachyonStorageType = defaultReadType.getTachyonStorageType(); }
/** * Return the {@code InStream} of this file based on the specified read type. If it has no block, * return an {@code EmptyBlockInStream}; if it has only one block, return a {@code BlockInStream} * of the block; otherwise return a {@code FileInStream}. * * @param readType the InStream's read type * @return the <code>InStream</code> * @throws IOException when an event that prevents the operation from completing is encountered */ public FileInStream getInStream(ReadType readType) throws IOException { if (readType == null) { throw new IOException("ReadType can not be null."); } if (!isCompleted()) { throw new IOException("The file " + this + " is not complete."); } if (isDirectory()) { throw new IOException("Cannot open a directory for reading."); } FileInfo info = getUnCachedFileStatus(); TachyonURI uri = new TachyonURI(info.getPath()); InStreamOptions.Builder optionsBuilder = new InStreamOptions.Builder(mTachyonConf); optionsBuilder.setTachyonStorageType(readType.getTachyonStorageType()); try { tachyon.client.file.TachyonFile newFile = mTFS.open(uri); return mTFS.getInStream(newFile, optionsBuilder.build()); } catch (TachyonException e) { throw new IOException(e); } }