Exemplo n.º 1
0
 public static boolean matchingValue(final Cell left, final Cell right) {
   return Bytes.equals(
       left.getValueArray(),
       left.getValueOffset(),
       left.getValueLength(),
       right.getValueArray(),
       right.getValueOffset(),
       right.getValueLength());
 }
Exemplo n.º 2
0
 public static int copyValueTo(Cell cell, byte[] destination, int destinationOffset) {
   System.arraycopy(
       cell.getValueArray(),
       cell.getValueOffset(),
       destination,
       destinationOffset,
       cell.getValueLength());
   return destinationOffset + cell.getValueLength();
 }
Exemplo n.º 3
0
 /** @deprecated use MetaTableAccessor methods for interacting with meta layouts */
 @Deprecated
 public static ServerName getServerName(final Result r) {
   Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
   if (cell == null || cell.getValueLength() == 0) return null;
   String hostAndPort =
       Bytes.toString(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
   cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, HConstants.STARTCODE_QUALIFIER);
   if (cell == null || cell.getValueLength() == 0) return null;
   try {
     return ServerName.valueOf(
         hostAndPort,
         Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength()));
   } catch (IllegalArgumentException e) {
     LOG.error("Ignoring invalid region for server " + hostAndPort + "; cell=" + cell, e);
     return null;
   }
 }
Exemplo n.º 4
0
 /**
  * @param cell
  * @return Estimate of the <code>cell</code> size in bytes.
  */
 public static int estimatedSizeOf(final Cell cell) {
   // If a KeyValue, we can give a good estimate of size.
   if (cell instanceof KeyValue) {
     return ((KeyValue) cell).getLength() + Bytes.SIZEOF_INT;
   }
   // TODO: Should we add to Cell a sizeOf?  Would it help? Does it make sense if Cell is
   // prefix encoded or compressed?
   return cell.getRowLength()
       + cell.getFamilyLength()
       + cell.getQualifierLength()
       + cell.getValueLength()
       +
       // Use the KeyValue's infrastructure size presuming that another implementation would have
       // same basic cost.
       KeyValue.KEY_INFRASTRUCTURE_SIZE
       +
       // Serialization is probably preceded by a length (it is in the KeyValueCodec at least).
       Bytes.SIZEOF_INT;
 }
Exemplo n.º 5
0
 /**
  * The latest seqnum that the server writing to meta observed when opening the region. E.g. the
  * seqNum when the result of {@link #getServerName(Result)} was written.
  *
  * @param r Result to pull the seqNum from
  * @return SeqNum, or HConstants.NO_SEQNUM if there's no value written.
  * @deprecated use MetaTableAccessor methods for interacting with meta layouts
  */
 @Deprecated
 public static long getSeqNumDuringOpen(final Result r) {
   Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, HConstants.SEQNUM_QUALIFIER);
   if (cell == null || cell.getValueLength() == 0) return HConstants.NO_SEQNUM;
   return Bytes.toLong(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
 }
Exemplo n.º 6
0
 /**
  * Returns the HRegionInfo object from the column {@link HConstants#CATALOG_FAMILY} and <code>
  * qualifier</code> of the catalog table result.
  *
  * @param r a Result object from the catalog table scan
  * @param qualifier Column family qualifier -- either {@link HConstants#SPLITA_QUALIFIER}, {@link
  *     HConstants#SPLITB_QUALIFIER} or {@link HConstants#REGIONINFO_QUALIFIER}.
  * @return An HRegionInfo instance or null.
  * @deprecated use MetaTableAccessor methods for interacting with meta layouts
  */
 @Deprecated
 public static HRegionInfo getHRegionInfo(final Result r, byte[] qualifier) {
   Cell cell = r.getColumnLatestCell(HConstants.CATALOG_FAMILY, qualifier);
   if (cell == null) return null;
   return parseFromOrNull(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
 }
Exemplo n.º 7
0
 public static byte[] cloneValue(Cell cell) {
   byte[] output = new byte[cell.getValueLength()];
   copyValueTo(cell, output, 0);
   return output;
 }
Exemplo n.º 8
0
 public static boolean matchingValue(final Cell left, final byte[] buf) {
   return Bytes.equals(
       left.getValueArray(), left.getValueOffset(), left.getValueLength(), buf, 0, buf.length);
 }
Exemplo n.º 9
0
 public static ByteBuffer getValueBufferShallowCopy(Cell cell) {
   ByteBuffer buffer =
       ByteBuffer.wrap(cell.getValueArray(), cell.getValueOffset(), cell.getValueLength());
   return buffer;
 }