Java 类org.apache.hadoop.hbase.protobuf.generated.FilterProtos 实例源码

项目:ditb    文件:ProtobufUtil.java   
/**
 * Convert a protocol buffer Filter to a client Filter
 *
 * @param proto the protocol buffer Filter to convert
 * @return the converted Filter
 */
@SuppressWarnings("unchecked")
public static Filter toFilter(FilterProtos.Filter proto) throws IOException {
  String type = proto.getName();
  final byte [] value = proto.getSerializedFilter().toByteArray();
  String funcName = "parseFrom";
  try {
    Class<? extends Filter> c =
      (Class<? extends Filter>)Class.forName(type, true, CLASS_LOADER);
    Method parseFrom = c.getMethod(funcName, byte[].class);
    if (parseFrom == null) {
      throw new IOException("Unable to locate function: " + funcName + " in type: " + type);
    }
    return (Filter)parseFrom.invoke(c, value);
  } catch (Exception e) {
    // Either we couldn't instantiate the method object, or "parseFrom" failed.
    // In either case, let's not retry.
    throw new DoNotRetryIOException(e);
  }
}
项目:ditb    文件:FirstKeyValueMatchingQualifiersFilter.java   
/**
 * @param pbBytes A pb serialized {@link FirstKeyValueMatchingQualifiersFilter} instance
 * @return An instance of {@link FirstKeyValueMatchingQualifiersFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static FirstKeyValueMatchingQualifiersFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.FirstKeyValueMatchingQualifiersFilter proto;
  try {
    proto = FilterProtos.FirstKeyValueMatchingQualifiersFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }

  TreeSet<byte []> qualifiers = new TreeSet<byte []>(Bytes.BYTES_COMPARATOR);
  for (ByteString qualifier : proto.getQualifiersList()) {
    qualifiers.add(qualifier.toByteArray());
  }
  return new FirstKeyValueMatchingQualifiersFilter(qualifiers);
}
项目:ditb    文件:QualifierFilter.java   
/**
 * @param pbBytes A pb serialized {@link QualifierFilter} instance
 * @return An instance of {@link QualifierFilter} made from <code>bytes</code>
 * @throws org.apache.hadoop.hbase.exceptions.DeserializationException
 * @see #toByteArray
 */
public static QualifierFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.QualifierFilter proto;
  try {
    proto = FilterProtos.QualifierFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  final CompareOp valueCompareOp =
    CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
  ByteArrayComparable valueComparator = null;
  try {
    if (proto.getCompareFilter().hasComparator()) {
      valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
    }
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }
  return new QualifierFilter(valueCompareOp,valueComparator);
}
项目:ditb    文件:MultiRowRangeFilter.java   
/**
 * @return The filter serialized using pb
 */
public byte[] toByteArray() {
  FilterProtos.MultiRowRangeFilter.Builder builder = FilterProtos.MultiRowRangeFilter
      .newBuilder();
  for (RowRange range : rangeList) {
    if (range != null) {
      FilterProtos.RowRange.Builder rangebuilder = FilterProtos.RowRange.newBuilder();
      if (range.startRow != null)
        rangebuilder.setStartRow(ByteStringer.wrap(range.startRow));
      rangebuilder.setStartRowInclusive(range.startRowInclusive);
      if (range.stopRow != null)
        rangebuilder.setStopRow(ByteStringer.wrap(range.stopRow));
      rangebuilder.setStopRowInclusive(range.stopRowInclusive);
      range.isScan = Bytes.equals(range.startRow, range.stopRow) ? 1 : 0;
      builder.addRowRangeList(rangebuilder.build());
    }
  }
  return builder.build().toByteArray();
}
项目:ditb    文件:DependentColumnFilter.java   
/**
 * @param pbBytes A pb serialized {@link DependentColumnFilter} instance
 * @return An instance of {@link DependentColumnFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static DependentColumnFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.DependentColumnFilter proto;
  try {
    proto = FilterProtos.DependentColumnFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  final CompareOp valueCompareOp =
    CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
  ByteArrayComparable valueComparator = null;
  try {
    if (proto.getCompareFilter().hasComparator()) {
      valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
    }
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }
  return new DependentColumnFilter(
    proto.hasColumnFamily()?proto.getColumnFamily().toByteArray():null,
    proto.hasColumnQualifier()?proto.getColumnQualifier().toByteArray():null,
    proto.getDropDependentColumn(), valueCompareOp, valueComparator);
}
项目:ditb    文件:RowFilter.java   
/**
 * @param pbBytes A pb serialized {@link RowFilter} instance
 * @return An instance of {@link RowFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static RowFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.RowFilter proto;
  try {
    proto = FilterProtos.RowFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  final CompareOp valueCompareOp =
    CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
  ByteArrayComparable valueComparator = null;
  try {
    if (proto.getCompareFilter().hasComparator()) {
      valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
    }
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }
  return new RowFilter(valueCompareOp,valueComparator);
}
项目:ditb    文件:ValueFilter.java   
/**
 * @param pbBytes A pb serialized {@link ValueFilter} instance
 * @return An instance of {@link ValueFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static ValueFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.ValueFilter proto;
  try {
    proto = FilterProtos.ValueFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  final CompareOp valueCompareOp =
    CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
  ByteArrayComparable valueComparator = null;
  try {
    if (proto.getCompareFilter().hasComparator()) {
      valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
    }
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }
  return new ValueFilter(valueCompareOp,valueComparator);
}
项目:ditb    文件:FilterList.java   
/**
 * @param pbBytes A pb serialized {@link FilterList} instance
 * @return An instance of {@link FilterList} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static FilterList parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.FilterList proto;
  try {
    proto = FilterProtos.FilterList.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }

  List<Filter> rowFilters = new ArrayList<Filter>(proto.getFiltersCount());
  try {
    List<org.apache.hadoop.hbase.protobuf.generated.FilterProtos.Filter> filtersList =
        proto.getFiltersList();
    int listSize = filtersList.size();
    for (int i = 0; i < listSize; i++) {
      rowFilters.add(ProtobufUtil.toFilter(filtersList.get(i)));
    }
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }
  return new FilterList(Operator.valueOf(proto.getOperator().name()),rowFilters);
}
项目:ditb    文件:FuzzyRowFilter.java   
/**
 * @param pbBytes A pb serialized {@link FuzzyRowFilter} instance
 * @return An instance of {@link FuzzyRowFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static FuzzyRowFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
  FilterProtos.FuzzyRowFilter proto;
  try {
    proto = FilterProtos.FuzzyRowFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  int count = proto.getFuzzyKeysDataCount();
  ArrayList<Pair<byte[], byte[]>> fuzzyKeysData = new ArrayList<Pair<byte[], byte[]>>(count);
  for (int i = 0; i < count; ++i) {
    BytesBytesPair current = proto.getFuzzyKeysData(i);
    byte[] keyBytes = current.getFirst().toByteArray();
    byte[] keyMeta = current.getSecond().toByteArray();
    fuzzyKeysData.add(new Pair<byte[], byte[]>(keyBytes, keyMeta));
  }
  return new FuzzyRowFilter(fuzzyKeysData);
}
项目:ditb    文件:SingleColumnValueFilter.java   
FilterProtos.SingleColumnValueFilter convert() {
  FilterProtos.SingleColumnValueFilter.Builder builder =
    FilterProtos.SingleColumnValueFilter.newBuilder();
  if (this.columnFamily != null) {
    builder.setColumnFamily(ByteStringer.wrap(this.columnFamily));
  }
  if (this.columnQualifier != null) {
    builder.setColumnQualifier(ByteStringer.wrap(this.columnQualifier));
  }
  HBaseProtos.CompareType compareOp = CompareType.valueOf(this.compareOp.name());
  builder.setCompareOp(compareOp);
  builder.setComparator(ProtobufUtil.toComparator(this.comparator));
  builder.setFilterIfMissing(this.filterIfMissing);
  builder.setLatestVersionOnly(this.latestVersionOnly);

  return builder.build();
}
项目:ditb    文件:SingleColumnValueFilter.java   
/**
 * @param pbBytes A pb serialized {@link SingleColumnValueFilter} instance
 * @return An instance of {@link SingleColumnValueFilter} made from <code>bytes</code>
 * @throws org.apache.hadoop.hbase.exceptions.DeserializationException
 * @see #toByteArray
 */
public static SingleColumnValueFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.SingleColumnValueFilter proto;
  try {
    proto = FilterProtos.SingleColumnValueFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }

  final CompareOp compareOp =
    CompareOp.valueOf(proto.getCompareOp().name());
  final ByteArrayComparable comparator;
  try {
    comparator = ProtobufUtil.toComparator(proto.getComparator());
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }

  return new SingleColumnValueFilter(proto.hasColumnFamily() ? proto.getColumnFamily()
      .toByteArray() : null, proto.hasColumnQualifier() ? proto.getColumnQualifier()
      .toByteArray() : null, compareOp, comparator, proto.getFilterIfMissing(), proto
      .getLatestVersionOnly());
}
项目:ditb    文件:FamilyFilter.java   
/**
 * @param pbBytes A pb serialized {@link FamilyFilter} instance
 * @return An instance of {@link FamilyFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static FamilyFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.FamilyFilter proto;
  try {
    proto = FilterProtos.FamilyFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  final CompareOp valueCompareOp =
    CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
  ByteArrayComparable valueComparator = null;
  try {
    if (proto.getCompareFilter().hasComparator()) {
      valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
    }
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }
  return new FamilyFilter(valueCompareOp,valueComparator);
}
项目:ditb    文件:MultipleColumnPrefixFilter.java   
/**
 * @param pbBytes A pb serialized {@link MultipleColumnPrefixFilter} instance
 * @return An instance of {@link MultipleColumnPrefixFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static MultipleColumnPrefixFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.MultipleColumnPrefixFilter proto;
  try {
    proto = FilterProtos.MultipleColumnPrefixFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  int numPrefixes = proto.getSortedPrefixesCount();
  byte [][] prefixes = new byte[numPrefixes][];
  for (int i = 0; i < numPrefixes; ++i) {
    prefixes[i] = proto.getSortedPrefixes(i).toByteArray();
  }

  return new MultipleColumnPrefixFilter(prefixes);
}
项目:ditb    文件:SingleColumnValueExcludeFilter.java   
/**
 * @param pbBytes A pb serialized {@link SingleColumnValueExcludeFilter} instance
 * @return An instance of {@link SingleColumnValueExcludeFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static SingleColumnValueExcludeFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.SingleColumnValueExcludeFilter proto;
  try {
    proto = FilterProtos.SingleColumnValueExcludeFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }

  FilterProtos.SingleColumnValueFilter parentProto = proto.getSingleColumnValueFilter();
  final CompareOp compareOp =
    CompareOp.valueOf(parentProto.getCompareOp().name());
  final ByteArrayComparable comparator;
  try {
    comparator = ProtobufUtil.toComparator(parentProto.getComparator());
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }

  return new SingleColumnValueExcludeFilter(parentProto.hasColumnFamily() ? parentProto
      .getColumnFamily().toByteArray() : null, parentProto.hasColumnQualifier() ? parentProto
      .getColumnQualifier().toByteArray() : null, compareOp, comparator, parentProto
      .getFilterIfMissing(), parentProto.getLatestVersionOnly());
}
项目:HIndex    文件:FamilyFilter.java   
/**
 * @param pbBytes A pb serialized {@link FamilyFilter} instance
 * @return An instance of {@link FamilyFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static FamilyFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.FamilyFilter proto;
  try {
    proto = FilterProtos.FamilyFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  final CompareOp valueCompareOp =
    CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
  ByteArrayComparable valueComparator = null;
  try {
    if (proto.getCompareFilter().hasComparator()) {
      valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
    }
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }
  return new FamilyFilter(valueCompareOp,valueComparator);
}
项目:pbase    文件:ProtobufUtil.java   
/**
 * Convert a protocol buffer Filter to a client Filter
 *
 * @param proto the protocol buffer Filter to convert
 * @return the converted Filter
 */
@SuppressWarnings("unchecked")
public static Filter toFilter(FilterProtos.Filter proto) throws IOException {
  String type = proto.getName();
  final byte [] value = proto.getSerializedFilter().toByteArray();
  String funcName = "parseFrom";
  try {
    Class<? extends Filter> c =
      (Class<? extends Filter>)Class.forName(type, true, CLASS_LOADER);
    Method parseFrom = c.getMethod(funcName, byte[].class);
    if (parseFrom == null) {
      throw new IOException("Unable to locate function: " + funcName + " in type: " + type);
    }
    return (Filter)parseFrom.invoke(c, value);
  } catch (Exception e) {
    // Either we couldn't instantiate the method object, or "parseFrom" failed.
    // In either case, let's not retry.
    throw new DoNotRetryIOException(e);
  }
}
项目:pbase    文件:FirstKeyValueMatchingQualifiersFilter.java   
/**
 * @param pbBytes A pb serialized {@link FirstKeyValueMatchingQualifiersFilter} instance
 * @return An instance of {@link FirstKeyValueMatchingQualifiersFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static FirstKeyValueMatchingQualifiersFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.FirstKeyValueMatchingQualifiersFilter proto;
  try {
    proto = FilterProtos.FirstKeyValueMatchingQualifiersFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }

  TreeSet<byte []> qualifiers = new TreeSet<byte []>(Bytes.BYTES_COMPARATOR);
  for (ByteString qualifier : proto.getQualifiersList()) {
    qualifiers.add(qualifier.toByteArray());
  }
  return new FirstKeyValueMatchingQualifiersFilter(qualifiers);
}
项目:pbase    文件:QualifierFilter.java   
/**
 * @param pbBytes A pb serialized {@link QualifierFilter} instance
 * @return An instance of {@link QualifierFilter} made from <code>bytes</code>
 * @throws org.apache.hadoop.hbase.exceptions.DeserializationException
 * @see #toByteArray
 */
public static QualifierFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.QualifierFilter proto;
  try {
    proto = FilterProtos.QualifierFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  final CompareOp valueCompareOp =
    CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
  ByteArrayComparable valueComparator = null;
  try {
    if (proto.getCompareFilter().hasComparator()) {
      valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
    }
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }
  return new QualifierFilter(valueCompareOp,valueComparator);
}
项目:pbase    文件:DependentColumnFilter.java   
/**
 * @param pbBytes A pb serialized {@link DependentColumnFilter} instance
 * @return An instance of {@link DependentColumnFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static DependentColumnFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.DependentColumnFilter proto;
  try {
    proto = FilterProtos.DependentColumnFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  final CompareOp valueCompareOp =
    CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
  ByteArrayComparable valueComparator = null;
  try {
    if (proto.getCompareFilter().hasComparator()) {
      valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
    }
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }
  return new DependentColumnFilter(
    proto.hasColumnFamily()?proto.getColumnFamily().toByteArray():null,
    proto.hasColumnQualifier()?proto.getColumnQualifier().toByteArray():null,
    proto.getDropDependentColumn(), valueCompareOp, valueComparator);
}
项目:pbase    文件:RowFilter.java   
/**
 * @param pbBytes A pb serialized {@link RowFilter} instance
 * @return An instance of {@link RowFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static RowFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.RowFilter proto;
  try {
    proto = FilterProtos.RowFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  final CompareOp valueCompareOp =
    CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
  ByteArrayComparable valueComparator = null;
  try {
    if (proto.getCompareFilter().hasComparator()) {
      valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
    }
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }
  return new RowFilter(valueCompareOp,valueComparator);
}
项目:HIndex    文件:SingleColumnValueExcludeFilter.java   
/**
 * @param pbBytes A pb serialized {@link SingleColumnValueExcludeFilter} instance
 * @return An instance of {@link SingleColumnValueExcludeFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static SingleColumnValueExcludeFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.SingleColumnValueExcludeFilter proto;
  try {
    proto = FilterProtos.SingleColumnValueExcludeFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }

  FilterProtos.SingleColumnValueFilter parentProto = proto.getSingleColumnValueFilter();
  final CompareOp compareOp =
    CompareOp.valueOf(parentProto.getCompareOp().name());
  final ByteArrayComparable comparator;
  try {
    comparator = ProtobufUtil.toComparator(parentProto.getComparator());
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }

  return new SingleColumnValueExcludeFilter(parentProto.hasColumnFamily() ? parentProto
      .getColumnFamily().toByteArray() : null, parentProto.hasColumnQualifier() ? parentProto
      .getColumnQualifier().toByteArray() : null, compareOp, comparator, parentProto
      .getFilterIfMissing(), parentProto.getLatestVersionOnly());
}
项目:HIndex    文件:MultipleColumnPrefixFilter.java   
/**
 * @param pbBytes A pb serialized {@link MultipleColumnPrefixFilter} instance
 * @return An instance of {@link MultipleColumnPrefixFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static MultipleColumnPrefixFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.MultipleColumnPrefixFilter proto;
  try {
    proto = FilterProtos.MultipleColumnPrefixFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  int numPrefixes = proto.getSortedPrefixesCount();
  byte [][] prefixes = new byte[numPrefixes][];
  for (int i = 0; i < numPrefixes; ++i) {
    prefixes[i] = proto.getSortedPrefixes(i).toByteArray();
  }

  return new MultipleColumnPrefixFilter(prefixes);
}
项目:HIndex    文件:SingleColumnValueFilter.java   
public FilterProtos.SingleColumnValueFilter convert() {
  FilterProtos.SingleColumnValueFilter.Builder builder =
    FilterProtos.SingleColumnValueFilter.newBuilder();
  if (this.columnFamily != null) {
    builder.setColumnFamily(HBaseZeroCopyByteString.wrap(this.columnFamily));
  }
  if (this.columnQualifier != null) {
    builder.setColumnQualifier(HBaseZeroCopyByteString.wrap(this.columnQualifier));
  }
  HBaseProtos.CompareType compareOp = CompareType.valueOf(this.compareOp.name());
  builder.setCompareOp(compareOp);
  builder.setComparator(ProtobufUtil.toComparator(this.comparator));
  builder.setFilterIfMissing(this.filterIfMissing);
  builder.setLatestVersionOnly(this.latestVersionOnly);

  return builder.build();
}
项目:pbase    文件:FuzzyRowFilter.java   
/**
 * @param pbBytes A pb serialized {@link FuzzyRowFilter} instance
 * @return An instance of {@link FuzzyRowFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static FuzzyRowFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.FuzzyRowFilter proto;
  try {
    proto = FilterProtos.FuzzyRowFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  int count = proto.getFuzzyKeysDataCount();
  ArrayList<Pair<byte[], byte[]>> fuzzyKeysData= new ArrayList<Pair<byte[], byte[]>>(count);
  for (int i = 0; i < count; ++i) {
    BytesBytesPair current = proto.getFuzzyKeysData(i);
    byte[] keyBytes = current.getFirst().toByteArray();
    byte[] keyMeta = current.getSecond().toByteArray();
    fuzzyKeysData.add(new Pair<byte[], byte[]>(keyBytes, keyMeta));
  }
  return new FuzzyRowFilter(fuzzyKeysData);
}
项目:pbase    文件:SingleColumnValueFilter.java   
FilterProtos.SingleColumnValueFilter convert() {
  FilterProtos.SingleColumnValueFilter.Builder builder =
    FilterProtos.SingleColumnValueFilter.newBuilder();
  if (this.columnFamily != null) {
    builder.setColumnFamily(ByteStringer.wrap(this.columnFamily));
  }
  if (this.columnQualifier != null) {
    builder.setColumnQualifier(ByteStringer.wrap(this.columnQualifier));
  }
  HBaseProtos.CompareType compareOp = CompareType.valueOf(this.compareOp.name());
  builder.setCompareOp(compareOp);
  builder.setComparator(ProtobufUtil.toComparator(this.comparator));
  builder.setFilterIfMissing(this.filterIfMissing);
  builder.setLatestVersionOnly(this.latestVersionOnly);

  return builder.build();
}
项目:pbase    文件:SingleColumnValueFilter.java   
/**
 * @param pbBytes A pb serialized {@link SingleColumnValueFilter} instance
 * @return An instance of {@link SingleColumnValueFilter} made from <code>bytes</code>
 * @throws org.apache.hadoop.hbase.exceptions.DeserializationException
 * @see #toByteArray
 */
public static SingleColumnValueFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.SingleColumnValueFilter proto;
  try {
    proto = FilterProtos.SingleColumnValueFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }

  final CompareOp compareOp =
    CompareOp.valueOf(proto.getCompareOp().name());
  final ByteArrayComparable comparator;
  try {
    comparator = ProtobufUtil.toComparator(proto.getComparator());
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }

  return new SingleColumnValueFilter(proto.hasColumnFamily() ? proto.getColumnFamily()
      .toByteArray() : null, proto.hasColumnQualifier() ? proto.getColumnQualifier()
      .toByteArray() : null, compareOp, comparator, proto.getFilterIfMissing(), proto
      .getLatestVersionOnly());
}
项目:pbase    文件:FamilyFilter.java   
/**
 * @param pbBytes A pb serialized {@link FamilyFilter} instance
 * @return An instance of {@link FamilyFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static FamilyFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.FamilyFilter proto;
  try {
    proto = FilterProtos.FamilyFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  final CompareOp valueCompareOp =
    CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
  ByteArrayComparable valueComparator = null;
  try {
    if (proto.getCompareFilter().hasComparator()) {
      valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
    }
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }
  return new FamilyFilter(valueCompareOp,valueComparator);
}
项目:pbase    文件:MultipleColumnPrefixFilter.java   
/**
 * @param pbBytes A pb serialized {@link MultipleColumnPrefixFilter} instance
 * @return An instance of {@link MultipleColumnPrefixFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static MultipleColumnPrefixFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.MultipleColumnPrefixFilter proto;
  try {
    proto = FilterProtos.MultipleColumnPrefixFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  int numPrefixes = proto.getSortedPrefixesCount();
  byte [][] prefixes = new byte[numPrefixes][];
  for (int i = 0; i < numPrefixes; ++i) {
    prefixes[i] = proto.getSortedPrefixes(i).toByteArray();
  }

  return new MultipleColumnPrefixFilter(prefixes);
}
项目:pbase    文件:SingleColumnValueExcludeFilter.java   
/**
 * @param pbBytes A pb serialized {@link SingleColumnValueExcludeFilter} instance
 * @return An instance of {@link SingleColumnValueExcludeFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static SingleColumnValueExcludeFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.SingleColumnValueExcludeFilter proto;
  try {
    proto = FilterProtos.SingleColumnValueExcludeFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }

  FilterProtos.SingleColumnValueFilter parentProto = proto.getSingleColumnValueFilter();
  final CompareOp compareOp =
    CompareOp.valueOf(parentProto.getCompareOp().name());
  final ByteArrayComparable comparator;
  try {
    comparator = ProtobufUtil.toComparator(parentProto.getComparator());
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }

  return new SingleColumnValueExcludeFilter(parentProto.hasColumnFamily() ? parentProto
      .getColumnFamily().toByteArray() : null, parentProto.hasColumnQualifier() ? parentProto
      .getColumnQualifier().toByteArray() : null, compareOp, comparator, parentProto
      .getFilterIfMissing(), parentProto.getLatestVersionOnly());
}
项目:HIndex    文件:ProtobufUtil.java   
/**
 * Convert a protocol buffer Filter to a client Filter
 *
 * @param proto the protocol buffer Filter to convert
 * @return the converted Filter
 */
@SuppressWarnings("unchecked")
public static Filter toFilter(FilterProtos.Filter proto) throws IOException {
  String type = proto.getName();
  final byte [] value = proto.getSerializedFilter().toByteArray();
  String funcName = "parseFrom";
  try {
    Class<? extends Filter> c =
      (Class<? extends Filter>)Class.forName(type, true, CLASS_LOADER);
    Method parseFrom = c.getMethod(funcName, byte[].class);
    if (parseFrom == null) {
      throw new IOException("Unable to locate function: " + funcName + " in type: " + type);
    }
    return (Filter)parseFrom.invoke(c, value);
  } catch (Exception e) {
    throw new IOException(e);
  }
}
项目:HIndex    文件:QualifierFilter.java   
/**
 * @param pbBytes A pb serialized {@link QualifierFilter} instance
 * @return An instance of {@link QualifierFilter} made from <code>bytes</code>
 * @throws org.apache.hadoop.hbase.exceptions.DeserializationException
 * @see #toByteArray
 */
public static QualifierFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.QualifierFilter proto;
  try {
    proto = FilterProtos.QualifierFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  final CompareOp valueCompareOp =
    CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
  ByteArrayComparable valueComparator = null;
  try {
    if (proto.getCompareFilter().hasComparator()) {
      valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
    }
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }
  return new QualifierFilter(valueCompareOp,valueComparator);
}
项目:HIndex    文件:DependentColumnFilter.java   
/**
 * @param pbBytes A pb serialized {@link DependentColumnFilter} instance
 * @return An instance of {@link DependentColumnFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static DependentColumnFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.DependentColumnFilter proto;
  try {
    proto = FilterProtos.DependentColumnFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  final CompareOp valueCompareOp =
    CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
  ByteArrayComparable valueComparator = null;
  try {
    if (proto.getCompareFilter().hasComparator()) {
      valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
    }
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }
  return new DependentColumnFilter(
    proto.hasColumnFamily()?proto.getColumnFamily().toByteArray():null,
    proto.hasColumnQualifier()?proto.getColumnQualifier().toByteArray():null,
    proto.getDropDependentColumn(), valueCompareOp, valueComparator);
}
项目:HIndex    文件:RowFilter.java   
/**
 * @param pbBytes A pb serialized {@link RowFilter} instance
 * @return An instance of {@link RowFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static RowFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.RowFilter proto;
  try {
    proto = FilterProtos.RowFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  final CompareOp valueCompareOp =
    CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
  ByteArrayComparable valueComparator = null;
  try {
    if (proto.getCompareFilter().hasComparator()) {
      valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
    }
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }
  return new RowFilter(valueCompareOp,valueComparator);
}
项目:HIndex    文件:ValueFilter.java   
/**
 * @param pbBytes A pb serialized {@link ValueFilter} instance
 * @return An instance of {@link ValueFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static ValueFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.ValueFilter proto;
  try {
    proto = FilterProtos.ValueFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  final CompareOp valueCompareOp =
    CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
  ByteArrayComparable valueComparator = null;
  try {
    if (proto.getCompareFilter().hasComparator()) {
      valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
    }
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }
  return new ValueFilter(valueCompareOp,valueComparator);
}
项目:HIndex    文件:FilterList.java   
/**
 * @param pbBytes A pb serialized {@link FilterList} instance
 * @return An instance of {@link FilterList} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static FilterList parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.FilterList proto;
  try {
    proto = FilterProtos.FilterList.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }

  List<Filter> rowFilters = new ArrayList<Filter>(proto.getFiltersCount());
  try {
    for (FilterProtos.Filter filter : proto.getFiltersList()) {
      rowFilters.add(ProtobufUtil.toFilter(filter));
    }
  } catch (IOException ioe) {
    throw new DeserializationException(ioe);
  }
  return new FilterList(Operator.valueOf(proto.getOperator().name()),rowFilters);
}
项目:HIndex    文件:FuzzyRowFilter.java   
/**
 * @param pbBytes A pb serialized {@link FuzzyRowFilter} instance
 * @return An instance of {@link FuzzyRowFilter} made from <code>bytes</code>
 * @throws DeserializationException
 * @see #toByteArray
 */
public static FuzzyRowFilter parseFrom(final byte [] pbBytes)
throws DeserializationException {
  FilterProtos.FuzzyRowFilter proto;
  try {
    proto = FilterProtos.FuzzyRowFilter.parseFrom(pbBytes);
  } catch (InvalidProtocolBufferException e) {
    throw new DeserializationException(e);
  }
  int count = proto.getFuzzyKeysDataCount();
  ArrayList<Pair<byte[], byte[]>> fuzzyKeysData= new ArrayList<Pair<byte[], byte[]>>(count);
  for (int i = 0; i < count; ++i) {
    BytesBytesPair current = proto.getFuzzyKeysData(i);
    byte[] keyBytes = current.getFirst().toByteArray();
    byte[] keyMeta = current.getSecond().toByteArray();
    fuzzyKeysData.add(new Pair<byte[], byte[]>(keyBytes, keyMeta));
  }
  return new FuzzyRowFilter(fuzzyKeysData);
}
项目:QDrill    文件:HBaseUtils.java   
public static byte[] serializeFilter(Filter filter) {
  if (filter == null) {
    return null;
  }
  try {
    FilterProtos.Filter pbFilter = ProtobufUtil.toFilter(filter);
    return pbFilter.toByteArray();
  } catch (IOException e) {
    throw new DrillRuntimeException("Error serializing filter: " + filter, e);
  }
}
项目:QDrill    文件:HBaseUtils.java   
public static Filter deserializeFilter(byte[] filterBytes) {
  if (filterBytes == null) {
    return null;
  }
  try {
    FilterProtos.Filter pbFilter = FilterProtos.Filter.parseFrom(filterBytes);
    return ProtobufUtil.toFilter(pbFilter);
  } catch (Exception e) {
    throw new DrillRuntimeException("Error deserializing filter: " + filterBytes, e);
  }
}
项目:dremio-oss    文件:HBaseUtils.java   
public static byte[] serializeFilter(Filter filter) {
  if (filter == null) {
    return null;
  }
  try {
    FilterProtos.Filter pbFilter = ProtobufUtil.toFilter(filter);
    return pbFilter.toByteArray();
  } catch (IOException e) {
    throw new RuntimeException("Error serializing filter: " + filter, e);
  }
}
项目:dremio-oss    文件:HBaseUtils.java   
public static Filter deserializeFilter(byte[] filterBytes) {
  if (filterBytes == null) {
    return null;
  }
  try {
    FilterProtos.Filter pbFilter = FilterProtos.Filter.parseFrom(filterBytes);
    return ProtobufUtil.toFilter(pbFilter);
  } catch (Exception e) {
    throw new RuntimeException("Error deserializing filter: " + filterBytes, e);
  }
}