• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java VisibilityLabel类的典型用法和代码示例

java 2次浏览

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

VisibilityLabel类属于org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos包,在下文中一共展示了VisibilityLabel类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: refreshLabelsCache

点赞 3

import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabel; //导入依赖的package包/类
public void refreshLabelsCache(byte[] data) throws IOException {
  List<VisibilityLabel> visibilityLabels = null;
  try {
    visibilityLabels = VisibilityUtils.readLabelsFromZKData(data);
  } catch (DeserializationException dse) {
    throw new IOException(dse);
  }
  this.lock.writeLock().lock();
  try {
    labels.clear();
    ordinalVsLabels.clear();
    for (VisibilityLabel visLabel : visibilityLabels) {
      String label = Bytes.toString(visLabel.getLabel().toByteArray());
      labels.put(label, visLabel.getOrdinal());
      ordinalVsLabels.put(visLabel.getOrdinal(), label);
    }
  } finally {
    this.lock.writeLock().unlock();
  }
}
 

开发者ID:fengchen8086,
项目名称:ditb,
代码行数:21,
代码来源:VisibilityLabelsCache.java

示例2: refreshLabelsCache

点赞 3

import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabel; //导入依赖的package包/类
public void refreshLabelsCache(byte[] data) throws IOException {
  List<VisibilityLabel> visibilityLabels = null;
  try {
    visibilityLabels = VisibilityUtils.readLabelsFromZKData(data);
  } catch (DeserializationException dse) {
    throw new IOException(dse);
  }
  this.lock.writeLock().lock();
  try {
    for (VisibilityLabel visLabel : visibilityLabels) {
      String label = Bytes.toString(visLabel.getLabel().toByteArray());
      labels.put(label, visLabel.getOrdinal());
      ordinalVsLabels.put(visLabel.getOrdinal(), label);
    }
  } finally {
    this.lock.writeLock().unlock();
  }
}
 

开发者ID:tenggyut,
项目名称:HIndex,
代码行数:19,
代码来源:VisibilityLabelsManager.java

示例3: getDataToWriteToZooKeeper

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabel; //导入依赖的package包/类
/**
 * Creates the labels data to be written to zookeeper.
 * @param existingLabels
 * @return Bytes form of labels and their ordinal details to be written to zookeeper.
 */
public static byte[] getDataToWriteToZooKeeper(Map<String, Integer> existingLabels) {
  VisibilityLabelsRequest.Builder visReqBuilder = VisibilityLabelsRequest.newBuilder();
  for (Entry<String, Integer> entry : existingLabels.entrySet()) {
    VisibilityLabel.Builder visLabBuilder = VisibilityLabel.newBuilder();
    visLabBuilder.setLabel(ByteStringer.wrap(Bytes.toBytes(entry.getKey())));
    visLabBuilder.setOrdinal(entry.getValue());
    visReqBuilder.addVisLabel(visLabBuilder.build());
  }
  return ProtobufUtil.prependPBMagic(visReqBuilder.build().toByteArray());
}
 

开发者ID:fengchen8086,
项目名称:ditb,
代码行数:16,
代码来源:VisibilityUtils.java

示例4: readLabelsFromZKData

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabel; //导入依赖的package包/类
/**
 * Reads back from the zookeeper. The data read here is of the form written by
 * writeToZooKeeper(Map&lt;byte[], Integer&gt; entries).
 * 
 * @param data
 * @return Labels and their ordinal details
 * @throws DeserializationException
 */
public static List<VisibilityLabel> readLabelsFromZKData(byte[] data)
    throws DeserializationException {
  if (ProtobufUtil.isPBMagicPrefix(data)) {
    int pblen = ProtobufUtil.lengthOfPBMagic();
    try {
      VisibilityLabelsRequest.Builder builder = VisibilityLabelsRequest.newBuilder();
      ProtobufUtil.mergeFrom(builder, data, pblen, data.length - pblen);
      return builder.getVisLabelList();
    } catch (IOException e) {
      throw new DeserializationException(e);
    }
  }
  return null;
}
 

开发者ID:fengchen8086,
项目名称:ditb,
代码行数:23,
代码来源:VisibilityUtils.java

示例5: readLabelsFromZKData

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabel; //导入依赖的package包/类
/**
 * Reads back from the zookeeper. The data read here is of the form written by
 * writeToZooKeeper(Map<byte[], Integer> entries).
 * 
 * @param data
 * @return Labels and their ordinal details
 * @throws DeserializationException
 */
public static List<VisibilityLabel> readLabelsFromZKData(byte[] data)
    throws DeserializationException {
  if (ProtobufUtil.isPBMagicPrefix(data)) {
    int pblen = ProtobufUtil.lengthOfPBMagic();
    try {
      VisibilityLabelsRequest request = VisibilityLabelsRequest.newBuilder()
          .mergeFrom(data, pblen, data.length - pblen).build();
      return request.getVisLabelList();
    } catch (InvalidProtocolBufferException e) {
      throw new DeserializationException(e);
    }
  }
  return null;
}
 

开发者ID:grokcoder,
项目名称:pbase,
代码行数:23,
代码来源:VisibilityUtils.java

示例6: getDataToWriteToZooKeeper

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabel; //导入依赖的package包/类
/**
 * Creates the labels data to be written to zookeeper.
 * @param existingLabels
 * @return Bytes form of labels and their ordinal details to be written to zookeeper.
 */
public static byte[] getDataToWriteToZooKeeper(Map<String, Integer> existingLabels) {
  VisibilityLabelsRequest.Builder visReqBuilder = VisibilityLabelsRequest.newBuilder();
  for (Entry<String, Integer> entry : existingLabels.entrySet()) {
    VisibilityLabel.Builder visLabBuilder = VisibilityLabel.newBuilder();
    visLabBuilder.setLabel(HBaseZeroCopyByteString.wrap(Bytes.toBytes(entry.getKey())));
    visLabBuilder.setOrdinal(entry.getValue());
    visReqBuilder.addVisLabel(visLabBuilder.build());
  }
  return ProtobufUtil.prependPBMagic(visReqBuilder.build().toByteArray());
}
 

开发者ID:tenggyut,
项目名称:HIndex,
代码行数:16,
代码来源:VisibilityUtils.java

示例7: getDataToWriteToZooKeeper

点赞 2

import org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabel; //导入依赖的package包/类
/**
 * Creates the labels data to be written to zookeeper.
 * @param existingLabels
 * @return Bytes form of labels and their ordinal details to be written to zookeeper.
 */
public static byte[] getDataToWriteToZooKeeper(Map<String, Integer> existingLabels) {
  VisibilityLabelsRequest.Builder visReqBuilder = VisibilityLabelsRequest.newBuilder();
  for (Entry<String, Integer> entry : existingLabels.entrySet()) {
    VisibilityLabel.Builder visLabBuilder = VisibilityLabel.newBuilder();
    visLabBuilder.setLabel(ByteString.copyFrom(Bytes.toBytes(entry.getKey())));
    visLabBuilder.setOrdinal(entry.getValue());
    visReqBuilder.addVisLabel(visLabBuilder.build());
  }
  return ProtobufUtil.prependPBMagic(visReqBuilder.build().toByteArray());
}
 

开发者ID:apache,
项目名称:hbase,
代码行数:16,
代码来源:VisibilityUtils.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)