Class RowKeyElastic

java.lang.Object
ghidra.features.bsim.query.description.RowKey
ghidra.features.bsim.query.elastic.RowKeyElastic
All Implemented Interfaces:
Comparable<RowKey>

public class RowKeyElastic extends RowKey
A "document id" that uniquely indexes documents, within the ElasticSearch database, that describe executables ExecutableRecord and functions FunctionDescription This plays the same role as the row id for executable and function rows in an SQL database.
  • Field Details

    • valueA

      protected int valueA
    • valueB

      protected int valueB
    • valueC

      protected int valueC
  • Constructor Details

    • RowKeyElastic

      public RowKeyElastic(long val)
      Initialize a key from a 64-bit long value
      Parameters:
      val - is (least significant) 64-bits of the key
    • RowKeyElastic

      public RowKeyElastic(int a, int b, int c)
      Create 96-bit, given 3 32-bit integers
      Parameters:
      a - is most significant 32-bits
      b - is middle 32-bits
      c - is least significant 32-bits
    • RowKeyElastic

      public RowKeyElastic(String md5)
      Construct key from String representation of an md5 hash. The key is initialized from the last 96-bits of the hash
      Parameters:
      md5 - is the hash
    • RowKeyElastic

      public RowKeyElastic()
      Key initialized to zero
  • Method Details

    • getLong

      public long getLong()
      Specified by:
      getLong in class RowKey
      Returns:
      the (least significant) 64-bits of the row key
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(RowKey obj)
    • generateExeIdString

      public String generateExeIdString()
      Emit the key as a base64 string of 16-characters. Used to encode executable document ids
      Returns:
      the String encoding
    • generateLibraryFunctionId

      public void generateLibraryFunctionId(StringBuilder buffer, String funcName)
      Generate an encoded document id from 64 bits of this key + additional bits derived from a name string. This encodes the document id of a library function given just the function Name and the RowKey (this) of the containing library executable. The final String encodes 80-bits of id in 14 characters.
      Parameters:
      buffer - is the StringBuilder to encode the id to
      funcName - is a function name that is hashed into the final encoded id
    • generateFunctionId

      public void generateFunctionId(StringBuilder buffer, FunctionDescription func)
      Generate an id string for a FunctionDescription. If the function is not from a library, just use the counter id already set for the function and emit it as a decimal string. If it is from a library, emit an id, 4 bytes of which is from the md5 placeholder hash of the library, the rest of the id is a base64 encoding of a hash generated from: the remainder of the md5 placeholder hash of the library the name of the function
      Parameters:
      buffer - holds the emitted id string
      func - is the function being labeled
    • parseExeIdString

      public static RowKeyElastic parseExeIdString(String id)
      Parse an encoded document id of an executable back into a key
      Parameters:
      id - is the encoded String
      Returns:
      the decoded RowKey
    • parseFunctionId

      public static RowKeyElastic parseFunctionId(String val)
      Parse an encoded document id of a function back into a key This handles both the normal function form: 64-bits encoded as decimal and the library function form: 80-bits encoded in base64
      Parameters:
      val - is the encoded String
      Returns:
      the decoded RowKey