org.apache.cassandra.utils.memory.EnsureOnHeap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cassandra-all Show documentation
Show all versions of cassandra-all Show documentation
The Apache Cassandra Project develops a highly scalable second-generation distributed database, bringing together Dynamo's fully distributed design and Bigtable's ColumnFamily-based data model.
/*
*
* 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.cassandra.utils.memory;
import java.util.Iterator;
import org.apache.cassandra.db.BufferDecoratedKey;
import org.apache.cassandra.db.Clustering;
import org.apache.cassandra.db.DecoratedKey;
import org.apache.cassandra.db.DeletionInfo;
import org.apache.cassandra.db.rows.*;
import org.apache.cassandra.db.transform.Transformation;
import org.apache.cassandra.utils.SearchIterator;
public abstract class EnsureOnHeap extends Transformation
{
public abstract DecoratedKey applyToPartitionKey(DecoratedKey key);
public abstract UnfilteredRowIterator applyToPartition(UnfilteredRowIterator partition);
public abstract SearchIterator, Row> applyToPartition(SearchIterator, Row> partition);
public abstract Iterator applyToPartition(Iterator partition);
public abstract DeletionInfo applyToDeletionInfo(DeletionInfo deletionInfo);
public abstract Row applyToRow(Row row);
public abstract Row applyToStatic(Row row);
public abstract RangeTombstoneMarker applyToMarker(RangeTombstoneMarker marker);
static class CloneToHeap extends EnsureOnHeap
{
protected BaseRowIterator> applyToPartition(BaseRowIterator partition)
{
return partition instanceof UnfilteredRowIterator
? Transformation.apply((UnfilteredRowIterator) partition, this)
: Transformation.apply((RowIterator) partition, this);
}
public DecoratedKey applyToPartitionKey(DecoratedKey key)
{
return new BufferDecoratedKey(key.getToken(), HeapCloner.instance.clone(key.getKey()));
}
public Row applyToRow(Row row)
{
if (row == null)
return null;
return row.clone(HeapCloner.instance);
}
public Row applyToStatic(Row row)
{
if (row == Rows.EMPTY_STATIC_ROW)
return row;
return applyToRow(row);
}
public RangeTombstoneMarker applyToMarker(RangeTombstoneMarker marker)
{
return marker.clone(HeapCloner.instance);
}
public UnfilteredRowIterator applyToPartition(UnfilteredRowIterator partition)
{
return Transformation.apply(partition, this);
}
public SearchIterator, Row> applyToPartition(SearchIterator, Row> partition)
{
return new SearchIterator, Row>()
{
public Row next(Clustering> key)
{
return applyToRow(partition.next(key));
}
};
}
public Iterator applyToPartition(Iterator partition)
{
return new Iterator()
{
public boolean hasNext()
{
return partition.hasNext();
}
public Row next()
{
return applyToRow(partition.next());
}
public void remove()
{
partition.remove();
}
};
}
public DeletionInfo applyToDeletionInfo(DeletionInfo deletionInfo)
{
return deletionInfo.clone(HeapCloner.instance);
}
}
static class NoOp extends EnsureOnHeap
{
protected BaseRowIterator> applyToPartition(BaseRowIterator partition)
{
return partition;
}
public DecoratedKey applyToPartitionKey(DecoratedKey key)
{
return key;
}
public Row applyToRow(Row row)
{
return row;
}
public Row applyToStatic(Row row)
{
return row;
}
public RangeTombstoneMarker applyToMarker(RangeTombstoneMarker marker)
{
return marker;
}
public UnfilteredRowIterator applyToPartition(UnfilteredRowIterator partition)
{
return partition;
}
public SearchIterator, Row> applyToPartition(SearchIterator, Row> partition)
{
return partition;
}
public Iterator applyToPartition(Iterator partition)
{
return partition;
}
public DeletionInfo applyToDeletionInfo(DeletionInfo deletionInfo)
{
return deletionInfo;
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy