Package com.orientechnologies.common.directmemory

Examples of com.orientechnologies.common.directmemory.ODirectMemoryPointer


    // 8, 9, 10, 11, 20
    pageChanges.addChanges(21, new byte[] { 12, 13, 14, 15 }, new byte[] { 9, 10, 11, 20 });
    // 8, 12, 13, 14, 15

    ODirectMemoryPointer pointer = new ODirectMemoryPointer(1024 + ODurablePage.PAGE_PADDING);
    pageChanges.applyChanges(pointer);

    Assert.assertEquals(pointer.get(10 + ODurablePage.PAGE_PADDING, 5), new byte[] { 0, 4, 5, 6, 7 });
    Assert.assertEquals(pointer.get(20 + ODurablePage.PAGE_PADDING, 5), new byte[] { 8, 12, 13, 14, 15 });

    pageChanges.revertChanges(pointer);
    Assert.assertEquals(pointer.get(10 + ODurablePage.PAGE_PADDING, 5), new byte[] { 3, 2, 1, 0, 10 });
    Assert.assertEquals(pointer.get(20 + ODurablePage.PAGE_PADDING, 5), new byte[] { 11, 10, 9, 8, 20 });

    pointer.free();
  }
View Full Code Here


    OPageChanges pageChanges = new OPageChanges();
    pageChanges.addChanges(10, new byte[] { 0, 1, 2, 3 }, new byte[] { 3, 2, 1, 0 });
    pageChanges.addChanges(14, new byte[] { 4, 5, 6, 7 }, new byte[] { 7, 6, 5, 4 });
    pageChanges.addChanges(18, new byte[] { 8, 9, 10, 11 }, new byte[] { 11, 10, 9, 8 });

    ODirectMemoryPointer pointer = new ODirectMemoryPointer(1024 + ODurablePage.PAGE_PADDING);
    pageChanges.applyChanges(pointer);

    Assert.assertEquals(pointer.get(10 + ODurablePage.PAGE_PADDING, 12), new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 });

    pageChanges.revertChanges(pointer);
    Assert.assertEquals(pointer.get(10 + ODurablePage.PAGE_PADDING, 12), new byte[] { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8 });

    pointer.free();
  }
View Full Code Here

    pageChanges.addChanges(10, new byte[] { 0, 1, 2, 3 }, new byte[] { 3, 2, 1, 0 });
    pageChanges.addChanges(22, new byte[] { 12, 13, 14, 15 }, new byte[] { 15, 14, 13, 12 });
    pageChanges.addChanges(18, new byte[] { 8, 9, 10, 11 }, new byte[] { 11, 10, 9, 8 });
    pageChanges.addChanges(14, new byte[] { 4, 5, 6, 7 }, new byte[] { 7, 6, 5, 4 });

    ODirectMemoryPointer pointer = new ODirectMemoryPointer(1024 + ODurablePage.PAGE_PADDING);
    pageChanges.applyChanges(pointer);

    Assert.assertEquals(pointer.get(10 + ODurablePage.PAGE_PADDING, 16), new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
        14, 15 });

    pageChanges.revertChanges(pointer);
    Assert.assertEquals(pointer.get(10 + ODurablePage.PAGE_PADDING, 16), new byte[] { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14,
        13, 12 });

    pointer.free();
  }
View Full Code Here

    pageChanges.addChanges(13, new byte[] { 23, 24, 25 }, new byte[] { 3, 4, 5 });

    // 0, 1, 2, 23, 24, 25, 6, 7,8, 9, 10, 11, 12, 13, 14, 15

    ODirectMemoryPointer pointer = new ODirectMemoryPointer(1024 + ODurablePage.PAGE_PADDING);
    pageChanges.applyChanges(pointer);

    Assert.assertEquals(pointer.get(10 + ODurablePage.PAGE_PADDING, 16), new byte[] { 0, 1, 2, 23, 24, 25, 6, 7, 8, 9, 10, 11, 12,
        13, 14, 15 });

    pageChanges.revertChanges(pointer);
    Assert.assertEquals(pointer.get(10 + ODurablePage.PAGE_PADDING, 16), new byte[] { 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14,
        13, 12 });

    pointer.free();
  }
View Full Code Here

    // -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11

    pageChanges.addChanges(8, new byte[] { 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111 }, new byte[] { -2,
        -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 });

    ODirectMemoryPointer pointer = new ODirectMemoryPointer(1024 + ODurablePage.PAGE_PADDING);
    pageChanges.applyChanges(pointer);

    Assert.assertEquals(pointer.get(8 + ODurablePage.PAGE_PADDING, 14), new byte[] { 98, 99, 100, 101, 102, 103, 104, 105, 106,
        107, 108, 109, 110, 111 });

    pageChanges.revertChanges(pointer);
    Assert
        .assertEquals(pointer.get(8 + ODurablePage.PAGE_PADDING, 14), new byte[] { -2, -1, 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8 });

    pointer.free();
  }
View Full Code Here

    }

    pageChanges.addChanges(9, new byte[] { 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114 }, new byte[] {
        -1, 0, 1, 2, 3, -2, 4, 5, 6, 7, -3, 8, 9, 10, 11 });

    ODirectMemoryPointer pointer = new ODirectMemoryPointer(1024 + ODurablePage.PAGE_PADDING);
    pageChanges.applyChanges(pointer);

    Assert.assertEquals(pointer.get(9 + ODurablePage.PAGE_PADDING, 15), new byte[] { 100, 101, 102, 103, 104, 105, 106, 107, 108,
        109, 110, 111, 112, 113, 114 });

    for (byte i = 3; i < 17; i++) {
      Assert.assertEquals(pointer.get(i * 10 + ODurablePage.PAGE_PADDING, 4), new byte[] { i, (byte) (i + 1), (byte) (i + 2),
          (byte) (i + 3) });
    }

    pageChanges.revertChanges(pointer);

    Assert.assertEquals(pointer.get(9 + ODurablePage.PAGE_PADDING, 15), new byte[] { -1, 3, 2, 1, 0, -2, 7, 6, 5, 4, -3, 11, 10, 9,
        8 });

    for (byte i = 3; i < 17; i++) {
      Assert.assertEquals(pointer.get(i * 10 + ODurablePage.PAGE_PADDING, 4), new byte[] { (byte) (i + 3), (byte) (i + 2),
          (byte) (i + 1), i });
    }

    pointer.free();
  }
View Full Code Here

    // 10, 11, 12, 13, 14, 35, 36, 37, 38, 29, 30, 31
    pageChanges.addChanges(12, new byte[] { 0, 1, 2, 3 }, new byte[] { 12, 13, 14, 35 });

    // 10, 11, 0, 1, 2, 3, 36, 37, 38, 29, 30, 31

    ODirectMemoryPointer pointer = new ODirectMemoryPointer(1024 + ODurablePage.PAGE_PADDING);
    pageChanges.applyChanges(pointer);

    Assert.assertEquals(pointer.get(12 + ODurablePage.PAGE_PADDING, 10), new byte[] { 0, 1, 2, 3, 36, 37, 38, 29, 30, 31 });

    pageChanges.revertChanges(pointer);

    Assert.assertEquals(pointer.get(12 + ODurablePage.PAGE_PADDING, 10), new byte[] { 12, 13, 14, 15, 16, 17, 18, 19, 20, 21 });

    pointer.free();
  }
View Full Code Here

    for (byte i = 17; i >= 0; i--) {
      pageChanges.addChanges(i * 10, new byte[] { i, (byte) (i + 1), (byte) (i + 2), (byte) (i + 3) }, new byte[] { (byte) (i + 3),
          (byte) (i + 2), (byte) (i + 1), i });
    }

    ODirectMemoryPointer pointer = new ODirectMemoryPointer(1024 + ODurablePage.PAGE_PADDING);
    pageChanges.applyChanges(pointer);

    for (byte i = 0; i < 17; i++) {
      Assert.assertEquals(pointer.get(i * 10 + ODurablePage.PAGE_PADDING, 4), new byte[] { i, (byte) (i + 1), (byte) (i + 2),
          (byte) (i + 3) });
    }

    pageChanges.revertChanges(pointer);

    for (byte i = 0; i < 17; i++) {
      Assert.assertEquals(pointer.get(i * 10 + ODurablePage.PAGE_PADDING, 4), new byte[] { (byte) (i + 3), (byte) (i + 2),
          (byte) (i + 1), i });
    }

    pointer.free();
  }
View Full Code Here

    Assert.assertEquals(pageChanges.toStream(content, 10), content.length);

    OPageChanges deserializedPageChanges = new OPageChanges();
    Assert.assertEquals(deserializedPageChanges.fromStream(content, 10), content.length);

    ODirectMemoryPointer pointer = new ODirectMemoryPointer(128000 + ODurablePage.PAGE_PADDING);

    deserializedPageChanges.applyChanges(pointer);

    Assert.assertEquals(pointer.get(0 + ODurablePage.PAGE_PADDING, 120), firstChange);
    Assert.assertEquals(pointer.get(125 + ODurablePage.PAGE_PADDING, 16000), secondChange);
    Assert.assertEquals(pointer.get(17000 + ODurablePage.PAGE_PADDING, 65000), thirdChange);

    deserializedPageChanges.revertChanges(pointer);

    Assert.assertEquals(pointer.get(0 + ODurablePage.PAGE_PADDING, 120), new byte[120]);
    Assert.assertEquals(pointer.get(125 + ODurablePage.PAGE_PADDING, 16000), new byte[16000]);
    Assert.assertEquals(pointer.get(17000 + ODurablePage.PAGE_PADDING, 65000), new byte[65000]);

    pointer.free();
  }
View Full Code Here

    Assert.assertEquals(pageChanges.toStream(content, 10), content.length);

    OPageChanges deserializedPageChanges = new OPageChanges();
    Assert.assertEquals(deserializedPageChanges.fromStream(content, 10), content.length);

    ODirectMemoryPointer pointer = new ODirectMemoryPointer(4000000 + ODurablePage.PAGE_PADDING);

    deserializedPageChanges.applyChanges(pointer);

    Assert.assertEquals(pointer.get(0 + ODurablePage.PAGE_PADDING, 127), firstChange);
    Assert.assertEquals(pointer.get(130 + ODurablePage.PAGE_PADDING, 16383), secondChange);
    Assert.assertEquals(pointer.get(17000 + ODurablePage.PAGE_PADDING, 2097151), thirdChange);

    deserializedPageChanges.revertChanges(pointer);

    Assert.assertEquals(pointer.get(0 + ODurablePage.PAGE_PADDING, 127), new byte[127]);
    Assert.assertEquals(pointer.get(130 + ODurablePage.PAGE_PADDING, 16383), new byte[16383]);
    Assert.assertEquals(pointer.get(17000 + ODurablePage.PAGE_PADDING, 2097151), new byte[2097151]);

    pointer.free();
  }
View Full Code Here

TOP

Related Classes of com.orientechnologies.common.directmemory.ODirectMemoryPointer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.