Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add desgin md file #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ Original meaning is a part of Fountain pen named Filling mechanisms.
- [ ] Support one-way queue
- cache
- [ ] LRU cache
- metrics
- [ ] Histogram
- distribute
- [ ] ?
15 changes: 15 additions & 0 deletions core/Design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Something

### off-heap index manager

- Design List
```
base on off-heap
��
��������allocate a memory block that contains all the entry had been serialized
�� ��
�� �������� head ==> ||||||||||||||||||||||||||||||| ==> tail
��
��
��������allocate some memory shard and the index are managered by heap
```
8 changes: 8 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,13 @@
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
</dependency>
</dependencies>
</project>
52 changes: 52 additions & 0 deletions core/src/main/java/org/doraemon/eyedropper/memory/Memory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.doraemon.eyedropper.memory;

import java.lang.reflect.Field;
import java.util.StringTokenizer;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigException;
import com.typesafe.config.ConfigFactory;
import org.doraemon.eyedropper.allocate.JNAMemoryAllocater;
import org.doraemon.eyedropper.allocate.MemoryAllocater;
import org.doraemon.eyedropper.allocate.UnsafeMemoryAllocater;
import sun.misc.Unsafe;

/**
* Created by SDE on 2018/1/23.
*/
public final class Memory {

private static final Unsafe unsafe;
private static final MemoryAllocater allocater;

static {
try {
Field field = sun.misc.Unsafe.class.getDeclaredField("theUnsafe");
field.setAccessible(true);
unsafe = (sun.misc.Unsafe)field.get(null);
} catch (Exception e) {
throw new AssertionError(e);
}
Config config = ConfigFactory.load();
String allocate;
try {
allocate = config.getString("allocate");
} catch (ConfigException.Missing missing) {
allocate = "jna";
}
if (allocate.equals("jna")) {
allocater = new JNAMemoryAllocater();
} else if (allocate.equals("unsafe")) {
allocater = new UnsafeMemoryAllocater();
} else {
allocater = new JNAMemoryAllocater();
}
String javaVersion = System.getProperty("java.version");
if (javaVersion.indexOf('-') != -1) { javaVersion = javaVersion.substring(0, javaVersion.indexOf('-')); }
StringTokenizer st = new StringTokenizer(javaVersion, ".");
int major = Integer.parseInt(st.nextToken());
int minor = st.hasMoreTokens() ? Integer.parseInt(st.nextToken()) : 0;

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.doraemon.eyedropper.memory.block;

/**
* Created by SDE on 2018/1/23.
*/
public class Block {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.doraemon.eyedropper.memory.chunks;

/**
* Created by SDE on 2018/1/22.
*/
public class Chunks {

}
51 changes: 51 additions & 0 deletions core/src/test/java/org/doraemon/eyedropper/block/BlockTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.doraemon.eyedropper.block;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.WritableByteChannel;

import org.doraemon.eyedropper.allocate.JNAMemoryAllocater;
import org.junit.Test;

/**
* Created by SDE on 2018/1/23.
*/
public class BlockTest {

@Test
public void test() {
byte[] a = new byte[10];
ByteBuffer buffer = ByteBuffer.wrap(a);
//after serilizer

JNAMemoryAllocater allocater = new JNAMemoryAllocater();
long address = allocater.allocate(1024 * 1024);




BlockWriteableChannel channel = new BlockWriteableChannel();

// WTF place FUCK FUCK

}

class BlockWriteableChannel implements WritableByteChannel {



public int write(ByteBuffer src) throws IOException {

return 0;
}

public boolean isOpen() {
return false;
}

public void close() throws IOException {

}
}

}
15 changes: 15 additions & 0 deletions core/src/test/java/org/doraemon/eyedropper/memory/MemoryTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.doraemon.eyedropper.memory;

import org.junit.Test;

/**
* Created by SDE on 2018/1/23.
*/
public class MemoryTest {

@Test
public void allocate_then_wrap_it_as_a_buffer() {

}

}
10 changes: 10 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
<artifactId>jna</artifactId>
<version>4.5.1</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.15.Final</version>
</dependency>
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down