当前位置: 首页>>代码示例>>Java>>正文


Java FilterProtos.Filter方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.protobuf.generated.FilterProtos.Filter方法的典型用法代码示例。如果您正苦于以下问题:Java FilterProtos.Filter方法的具体用法?Java FilterProtos.Filter怎么用?Java FilterProtos.Filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.protobuf.generated.FilterProtos的用法示例。


在下文中一共展示了FilterProtos.Filter方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toFilter

import org.apache.hadoop.hbase.protobuf.generated.FilterProtos; //导入方法依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:26,代码来源:ProtobufUtil.java

示例2: toFilter

import org.apache.hadoop.hbase.protobuf.generated.FilterProtos; //导入方法依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:24,代码来源:ProtobufUtil.java

示例3: parseFrom

import org.apache.hadoop.hbase.protobuf.generated.FilterProtos; //导入方法依赖的package包/类
/**
 * @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);
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:26,代码来源:FilterList.java

示例4: serializeFilter

import org.apache.hadoop.hbase.protobuf.generated.FilterProtos; //导入方法依赖的package包/类
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);
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:12,代码来源:HBaseUtils.java

示例5: deserializeFilter

import org.apache.hadoop.hbase.protobuf.generated.FilterProtos; //导入方法依赖的package包/类
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);
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:12,代码来源:HBaseUtils.java

示例6: serializeFilter

import org.apache.hadoop.hbase.protobuf.generated.FilterProtos; //导入方法依赖的package包/类
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);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:12,代码来源:HBaseUtils.java

示例7: deserializeFilter

import org.apache.hadoop.hbase.protobuf.generated.FilterProtos; //导入方法依赖的package包/类
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);
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:12,代码来源:HBaseUtils.java

示例8: serializationTest

import org.apache.hadoop.hbase.protobuf.generated.FilterProtos; //导入方法依赖的package包/类
private Filter serializationTest(Filter filter) throws Exception {
  FilterProtos.Filter filterProto = ProtobufUtil.toFilter(filter);
  Filter newFilter = ProtobufUtil.toFilter(filterProto);

  return newFilter;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:7,代码来源:TestColumnPaginationFilter.java

示例9: toGet

import org.apache.hadoop.hbase.protobuf.generated.FilterProtos; //导入方法依赖的package包/类
/**
 * Convert a protocol buffer Get to a client Get
 *
 * @param proto the protocol buffer Get to convert
 * @return the converted client Get
 * @throws IOException
 */
public static Get toGet(
    final ClientProtos.Get proto) throws IOException {
  if (proto == null) return null;
  byte[] row = proto.getRow().toByteArray();
  Get get = new Get(row);
  if (proto.hasCacheBlocks()) {
    get.setCacheBlocks(proto.getCacheBlocks());
  }
  if (proto.hasMaxVersions()) {
    get.setMaxVersions(proto.getMaxVersions());
  }
  if (proto.hasStoreLimit()) {
    get.setMaxResultsPerColumnFamily(proto.getStoreLimit());
  }
  if (proto.hasStoreOffset()) {
    get.setRowOffsetPerColumnFamily(proto.getStoreOffset());
  }
  if (proto.hasTimeRange()) {
    HBaseProtos.TimeRange timeRange = proto.getTimeRange();
    long minStamp = 0;
    long maxStamp = Long.MAX_VALUE;
    if (timeRange.hasFrom()) {
      minStamp = timeRange.getFrom();
    }
    if (timeRange.hasTo()) {
      maxStamp = timeRange.getTo();
    }
    get.setTimeRange(minStamp, maxStamp);
  }
  if (proto.hasFilter()) {
    FilterProtos.Filter filter = proto.getFilter();
    get.setFilter(ProtobufUtil.toFilter(filter));
  }
  for (NameBytesPair attribute: proto.getAttributeList()) {
    get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
  }
  if (proto.getColumnCount() > 0) {
    for (Column column: proto.getColumnList()) {
      byte[] family = column.getFamily().toByteArray();
      if (column.getQualifierCount() > 0) {
        for (ByteString qualifier: column.getQualifierList()) {
          get.addColumn(family, qualifier.toByteArray());
        }
      } else {
        get.addFamily(family);
      }
    }
  }
  if (proto.hasExistenceOnly() && proto.getExistenceOnly()){
    get.setCheckExistenceOnly(true);
  }
  if (proto.hasClosestRowBefore() && proto.getClosestRowBefore()){
    get.setClosestRowBefore(true);
  }
  if (proto.hasConsistency()) {
    get.setConsistency(toConsistency(proto.getConsistency()));
  }
  return get;
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:67,代码来源:ProtobufUtil.java

示例10: toGet

import org.apache.hadoop.hbase.protobuf.generated.FilterProtos; //导入方法依赖的package包/类
/**
 * Convert a protocol buffer Get to a client Get
 *
 * @param proto the protocol buffer Get to convert
 * @return the converted client Get
 * @throws IOException
 */
public static Get toGet(
    final ClientProtos.Get proto) throws IOException {
  if (proto == null) return null;
  byte[] row = proto.getRow().toByteArray();
  Get get = new Get(row);
  if (proto.hasCacheBlocks()) {
    get.setCacheBlocks(proto.getCacheBlocks());
  }
  if (proto.hasMaxVersions()) {
    get.setMaxVersions(proto.getMaxVersions());
  }
  if (proto.hasStoreLimit()) {
    get.setMaxResultsPerColumnFamily(proto.getStoreLimit());
  }
  if (proto.hasStoreOffset()) {
    get.setRowOffsetPerColumnFamily(proto.getStoreOffset());
  }
  if (proto.hasTimeRange()) {
    HBaseProtos.TimeRange timeRange = proto.getTimeRange();
    long minStamp = 0;
    long maxStamp = Long.MAX_VALUE;
    if (timeRange.hasFrom()) {
      minStamp = timeRange.getFrom();
    }
    if (timeRange.hasTo()) {
      maxStamp = timeRange.getTo();
    }
    get.setTimeRange(minStamp, maxStamp);
  }
  if (proto.hasFilter()) {
    FilterProtos.Filter filter = proto.getFilter();
    get.setFilter(ProtobufUtil.toFilter(filter));
  }
  for (NameBytesPair attribute: proto.getAttributeList()) {
    get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
  }
  if (proto.getColumnCount() > 0) {
    for (Column column: proto.getColumnList()) {
      byte[] family = column.getFamily().toByteArray();
      if (column.getQualifierCount() > 0) {
        for (ByteString qualifier: column.getQualifierList()) {
          get.addColumn(family, qualifier.toByteArray());
        }
      } else {
        get.addFamily(family);
      }
    }
  }
  if (proto.hasExistenceOnly() && proto.getExistenceOnly()){
    get.setCheckExistenceOnly(true);
  }
  if (proto.hasClosestRowBefore() && proto.getClosestRowBefore()){
    get.setClosestRowBefore(true);
  }
  return get;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:64,代码来源:ProtobufUtil.java

示例11: toScan

import org.apache.hadoop.hbase.protobuf.generated.FilterProtos; //导入方法依赖的package包/类
/**
 * Convert a protocol buffer Scan to a client Scan
 *
 * @param proto the protocol buffer Scan to convert
 * @return the converted client Scan
 * @throws IOException
 */
public static Scan toScan(
    final ClientProtos.Scan proto) throws IOException {
  byte [] startRow = HConstants.EMPTY_START_ROW;
  byte [] stopRow  = HConstants.EMPTY_END_ROW;
  if (proto.hasStartRow()) {
    startRow = proto.getStartRow().toByteArray();
  }
  if (proto.hasStopRow()) {
    stopRow = proto.getStopRow().toByteArray();
  }
  Scan scan = new Scan(startRow, stopRow);
  if (proto.hasCacheBlocks()) {
    scan.setCacheBlocks(proto.getCacheBlocks());
  }
  if (proto.hasMaxVersions()) {
    scan.setMaxVersions(proto.getMaxVersions());
  }
  if (proto.hasStoreLimit()) {
    scan.setMaxResultsPerColumnFamily(proto.getStoreLimit());
  }
  if (proto.hasStoreOffset()) {
    scan.setRowOffsetPerColumnFamily(proto.getStoreOffset());
  }
  if (proto.hasLoadColumnFamiliesOnDemand()) {
    scan.setLoadColumnFamiliesOnDemand(proto.getLoadColumnFamiliesOnDemand());
  }
  if (proto.hasTimeRange()) {
    HBaseProtos.TimeRange timeRange = proto.getTimeRange();
    long minStamp = 0;
    long maxStamp = Long.MAX_VALUE;
    if (timeRange.hasFrom()) {
      minStamp = timeRange.getFrom();
    }
    if (timeRange.hasTo()) {
      maxStamp = timeRange.getTo();
    }
    scan.setTimeRange(minStamp, maxStamp);
  }
  if (proto.hasFilter()) {
    FilterProtos.Filter filter = proto.getFilter();
    scan.setFilter(ProtobufUtil.toFilter(filter));
  }
  if (proto.hasBatchSize()) {
    scan.setBatch(proto.getBatchSize());
  }
  if (proto.hasMaxResultSize()) {
    scan.setMaxResultSize(proto.getMaxResultSize());
  }
  if (proto.hasSmall()) {
    scan.setSmall(proto.getSmall());
  }
  for (NameBytesPair attribute: proto.getAttributeList()) {
    scan.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
  }
  if (proto.getColumnCount() > 0) {
    for (Column column: proto.getColumnList()) {
      byte[] family = column.getFamily().toByteArray();
      if (column.getQualifierCount() > 0) {
        for (ByteString qualifier: column.getQualifierList()) {
          scan.addColumn(family, qualifier.toByteArray());
        }
      } else {
        scan.addFamily(family);
      }
    }
  }
  if (proto.hasReversed()) {
    scan.setReversed(proto.getReversed());
  }
  return scan;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:79,代码来源:ProtobufUtil.java


注:本文中的org.apache.hadoop.hbase.protobuf.generated.FilterProtos.Filter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。