2
* Copyright (C) 2011 Akiban Technologies Inc.
3
* This program is free software: you can redistribute it and/or modify
4
* it under the terms of the GNU Affero General Public License, version 3,
5
* as published by the Free Software Foundation.
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU Affero General Public License for more details.
12
* You should have received a copy of the GNU Affero General Public License
13
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
import com.persistit.Persistit;
17
import com.persistit.Exchange;
18
import com.persistit.Key;
20
public class HelloWorld
22
public static void main(String[] args)
25
Persistit persistit = new Persistit();
28
// Reads configuration from persistit.properties, allocates
29
// buffers, opens Volume(s), and performs recovery processing
32
persistit.initialize();
34
// Creates an Exchange, which is a thread-private facade for
35
// accessing data in a Persistit Tree. This Exchange will
36
// access a Tree called "greetings" in a Volume called
37
// "hwdemo". It will create a new Tree by that name
38
// if one does not already exist.
40
Exchange dbex = new Exchange(persistit, "hwdemo", "greetings", true);
42
// Set up the Value field of the Exchange.
44
dbex.getValue().put("World");
46
// Set up the Key field of the Exchange.
48
dbex.getKey().append("Hello");
50
// Ask Persistit to put this key/value pair into the Tree.
51
// Until this point, the changes to the Exchange are local
56
// Prepare to traverse all the keys in the Tree (of which there
57
// is currently only one!) and for each key display its value.
59
dbex.getKey().to(Key.BEFORE);
63
dbex.getKey().indexTo(0).decode() + " " +
64
dbex.getValue().get());
69
// Always close Persistit. If the application does not do
70
// this, Persistit's background threads will keep the JVM from
b'\\ No newline at end of file'