Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  *
0009  *    http://www.apache.org/licenses/LICENSE-2.0
0010  *
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 package org.apache.spark.api.java;
0019 
0020 import org.apache.spark.storage.StorageLevel;
0021 
0022 /**
0023  * Expose some commonly useful storage level constants.
0024  */
0025 public class StorageLevels {
0026   public static final StorageLevel NONE = create(false, false, false, false, 1);
0027   public static final StorageLevel DISK_ONLY = create(true, false, false, false, 1);
0028   public static final StorageLevel DISK_ONLY_2 = create(true, false, false, false, 2);
0029   public static final StorageLevel MEMORY_ONLY = create(false, true, false, true, 1);
0030   public static final StorageLevel MEMORY_ONLY_2 = create(false, true, false, true, 2);
0031   public static final StorageLevel MEMORY_ONLY_SER = create(false, true, false, false, 1);
0032   public static final StorageLevel MEMORY_ONLY_SER_2 = create(false, true, false, false, 2);
0033   public static final StorageLevel MEMORY_AND_DISK = create(true, true, false, true, 1);
0034   public static final StorageLevel MEMORY_AND_DISK_2 = create(true, true, false, true, 2);
0035   public static final StorageLevel MEMORY_AND_DISK_SER = create(true, true, false, false, 1);
0036   public static final StorageLevel MEMORY_AND_DISK_SER_2 = create(true, true, false, false, 2);
0037   public static final StorageLevel OFF_HEAP = create(true, true, true, false, 1);
0038 
0039   /**
0040    * Create a new StorageLevel object.
0041    * @param useDisk saved to disk, if true
0042    * @param useMemory saved to on-heap memory, if true
0043    * @param useOffHeap saved to off-heap memory, if true
0044    * @param deserialized saved as deserialized objects, if true
0045    * @param replication replication factor
0046    */
0047   public static StorageLevel create(
0048     boolean useDisk,
0049     boolean useMemory,
0050     boolean useOffHeap,
0051     boolean deserialized,
0052     int replication) {
0053     return StorageLevel.apply(useDisk, useMemory, useOffHeap, deserialized, replication);
0054   }
0055 }