andromache.hadoop.CassandraSplit.java Source code

Java tutorial

Introduction

Here is the source code for andromache.hadoop.CassandraSplit.java

Source

/*
 * Copyright 2013 Illarion Kovalchuk
 * <p/>
 * Licensed 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
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * 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 andromache.hadoop;

import org.apache.cassandra.hadoop.ColumnFamilySplit;
import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class CassandraSplit extends ColumnFamilySplit implements Writable {
    private String cf;

    /**
     * For deserialization in org.apache.hadoop.io.serializer.WritableSerialization$WritableDeserializer.deserialize()
     */
    public CassandraSplit() {
    }

    public CassandraSplit(String startToken, String endToken, String[] dataNodes, String cf) {
        super(startToken, endToken, dataNodes);
        this.cf = cf;
    }

    public String getCf() {
        return cf;
    }

    @Override
    public void write(DataOutput out) throws IOException {
        super.write(out);
        out.writeUTF(cf);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        super.readFields(in);
        this.cf = in.readUTF();
    }

    @Override
    public String toString() {
        return super.toString() + " cf = " + cf;
    }
}