congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
RowKeyFormat.getEncoding
Code IndexAdd Tabnine to your IDE (free)

How to use
getEncoding
method
in
com.moz.fiji.schema.avro.RowKeyFormat

Best Java code snippets using com.moz.fiji.schema.avro.RowKeyFormat.getEncoding (Showing top 12 results out of 315)

origin: com.moz.fiji.schema/fiji-schema

/**
 * Creates a HashPrefixedEntityIdFactory.
 *
 * @param format Row key format.
 */
private HashPrefixedEntityIdFactory(RowKeyFormat format) {
 Preconditions.checkNotNull(format);
 Preconditions.checkArgument(format.getEncoding() == RowKeyEncoding.HASH_PREFIX);
 mRowKeyFormat = format;
}
origin: com.moz.fiji.schema/fiji-schema

/**
 * Creates a RawEntityIdFactory.
 *
 * @param format Row key format.
 */
private RawEntityIdFactory(RowKeyFormat format) {
 Preconditions.checkNotNull(format);
 Preconditions.checkArgument(format.getEncoding() == RowKeyEncoding.RAW);
}
origin: com.moz.fiji.schema/fiji-schema

/**
 * Creates a new Hashed Entity ID factory.
 *
 * @param format The format for creating the hashed entity ID factory.
 */
private HashedEntityIdFactory(RowKeyFormat format) {
 Preconditions.checkNotNull(format);
 Preconditions.checkArgument(format.getEncoding() == RowKeyEncoding.HASH);
 mRowKeyFormat = format;
}
origin: com.moz.fiji.schema/fiji-schema

/**
 * Creates a new HashPrefixedEntityId.
 *
 * @param fijiRowKey Fiji row key.
 * @param hbaseRowKey HBase row key.
 * @param format Row key hashing specification.
 */
private HashPrefixedEntityId(byte[] fijiRowKey, byte[] hbaseRowKey, RowKeyFormat format) {
 Preconditions.checkNotNull(format);
 Preconditions.checkArgument(format.getEncoding() == RowKeyEncoding.HASH_PREFIX);
 mFijiRowKey = Preconditions.checkNotNull(fijiRowKey);
 mHBaseRowKey = Preconditions.checkNotNull(hbaseRowKey);
}
origin: com.moz.fiji.schema/fiji-schema

/**
 * Creates a new HashedEntityId.
 *
 * @param fijiRowKey Fiji row key.
 * @param hbaseRowKey HBase row key.
 * @param format Row key hashing specification.
 */
private HashedEntityId(byte[] fijiRowKey, byte[] hbaseRowKey, RowKeyFormat format) {
 Preconditions.checkNotNull(format);
 Preconditions.checkArgument(format.getEncoding() == RowKeyEncoding.HASH);
 mFijiRowKey = fijiRowKey;
 mHBaseRowKey = Preconditions.checkNotNull(hbaseRowKey);
}
origin: com.moz.fiji.schema/fiji-schema

/**
 * Find the encoding of the row key given the format.
 *
 * @param rowKeyFormat Format of row keys of type RowKeyFormat or RowKeyFormat2.
 * @return The specific row key encoding, e.g. RAW, HASH, etc.
 */
public static RowKeyEncoding getEncoding(Object rowKeyFormat) {
 if (rowKeyFormat instanceof RowKeyFormat) {
  return ((RowKeyFormat) rowKeyFormat).getEncoding();
 } else if (rowKeyFormat instanceof RowKeyFormat2) {
  return ((RowKeyFormat2) rowKeyFormat).getEncoding();
 } else {
  throw new RuntimeException("Unsupported Row Key Format");
 }
}
origin: com.moz.fiji.rest/fiji-rest-lib

/**
 * Gets row key encoding of a row key format.
 *
 * @param keysFormat row key format.
 * @return row key encoding.
 * @throws IOException if row key format is unrecognized.
 */
private static RowKeyEncoding getEncoding(final Object keysFormat) throws IOException {
 if (keysFormat instanceof RowKeyFormat) {
  return ((RowKeyFormat) keysFormat).getEncoding();
 } else if (keysFormat instanceof RowKeyFormat2) {
  return ((RowKeyFormat2) keysFormat).getEncoding();
 } else {
  throw new IOException(
    String.format("Unrecognized row key format: %s", keysFormat.getClass()));
 }
}
origin: com.moz.fiji.schema/fiji-schema

/**
 * Gets row key encoding of a row key format.
 *
 * @param keysFormat row key format.
 * @return row key encoding.
 * @throws IOException if row key format is unrecognized.
 */
private static RowKeyEncoding getEncoding(final Object keysFormat) throws IOException {
 if (keysFormat instanceof RowKeyFormat) {
  return ((RowKeyFormat) keysFormat).getEncoding();
 } else if (keysFormat instanceof RowKeyFormat2) {
  return ((RowKeyFormat2) keysFormat).getEncoding();
 } else {
  throw new IOException(
    String.format("Unrecognized row key format: %s", keysFormat.getClass()));
 }
}
origin: com.moz.fiji.schema/fiji-schema

/**
 * Creates a HashPrefixedEntityId from the specified HBase row key.
 *
 * @param hbaseRowKey HBase row key.
 * @param format Row key hashing specification.
 * @return a new HashedEntityId with the specified HBase row key.
 */
static HashPrefixedEntityId fromHBaseRowKey(byte[] hbaseRowKey, RowKeyFormat format) {
 Preconditions.checkNotNull(format);
 Preconditions.checkArgument(format.getEncoding() == RowKeyEncoding.HASH_PREFIX);
 final int hashSize = format.getHashSize();
 final byte[] fijiRowKey =
   Arrays.copyOfRange(hbaseRowKey, hashSize, hbaseRowKey.length);
 // TODO Paranoid expensive check : rehash the fiji key and compare with the hash?
 return new HashPrefixedEntityId(fijiRowKey, hbaseRowKey, format);
}
origin: com.moz.fiji.schema/fiji-schema

/**
 * Creates a HashPrefixedEntityId from the specified Fiji row key.
 *
 * @param fijiRowKey Fiji row key.
 * @param format Row key hashing specification.
 * @return a new HashPrefixedEntityId with the specified Fiji row key.
 */
static HashPrefixedEntityId getEntityId(byte[] fijiRowKey, RowKeyFormat format) {
 Preconditions.checkNotNull(format);
 Preconditions.checkArgument(format.getEncoding() == RowKeyEncoding.HASH_PREFIX);
 final byte[] hash = hashFijiRowKey(format, fijiRowKey);
 final int hashSize = format.getHashSize();
 // Prepend a subset of the hash to the Fiji row key:
 final byte[] hbaseRowKey = new byte[hashSize + fijiRowKey.length];
 System.arraycopy(hash, 0, hbaseRowKey, 0, hashSize);
 System.arraycopy(fijiRowKey, 0, hbaseRowKey, hashSize, fijiRowKey.length);
 return new HashPrefixedEntityId(fijiRowKey, hbaseRowKey, format);
}
origin: com.moz.fiji.schema/fiji-schema

/**
 * Creates an entity ID factory for the specified row key format.
 *
 * @param format Row key format of type RowKeyFormat that determines the
 *               type of EntityIdFactory that's created.
 * @return a new entity ID factory for the specified row key format.
 */
public static EntityIdFactory getFactory(RowKeyFormat format) {
 Preconditions.checkNotNull(format);
 // FORMATTED encoding is legal here but not supported by RowKeyFormat.
 switch (format.getEncoding()) {
 case RAW:
  return new RawEntityIdFactory(format);
 case HASH:
  return new HashedEntityIdFactory(format);
 case HASH_PREFIX:
  return new HashPrefixedEntityIdFactory(format);
 case FORMATTED:
  throw new RuntimeException(
    "Row key format encoding FORMATTED is not supported with RowKeyFormat specifications. "
    + "Use RowKeyFormat2 instead.");
 default:
  throw new RuntimeException(String.format("Unhandled row key format: '%s'.", format));
 }
}
origin: com.moz.fiji.schema/fiji-schema

/**
 * Ensure a row key format (version 1) specified in a layout file is sane.
 * @param format The RowKeyFormat created from the layout file for a table.
 * @throws InvalidLayoutException If the format is invalid.
 */
private void isValidRowKeyFormat1(RowKeyFormat format) throws InvalidLayoutException {
 RowKeyEncoding rowKeyEncoding = format.getEncoding();
 if (rowKeyEncoding != RowKeyEncoding.RAW
   && rowKeyEncoding != RowKeyEncoding.HASH
   && rowKeyEncoding != RowKeyEncoding.HASH_PREFIX) {
  throw new InvalidLayoutException("RowKeyFormat only supports encodings"
    + "of type RAW, HASH and HASH_PREFIX. Use RowKeyFormat2 instead");
 }
 if (rowKeyEncoding == RowKeyEncoding.HASH || rowKeyEncoding == RowKeyEncoding.HASH_PREFIX) {
  if (format.getHashSize() < 0 || format.getHashSize() > Hasher.HASH_SIZE_BYTES) {
   throw new InvalidLayoutException("HASH or HASH_PREFIX row key formats require hash size"
     + "to be between 1 and " + Hasher.HASH_SIZE_BYTES);
  }
 }
}
com.moz.fiji.schema.avroRowKeyFormatgetEncoding

Popular methods of RowKeyFormat

  • getHashSize
  • getHashType

Popular in Java

  • Finding current android device location
  • onCreateOptionsMenu (Activity)
  • getApplicationContext (Context)
  • getSharedPreferences (Context)
  • Menu (java.awt)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now