/**
 * END USER LICENSE AGREEMENT (“EULA”)
 *
 * READ THIS AGREEMENT CAREFULLY (date: 9/13/2011):
 * http://www.akiban.com/licensing/20110913
 *
 * BY INSTALLING OR USING ALL OR ANY PORTION OF THE SOFTWARE, YOU ARE ACCEPTING
 * ALL OF THE TERMS AND CONDITIONS OF THIS AGREEMENT. YOU AGREE THAT THIS
 * AGREEMENT IS ENFORCEABLE LIKE ANY WRITTEN AGREEMENT SIGNED BY YOU.
 *
 * IF YOU HAVE PAID A LICENSE FEE FOR USE OF THE SOFTWARE AND DO NOT AGREE TO
 * THESE TERMS, YOU MAY RETURN THE SOFTWARE FOR A FULL REFUND PROVIDED YOU (A) DO
 * NOT USE THE SOFTWARE AND (B) RETURN THE SOFTWARE WITHIN THIRTY (30) DAYS OF
 * YOUR INITIAL PURCHASE.
 *
 * IF YOU WISH TO USE THE SOFTWARE AS AN EMPLOYEE, CONTRACTOR, OR AGENT OF A
 * CORPORATION, PARTNERSHIP OR SIMILAR ENTITY, THEN YOU MUST BE AUTHORIZED TO SIGN
 * FOR AND BIND THE ENTITY IN ORDER TO ACCEPT THE TERMS OF THIS AGREEMENT. THE
 * LICENSES GRANTED UNDER THIS AGREEMENT ARE EXPRESSLY CONDITIONED UPON ACCEPTANCE
 * BY SUCH AUTHORIZED PERSONNEL.
 *
 * IF YOU HAVE ENTERED INTO A SEPARATE WRITTEN LICENSE AGREEMENT WITH AKIBAN FOR
 * USE OF THE SOFTWARE, THE TERMS AND CONDITIONS OF SUCH OTHER AGREEMENT SHALL
 * PREVAIL OVER ANY CONFLICTING TERMS OR CONDITIONS IN THIS AGREEMENT.
 */

package com.akiban.server.store;

import com.persistit.Exchange;
import com.persistit.Management.DisplayFilter;

class RowDataDisplayFilter implements DisplayFilter {
    private DisplayFilter defaultFilter;

    public RowDataDisplayFilter(final DisplayFilter filter) {
        this.defaultFilter = filter;
    }

    public String toKeyDisplayString(final Exchange exchange) {
        return defaultFilter.toKeyDisplayString(exchange);
    }

    public String toValueDisplayString(final Exchange exchange) {
        final String treeName = exchange.getTree().getName();

        // TODO: UPDATE FOR PROTOBUF
        /*
        if (treeName.equals(TreeService.SCHEMA_TREE_NAME)) {
            try {
                final Key key = exchange.getKey();
                if(key.decodeString().equals("byAIS")) {
                    byte[] storedAIS = exchange.fetch().getValue().getByteArray();
                    GrowableByteBuffer buffer = GrowableByteBuffer.wrap(storedAIS);
                    AkibanInformationSchema ais = new Reader(new MessageSource(buffer)).load();
                    return CSVTarget.toString(ais);
                }
            } catch (Exception e) {
                // fall through and attempt to use default display filter
            }
        }*/
        return defaultFilter.toValueDisplayString(exchange);
    }
}

@@ -1276,129 +1276,552 @@
 com.
-persistit.Exchange;%0Aimport com.persistit.Management.DisplayFilter;%0A%0Aclass RowDataDisplayFilter implements DisplayFilter %7B
+akiban.ais.model.AkibanInformationSchema;%0Aimport com.akiban.ais.protobuf.AISProtobuf;%0Aimport com.akiban.ais.protobuf.ProtobufReader;%0Aimport com.akiban.server.service.tree.TreeService;%0Aimport com.akiban.util.GrowableByteBuffer;%0Aimport com.persistit.Exchange;%0Aimport com.persistit.Key;%0Aimport com.persistit.Management.DisplayFilter;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0Aclass RowDataDisplayFilter implements DisplayFilter %7B%0A    private static final Logger LOG = LoggerFactory.getLogger(RowDataDisplayFilter.class.getName());%0A
 %0A   
@@ -2228,56 +2228,8 @@
 );%0A%0A
-        // TODO: UPDATE FOR PROTOBUF%0A        /*%0A
     
@@ -2402,16 +2402,18 @@
 uals(%22by
+PB
 AIS%22)) %7B
@@ -2409,24 +2409,331 @@
 yPBAIS%22)) %7B%0A
+                    // Default string, will include MVV information%0A                    String def = defaultFilter.toValueDisplayString(exchange);%0A                    // New exchange (that doesn't have ignore MVV set), to get pretty-print of latest%0A                    Exchange ex = new Exchange(exchange);%0A
             
@@ -2761,22 +2761,16 @@
 AIS = ex
-change
 .fetch()
@@ -2939,86 +2939,301 @@
 new 
-Reader(new MessageSource(buffer)).load();%0A                    return CSVTarget
+AkibanInformationSchema();%0A                    AISProtobuf.AkibanInformationSchema.Builder pbAIS = AISProtobuf.AkibanInformationSchema.newBuilder();%0A                    new ProtobufReader(ais, pbAIS).loadBuffer(buffer);%0A                    return %22raw:%5Cn%22 + def + %22%5Cnlatest:%5Cn%22 + pbAIS.build()
 .toS
@@ -3238,19 +3238,16 @@
 oString(
-ais
 );%0A     
@@ -3315,65 +3315,57 @@
     
-// fall through and attempt to use default display filter
+LOG.debug(%22Failure to decode byPBAIS key %7B%7D%22, e);
 %0A   
@@ -3384,18 +3384,16 @@
        %7D
-*/
 %0A       

Update RDDF for protobuf