// Path: src/main/java/com/spotify/hdfs2cass/crunch/thrift/ThriftRecord.java
// @Deprecated
// public class ThriftRecord implements Serializable {
//   public static PType<ThriftRecord> PTYPE = Avros.reflects(ThriftRecord.class);
// 
//   private ByteBuffer key;
//   private List<Mutation> values;
// 
//   public ThriftRecord() {
//   }
// 
//   /**
//    * A ThriftRecord consists of Cassandra row key and a collection of
//    * {@link org.apache.cassandra.thrift.Mutation}.
//    * Mutations are passed to {@link org.apache.cassandra.hadoop.BulkOutputFormat}
//    * and correspond to column insertions.
//    * Mutations can be in any order. One row can be split into multiple ThriftRecords, Cassandra
//    * will eventually handle this.
//    * Placing 5,000+ mutations in one causes A LOT of memory pressure and should be avoided.
//    *
//    * @param key Cassandra row (i.e. partition) key
//    * @param values List of columns belonging to this row
//    */
//   public ThriftRecord(final ByteBuffer key, final List<Mutation> values) {
//     this.key = key;
//     this.values = values;
//   }
// 
//   public ByteBuffer getKey() {
//     return key;
//   }
// 
//   public static ThriftRecord of(final ByteBuffer key, final Mutation... values) {
//     return of(key, Lists.newArrayList(values));
//   }
// 
// 
// 
//   /**
//    * @param key Cassandra row (i.e. partition) key
//    * @param values List of columns belonging to this row
//    * @return
//    */
//   public static ThriftRecord of(final ByteBuffer key, final List<Mutation> values) {
//     return new ThriftRecord(key, values);
//   }
// 
//   public Pair<ByteBuffer, Collection<Mutation>> asPair() {
//     Collection<Mutation> collection = values;
//     return Pair.of(key, collection);
//   }
// 
//   public List<Mutation> getValues() {
//     return values;
//   }
// 
//   public static class AsPair extends MapFn<ThriftRecord, Pair<ByteBuffer, Collection<Mutation>>> {
//     public static PTableType<ByteBuffer, Collection<Mutation>> PTYPE =
//         Avros.tableOf(Avros.bytes(), Avros.collections(Avros.records(Mutation.class)));
// 
//     @Override
//     public Pair<ByteBuffer, Collection<Mutation>> map(final ThriftRecord input) {
//       return input.asPair();
//     }
//   }
// 
//   @Override
//   public boolean equals(final Object o) {
//     if (this == o) return true;
//     if (o == null || getClass() != o.getClass()) return false;
// 
//     ThriftRecord that = (ThriftRecord) o;
// 
//     if (!key.equals(that.key)) return false;
//     if (!values.equals(that.values)) return false;
// 
//     return true;
//   }
// 
//   @Override
//   public int hashCode() {
//     int result = key.hashCode();
//     result = 31 * result + values.hashCode();
//     return result;
//   }
// 
//   @Override
//   public String toString() {
//     return "ThriftRecord{" + "key=" + key + ", values=" + values + '}';
//   }
// }


import com.spotify.hdfs2cass.crunch.thrift.ThriftRecord;
import org.apache.avro.specific.SpecificRecord;
import org.apache.crunch.PCollection;
/*
 * Copyright 2014 Spotify AB. All rights reserved.
 *
 * The contents of this file are 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
 *
 *     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 com.spotify.hdfs2cass.crunch.thrift.converters;


public final class Thrift {
  public static final String DEFAULT_ROWKEY_FIELD_NAME = "rowkey";
  public static final String DEFAULT_TTL_FIELD_NAME = "ttl";
  public static final String DEFAULT_TIMESTAMP_FIELD_NAME = "timestamp";

  private Thrift() {
  }

  public static <T extends SpecificRecord> PCollection<ThriftRecord> byConvention(final PCollection<T> collection) {
    return byFieldNames(collection, DEFAULT_ROWKEY_FIELD_NAME, DEFAULT_TTL_FIELD_NAME, DEFAULT_TIMESTAMP_FIELD_NAME);
  }

// Path: src/main/java/com/spotify/hdfs2cass/crunch/thrift/ThriftRecord.java
// @Deprecated
// public class ThriftRecord implements Serializable {
//   public static PType<ThriftRecord> PTYPE = Avros.reflects(ThriftRecord.class);
// 
//   private ByteBuffer key;
//   private List<Mutation> values;
// 
//   public ThriftRecord() {
//   }
// 
//   /**
//    * A ThriftRecord consists of Cassandra row key and a collection of
//    * {@link org.apache.cassandra.thrift.Mutation}.
//    * Mutations are passed to {@link org.apache.cassandra.hadoop.BulkOutputFormat}
//    * and correspond to column insertions.
//    * Mutations can be in any order. One row can be split into multiple ThriftRecords, Cassandra
//    * will eventually handle this.
//    * Placing 5,000+ mutations in one causes A LOT of memory pressure and should be avoided.
//    *
//    * @param key Cassandra row (i.e. partition) key
//    * @param values List of columns belonging to this row
//    */
//   public ThriftRecord(final ByteBuffer key, final List<Mutation> values) {
//     this.key = key;
//     this.values = values;
//   }
// 
//   public ByteBuffer getKey() {
//     return key;
//   }
// 
//   public static ThriftRecord of(final ByteBuffer key, final Mutation... values) {
//     return of(key, Lists.newArrayList(values));
//   }
// 
// 
// 
//   /**
//    * @param key Cassandra row (i.e. partition) key
//    * @param values List of columns belonging to this row
//    * @return
//    */
//   public static ThriftRecord of(final ByteBuffer key, final List<Mutation> values) {
//     return new ThriftRecord(key, values);
//   }
// 
//   public Pair<ByteBuffer, Collection<Mutation>> asPair() {
//     Collection<Mutation> collection = values;
//     return Pair.of(key, collection);
//   }
// 
//   public List<Mutation> getValues() {
//     return values;
//   }
// 
//   public static class AsPair extends MapFn<ThriftRecord, Pair<ByteBuffer, Collection<Mutation>>> {
//     public static PTableType<ByteBuffer, Collection<Mutation>> PTYPE =
//         Avros.tableOf(Avros.bytes(), Avros.collections(Avros.records(Mutation.class)));
// 
//     @Override
//     public Pair<ByteBuffer, Collection<Mutation>> map(final ThriftRecord input) {
//       return input.asPair();
//     }
//   }
// 
//   @Override
//   public boolean equals(final Object o) {
//     if (this == o) return true;
//     if (o == null || getClass() != o.getClass()) return false;
// 
//     ThriftRecord that = (ThriftRecord) o;
// 
//     if (!key.equals(that.key)) return false;
//     if (!values.equals(that.values)) return false;
// 
//     return true;
//   }
// 
//   @Override
//   public int hashCode() {
//     int result = key.hashCode();
//     result = 31 * result + values.hashCode();
//     return result;
//   }
// 
//   @Override
//   public String toString() {
//     return "ThriftRecord{" + "key=" + key + ", values=" + values + '}';
//   }
// }


// Path: src/main/java/com/spotify/hdfs2cass/crunch/thrift/converters/Thrift.java
import com.spotify.hdfs2cass.crunch.thrift.ThriftRecord;
import org.apache.avro.specific.SpecificRecord;
import org.apache.crunch.PCollection;

/*
 * Copyright 2014 Spotify AB. All rights reserved.
 *
 * The contents of this file are 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
 *
 *     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 com.spotify.hdfs2cass.crunch.thrift.converters;


public final class Thrift {
  public static final String DEFAULT_ROWKEY_FIELD_NAME = "rowkey";
  public static final String DEFAULT_TTL_FIELD_NAME = "ttl";
  public static final String DEFAULT_TIMESTAMP_FIELD_NAME = "timestamp";

  private Thrift() {
  }

  public static <T extends SpecificRecord> PCollection<ThriftRecord> byConvention(final PCollection<T> collection) {
    return byFieldNames(collection, DEFAULT_ROWKEY_FIELD_NAME, DEFAULT_TTL_FIELD_NAME, DEFAULT_TIMESTAMP_FIELD_NAME);
  }

  public static <T extends SpecificRecord> PCollection<ThriftRecord> byFieldNames(