Github user mateiz commented on a diff in the pull request:

    https://github.com/apache/spark/pull/158#discussion_r11224981
  
    --- Diff: core/src/main/scala/org/apache/spark/storage/TachyonStore.scala 
---
    @@ -0,0 +1,143 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.storage
    +
    +import java.io.IOException
    +import java.nio.ByteBuffer
    +
    +import scala.collection.mutable.ArrayBuffer
    +
    +import tachyon.client.{WriteType, ReadType}
    +
    +import org.apache.spark.Logging
    +import org.apache.spark.util.Utils
    +import org.apache.spark.serializer.Serializer
    +
    +
    +private class Entry(val size: Long)
    +
    +
    +/**
    + * Stores BlockManager blocks on Tachyon.
    + */
    +private class TachyonStore(
    +    blockManager: BlockManager,
    +    tachyonManager: TachyonBlockManager)
    +  extends BlockStore(blockManager: BlockManager) with Logging {
    +
    +  logInfo("TachyonStore started")
    +
    +  override def getSize(blockId: BlockId): Long = {
    +    tachyonManager.getFile(blockId.name).length
    +//    tachyonManager.getBlockLocation(blockId).length
    +  }
    +
    +  override def putBytes(blockId: BlockId, _bytes: ByteBuffer, level: 
StorageLevel): PutResult =  {
    +    putToTachyonStore(blockId, _bytes, true)
    +  }
    +
    +  override def putValues(
    +    blockId: BlockId,
    +    values: ArrayBuffer[Any],
    +    level: StorageLevel,
    +    returnValues: Boolean): PutResult = {
    +    return putValues(blockId, values.toIterator, level, returnValues)
    +  }
    +
    +  override def putValues(
    +    blockId: BlockId,
    +    values: Iterator[Any],
    +    level: StorageLevel,
    +    returnValues: Boolean): PutResult = {
    +    logDebug("Attempting to write values for block " + blockId)
    +    val _bytes = blockManager.dataSerialize(blockId, values)
    +    putToTachyonStore(blockId, _bytes, returnValues)
    +  }
    +
    +  private def putToTachyonStore(
    +    blockId: BlockId,
    +    _bytes: ByteBuffer,
    +    returnValues: Boolean): PutResult = {
    +    // So that we do not modify the input offsets !
    +    // duplicate does not copy buffer, so inexpensive
    +    val bytes = _bytes.duplicate()
    +    bytes.rewind()
    +    logDebug("Attempting to put block " + blockId + " into Tachyon")
    +    val startTime = System.currentTimeMillis
    +    val file = tachyonManager.getFile(blockId)
    +    val os = file.getOutStream(WriteType.TRY_CACHE)
    --- End diff --
    
    For this first version we just want recompilation in this case. In later 
versions, we'll make Tachyon itself support evicting data to disk, because 
there's no easy way Spark could know when to do that.
    
    I agree that we should not use the same filename from multiple nodes -- I 
thought this patch isn't doing that. But more generally we should probably not 
allow Tachyon mode to be on with StorageLevel.replication set, since this is 
again an option we can add in Tachyon itself.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to