Class Level1Features
- java.lang.Object
-
- com.tonic.analysis.fingerprint.features.Level1Features
-
- All Implemented Interfaces:
FeatureVector
public class Level1Features extends Object implements FeatureVector
Stable fingerprint features: loop and block-count shape plus branch, arithmetic, and invoke histograms.
-
-
Field Summary
Fields Modifier and Type Field Description static intARRAY_LENGTHstatic intARRAY_LOADstatic intARRAY_NEWstatic intARRAY_STORE
-
Constructor Summary
Constructors Constructor Description Level1Features(int loopCount, int maxLoopNestingDepth, int blockCount, Map<String,Integer> branchTypes, Map<String,Integer> arithmeticOps, Map<String,Integer> invokeTypes, int arrayFlags)Creates a level-1 feature set, bucketing the block count and normalizing the histograms to percentages.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intbucketize(int count)Maps a block count onto one of five coarse size buckets.byte[]computeHash()Digests every extracted feature into a hash usable for equality and lookup.Map<String,Integer>getArithmeticOpHistogram()intgetArrayUsageFlags()intgetBlockCountBucket()Map<String,Integer>getBranchTypeHistogram()Map<String,Integer>getInvokeTypeHistogram()intgetLoopCount()intgetMaxLoopNestingDepth()static doublehistogramSimilarity(Map<String,Integer> a, Map<String,Integer> b)Scores two histograms by the ratio of summed per-key minima to summed per-key maxima.booleanisValid()doublesimilarity(Level1Features other)Scores similarity to another level-1 feature set, mixing exact and near matches with histogram overlaps.
-
-
-
Field Detail
-
ARRAY_LOAD
public static final int ARRAY_LOAD
- See Also:
- Constant Field Values
-
ARRAY_STORE
public static final int ARRAY_STORE
- See Also:
- Constant Field Values
-
ARRAY_NEW
public static final int ARRAY_NEW
- See Also:
- Constant Field Values
-
ARRAY_LENGTH
public static final int ARRAY_LENGTH
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Level1Features
public Level1Features(int loopCount, int maxLoopNestingDepth, int blockCount, Map<String,Integer> branchTypes, Map<String,Integer> arithmeticOps, Map<String,Integer> invokeTypes, int arrayFlags)Creates a level-1 feature set, bucketing the block count and normalizing the histograms to percentages.- Parameters:
loopCount- the estimated number of loopsmaxLoopNestingDepth- the deepest loop nestingblockCount- the raw basic-block countbranchTypes- counts per branch categoryarithmeticOps- counts per arithmetic categoryinvokeTypes- counts per invoke kindarrayFlags- the ARRAY_* usage flag bits
-
-
Method Detail
-
bucketize
public static int bucketize(int count)
Maps a block count onto one of five coarse size buckets.- Parameters:
count- the raw basic-block count- Returns:
- the bucket index, 0 through 4
-
computeHash
public byte[] computeHash()
Description copied from interface:FeatureVectorDigests every extracted feature into a hash usable for equality and lookup.- Specified by:
computeHashin interfaceFeatureVector- Returns:
- the digest bytes
-
isValid
public boolean isValid()
- Specified by:
isValidin interfaceFeatureVector- Returns:
- true if extraction produced features that can be matched against
-
similarity
public double similarity(Level1Features other)
Scores similarity to another level-1 feature set, mixing exact and near matches with histogram overlaps.- Parameters:
other- the feature set to compare against- Returns:
- a score in [0, 1], 0 if other is null
-
histogramSimilarity
public static double histogramSimilarity(Map<String,Integer> a, Map<String,Integer> b)
Scores two histograms by the ratio of summed per-key minima to summed per-key maxima.- Parameters:
a- the first histogram, may be nullb- the second histogram, may be null- Returns:
- a score in [0, 1]; 1 when both are empty
-
getLoopCount
public int getLoopCount()
- Returns:
- the loop count
-
getMaxLoopNestingDepth
public int getMaxLoopNestingDepth()
- Returns:
- the max loop nesting depth
-
getBlockCountBucket
public int getBlockCountBucket()
- Returns:
- the block count bucket
-
getBranchTypeHistogram
public Map<String,Integer> getBranchTypeHistogram()
- Returns:
- an unmodifiable view of the normalized branch-type histogram
-
getArithmeticOpHistogram
public Map<String,Integer> getArithmeticOpHistogram()
- Returns:
- an unmodifiable view of the normalized arithmetic-op histogram
-
getInvokeTypeHistogram
public Map<String,Integer> getInvokeTypeHistogram()
- Returns:
- an unmodifiable view of the normalized invoke-type histogram
-
getArrayUsageFlags
public int getArrayUsageFlags()
- Returns:
- the array usage flags
-
-