Class PredExp

java.lang.Object
com.aerospike.client.query.PredExp
All Implemented Interfaces:
Serializable

public abstract class PredExp
extends Object
implements Serializable
Predicate expression filter. Predicate expression filters are applied on the query results on the server. Predicate expression filters may occur on any bin in the record.
See Also:
Serialized Form
  • Constructor Details

  • Method Details

    • and

      public static PredExp and​(int nexp)
      Create "and" expression.
      Parameters:
      nexp - number of expressions to perform "and" operation. Usually two.
    • or

      public static PredExp or​(int nexp)
      Create "or" expression.
      Parameters:
      nexp - number of expressions to perform "or" operation. Usually two.
    • not

      public static PredExp not()
      Create "not" expression.
    • integerValue

      public static PredExp integerValue​(Calendar val)
      Create Calendar value expressed in nanoseconds since 1970-01-01 epoch as 64 bit integer.
    • integerValue

      public static PredExp integerValue​(long val)
      Create 64 bit integer value.
    • stringValue

      public static PredExp stringValue​(String val)
      Create string value.
    • geoJSONValue

      public static PredExp geoJSONValue​(String val)
      Create geospatial json string value.
    • integerBin

      public static PredExp integerBin​(String name)
      Create 64 bit integer bin predicate.
    • stringBin

      public static PredExp stringBin​(String name)
      Create string bin predicate.
    • geoJSONBin

      public static PredExp geoJSONBin​(String name)
      Create geospatial bin predicate.
    • listBin

      public static PredExp listBin​(String name)
      Create list bin predicate.
    • mapBin

      public static PredExp mapBin​(String name)
      Create map bin predicate.
    • integerVar

      public static PredExp integerVar​(String name)
      Create 64 bit integer variable used in list/map iterations.
    • stringVar

      public static PredExp stringVar​(String name)
      Create string variable used in list/map iterations.
    • geoJSONVar

      public static PredExp geoJSONVar​(String name)
      Create geospatial json string variable used in list/map iterations.
    • recDeviceSize

      public static PredExp recDeviceSize()
      Create record size on disk predicate.
    • recLastUpdate

      public static PredExp recLastUpdate()
      Create record last update time predicate expressed in nanoseconds since 1970-01-01 epoch as 64 bit integer. Example:
       // Record last update time >= 2017-01-15
       PredExp.recLastUpdate()
       PredExp.integerValue(new GregorianCalendar(2017, 0, 15))
       PredExp.integerGreaterEq()
       
    • recVoidTime

      public static PredExp recVoidTime()
      Create record expiration time predicate expressed in nanoseconds since 1970-01-01 epoch as 64 bit integer. Example:
       // Record expires on 2020-01-01
       PredExp.recVoidTime()
       PredExp.integerValue(new GregorianCalendar(2020, 0, 1))
       PredExp.integerGreaterEq()
       PredExp.recVoidTime()
       PredExp.integerValue(new GregorianCalendar(2020, 0, 2))
       PredExp.integerLess()
       PredExp.and(2)
       
    • recDigestModulo

      public static PredExp recDigestModulo​(int mod)
      Create a digest modulo record metadata value predicate expression. The digest modulo expression assumes the value of 4 bytes of the record's key digest modulo it's argument.

      For example, the following sequence of predicate expressions selects records that have digest(key) % 3 == 1):

       PredExp.recDigestModulo(3)
       PredExp.integerValue(1)
       PredExp.integerEqual()
       
    • integerEqual

      public static PredExp integerEqual()
      Create 64 bit integer "=" operation predicate.
    • integerUnequal

      public static PredExp integerUnequal()
      Create 64 bit integer "!=" operation predicate.
    • integerGreater

      public static PredExp integerGreater()
      Create 64 bit integer ">" operation predicate.
    • integerGreaterEq

      public static PredExp integerGreaterEq()
      Create 64 bit integer ">=" operation predicate.
    • integerLess

      public static PredExp integerLess()
      Create 64 bit integer "<" operation predicate.
    • integerLessEq

      public static PredExp integerLessEq()
      Create 64 bit integer "<=" operation predicate.
    • stringEqual

      public static PredExp stringEqual()
      Create string "=" operation predicate.
    • stringUnequal

      public static PredExp stringUnequal()
      Create string "!=" operation predicate.
    • stringRegex

      public static PredExp stringRegex​(int flags)
      Create regular expression string operation predicate. Example:
       PredExp.stringRegex(RegexFlag.EXTENDED | RegexFlag.ICASE)
       
      Parameters:
      flags - regular expression bit flags. See RegexFlag
    • geoJSONWithin

      public static PredExp geoJSONWithin()
      Create geospatial json "within" predicate.
    • geoJSONContains

      public static PredExp geoJSONContains()
      Create geospatial json "contains" predicate.
    • listIterateOr

      public static PredExp listIterateOr​(String varName)
      Create list predicate where expression matches for any list item. Example:
       // Find records where any list item v = "hello" in list bin x.
       PredExp.stringVar("v")
       PredExp.stringValue("hello")
       PredExp.stringEqual()
       PredExp.listBin("x")
       PredExp.listIterateOr("v")
       
    • listIterateAnd

      public static PredExp listIterateAnd​(String varName)
      Create list predicate where expression matches for all list items. Example:
       // Find records where all list elements v != "goodbye" in list bin x.
       PredExp.stringVar("v")
       PredExp.stringValue("goodbye")
       PredExp.stringUnequal()
       PredExp.listBin("x")
       PredExp.listIterateAnd("v")
       
    • mapKeyIterateOr

      public static PredExp mapKeyIterateOr​(String varName)
      Create map predicate where expression matches for any map key. Example:
       // Find records where any map key k = 7 in map bin m.
       PredExp.integerVar("k")
       PredExp.integerValue(7)
       PredExp.integerEqual()
       PredExp.mapBin("m")
       PredExp.mapKeyIterateOr("k")
       
    • mapKeyIterateAnd

      public static PredExp mapKeyIterateAnd​(String varName)
      Create map key predicate where expression matches for all map keys. Example:
       // Find records where all map keys k < 5 in map bin m.
       PredExp.integerVar("k")
       PredExp.integerValue(5)
       PredExp.integerLess()
       PredExp.mapBin("m")
       PredExp.mapKeyIterateAnd("k")
       
    • mapValIterateOr

      public static PredExp mapValIterateOr​(String varName)
      Create map predicate where expression matches for any map value.
       // Find records where any map value v > 100 in map bin m.
       PredExp.integerVar("v")
       PredExp.integerValue(100)
       PredExp.integerGreater()
       PredExp.mapBin("m")
       PredExp.mapValIterateOr("v")
       
    • mapValIterateAnd

      public static PredExp mapValIterateAnd​(String varName)
      Create map predicate where expression matches for all map values. Example:
       // Find records where all map values v > 500 in map bin m.
       PredExp.integerVar("v")
       PredExp.integerValue(500)
       PredExp.integerGreater()
       PredExp.mapBin("m")
       PredExp.mapValIterateAnd("v")
       
    • estimateSize

      public static int estimateSize​(PredExp[] predExp)
      Estimate size of predicate expressions. For internal use only.
    • write

      public static int write​(PredExp[] predExp, byte[] buf, int offset)
      Write predicate expressions to write protocol. For internal use only.
    • estimateSize

      public abstract int estimateSize()
      Estimate size of predicate expression. For internal use only.
    • write

      public abstract int write​(byte[] buf, int offset)
      Write predicate expression to write protocol. For internal use only.