All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.sysml.runtime.controlprogram.caching.CacheBlock Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
/*
 * 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.sysml.runtime.controlprogram.caching;

import org.apache.hadoop.io.Writable;
import org.apache.sysml.runtime.DMLRuntimeException;


/**
 * Interface for all blocks handled by lazy write buffer. This abstraction 
 * allows us to keep the buffer pool independent of matrix and frame blocks. 
 * 
 */
public interface CacheBlock extends Writable 
{

	public int getNumRows();

	public int getNumColumns();
	
	/**
	 * Get the in-memory size in bytes of the cache block.
	 * 
	 * @return in-memory size in bytes of cache block
	 */
	public long getInMemorySize();
	
	/**
	 * Get the exact serialized size in bytes of the cache block.
	 * 
	 * @return exact serialized size in bytes of cache block
	 */
	public long getExactSerializedSize();

	/**
	 * Indicates if the cache block is subject to shallow serialized,
	 * which is generally true if in-memory size and serialized size
	 * are almost identical allowing to avoid unnecessary deep serialize. 
	 * 
	 * @return true if shallow serialized
	 */
	public boolean isShallowSerialize();
	
	/**
	 * Free unnecessarily allocated empty block.
	 */
	public void compactEmptyBlock();
	
	/**
	 * Slice a sub block out of the current block and write into the given output block.
	 * This method returns the passed instance if not null.
	 * 
	 * @param rl row lower
	 * @param ru row upper
	 * @param cl column lower
	 * @param cu column upper
	 * @param block cache block
	 * @return sub-block of cache block
	 * @throws DMLRuntimeException if DMLRuntimeException occurs
	 */
	public CacheBlock sliceOperations(int rl, int ru, int cl, int cu, CacheBlock block) 
		throws DMLRuntimeException;
	
	/**
	 * Merge the given block into the current block. Both blocks needs to be of equal 
	 * dimensions and contain disjoint non-zero cells.
	 * 
	 * @param that cache block
	 * @param appendOnly ?
	 * @throws DMLRuntimeException if DMLRuntimeException occurs
	 */
	public void merge(CacheBlock that, boolean appendOnly) 
		throws DMLRuntimeException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy