com.distelli.persistence.ConvertMarker Maven / Gradle / Ivy
package com.distelli.persistence;
import java.util.Map;
public interface ConvertMarker {
public interface Factory {
/**
* Provide an implementation of ConvertMarker implemented as
* base64(MsgPack) of the keys.
*
* Note that the ordering of otherKeyNames must be consistent.
*
* @param hashKeyName is the index's hash key name.
*
* @param otherKeyNames is the other key names (range key for index,
* hash key and range key of primary index).
*
* @return a generic convert marker implementation that base64 encodes
* a message pack of the selected key attribute names.
*/
public ConvertMarker create(String hashKeyName, String... otherKeyNames);
}
/**
* @param attributes are the full key/value attributes record fetched
* from the DB. The Object
is a dynamo db "simple
* type". See
* http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/document/Item.html#asMap--
*
* @param hasHashKey is true if this is a query (and thus we know
* the hash key between subsequent paginated queries). For
* full table scans this is false.
*
* @return the serialized marker.
*/
public String toMarker(Map attributes, boolean hasHashKey);
/**
* @param hk is the hash key passed into the query(), or null if
* this is a scan().
*
* @param marker is the marker returned from a previous toMarker() call.
*
* @return an array of attributes used to identify the location within
* pagination.
*/
public Attribute[] fromMarker(Object hk, String marker);
}