Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package examples;
 
 import org.mapdb.*;
 
 import java.util.*;

Shows howto use secondary non-unique keys,
 
public class Secondary_Key {
    public static void main(String[] args) {
        // stores string under id
        BTreeMap<LongStringprimary = DBMaker.newTempTreeMap();
        // stores value hash from primary map
        NavigableSet<Fun.Tuple2<Integer,Long>> valueHash =
                new TreeSet<Fun.Tuple2<Integer,Long>>(); //any Set will do
        // bind secondary to primary so it contains secondary key
        Bind.secondaryKey(primaryvalueHashnew Fun.Function2<IntegerLongString>() {
            @Override
            public Integer run(Long keyString value) {
                return value.hashCode();
            }
        });
        //insert some stuff into primary
        primary.put(111L, "some value");
        primary.put(112L, "some value");
        //shot content of secondary
        ..println(valueHash);
        //get all keys where value hashCode is N
        Iterable<Longids = Bind.findSecondaryKeys(valueHash, 1571230533);
        ..println(ids.iterator().next());
    }
New to GrepCode? Check out our FAQ X