-
-
Save user16558789/d1b0781f1d5ca21bd637 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.nfsdb.Journal; | |
import com.nfsdb.JournalWriter; | |
import com.nfsdb.factory.JournalFactory; | |
import com.nfsdb.factory.configuration.JournalConfigurationBuilder; | |
import com.nfsdb.query.api.QueryHeadBuilder; | |
// built with nfsdb-core-3.0.0-20150216.031900-5.jar | |
class NfsdbArrayBug { | |
private JournalFactory factory = new JournalFactory(CONFIG.build("/tmp")); | |
public static final JournalConfigurationBuilder CONFIG = new JournalConfigurationBuilder() {{ | |
$(NfsdbArrayBugBean.class) | |
.key("id") | |
.$sym("id").index() | |
; | |
}}; | |
public void put(String id) throws Exception { | |
try (JournalWriter<NfsdbArrayBugBean> writer = factory.writer(NfsdbArrayBugBean.class)) { | |
NfsdbArrayBugBean b = new NfsdbArrayBugBean(); | |
b.setId(id); | |
writer.append(b); | |
writer.commit(); | |
} | |
} | |
public static void main(String[] args) throws Exception { | |
NfsdbArrayBug test = new NfsdbArrayBug(); | |
for (int i = 0; i < 16383; i++) { | |
test.put(String.valueOf(i)); | |
} | |
System.out.println("Wrote 16383 elements"); | |
test.put(String.valueOf(16383)); | |
// "ArrayIndexOutOfBoundsException: -64" gets thrown at putting 2^14th element into database | |
System.out.println("Wrote another element"); | |
} | |
} | |
class NfsdbArrayBugBean { | |
private String id; | |
public String getId() { | |
return id; | |
} | |
public void setId(String id) { | |
this.id = id; | |
} | |
public void clear() { | |
id = null; | |
} | |
public String toString() { | |
return id; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment