<commit_before>
/*
 * Copyright (C) 2014 <NAME>. All rights reserved.
 */

package org.jsimpledb.core;

import com.google.common.collect.Lists;

import java.io.ByteArrayInputStream;
import java.util.List;
import java.util.NavigableMap;
import java.util.NavigableSet;
import java.util.TreeMap;

import org.jsimpledb.TestSupport;
import org.jsimpledb.kv.KVPair;
import org.jsimpledb.kv.simple.SimpleKVDatabase;
import org.jsimpledb.kv.util.NavigableMapKVStore;
import org.jsimpledb.schema.SchemaModel;
import org.jsimpledb.util.ByteUtil;
import org.testng.Assert;
import org.testng.annotations.Test;

public class SnapshotTest extends TestSupport {

    @SuppressWarnings("unchecked")
    @Test
    public void testSnapshot() throws Exception {

        // Setup database
        final TreeMap<byte[], byte[]> data1 = new TreeMap<byte[], byte[]>(ByteUtil.COMPARATOR);
        final NavigableMapKVStore kvstore1 = new NavigableMapKVStore(data1);
        final SimpleKVDatabase kv1 = new SimpleKVDatabase(kvstore1, 100, 500);
        final Database db1 = new Database(kv1);

        final SchemaModel schema = SchemaModel.fromXML(new ByteArrayInputStream((
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
          + "<Schema formatVersion=\"1\">\n"
          + "  <ObjectType name=\"Foo\" storageId=\"1\">\n"
          + "    <SimpleField name=\"float\" type=\"float\" storageId=\"2\"/>\n"
          + "    <ReferenceField name=\"rref\" storageId=\"3\"/>\n"
          + "    <SetField name=\"set\" storageId=\"4\">\n"
          + "        <SimpleField type=\"int\" storageId=\"5\"/>\n"
          + "    </SetField>"
          + "    <ListField name=\"list\" storageId=\"6\">\n"
          + "        <SimpleField type=\"int\" storageId=\"7\" indexed=\"true\"/>\n"
          + "    </ListField>"
          + "    <MapField name=\"map\" storageId=\"8\">\n"<commit_msg>Use ConcurrentSkipListMap instead of TreeMap in test to be correct.<commit_after>
/*
 * Copyright (C) 2014 <NAME>. All rights reserved.
 */

package org.jsimpledb.core;

import com.google.common.collect.Lists;

import java.io.ByteArrayInputStream;
import java.util.List;
import java.util.NavigableMap;
import java.util.NavigableSet;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentSkipListMap;

import org.jsimpledb.TestSupport;
import org.jsimpledb.kv.KVPair;
import org.jsimpledb.kv.simple.SimpleKVDatabase;
import org.jsimpledb.kv.util.NavigableMapKVStore;
import org.jsimpledb.schema.SchemaModel;
import org.jsimpledb.util.ByteUtil;
import org.testng.Assert;
import org.testng.annotations.Test;

public class SnapshotTest extends TestSupport {

    @SuppressWarnings("unchecked")
    @Test
    public void testSnapshot() throws Exception {

        // Setup database
        final ConcurrentSkipListMap<byte[], byte[]> data1 = new ConcurrentSkipListMap<byte[], byte[]>(ByteUtil.COMPARATOR);
        final NavigableMapKVStore kvstore1 = new NavigableMapKVStore(data1);
        final SimpleKVDatabase kv1 = new SimpleKVDatabase(kvstore1, 100, 500);
        final Database db1 = new Database(kv1);

        final SchemaModel schema = SchemaModel.fromXML(new ByteArrayInputStream((
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
          + "<Schema formatVersion=\"1\">\n"
          + "  <ObjectType name=\"Foo\" storageId=\"1\">\n"
          + "    <SimpleField name=\"float\" type=\"float\" storageId=\"2\"/>\n"
          + "    <ReferenceField name=\"rref\" storageId=\"3\"/>\n"
          + "    <SetField name=\"set\" storageId=\"4\">\n"
          + "        <SimpleField type=\"int\" storageId=\"5\"/>\n"
          + "    </SetField>"
          + "    <ListField name=\"list\" storageId=\"6\">\n"
          + "        <SimpleField type=\"int\" storageId=\"7\" indexed=\"true\"/>\n"
          + "    </ListField>"
          + "    <MapField name=\"map\" storageId=\"8\">\n"
{'fraction_non_alphanumeric': 0.15751482340809486, 'fraction_numerical': 0.014952307295694767, 'mean_word_length': 2.967280163599182, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 2, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3129237', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1240, 'n_words': 238}