Example usage for org.apache.lucene.util Constants JRE_IS_64BIT

List of usage examples for org.apache.lucene.util Constants JRE_IS_64BIT

Introduction

In this page you can find the example usage for org.apache.lucene.util Constants JRE_IS_64BIT.

Prototype

boolean JRE_IS_64BIT

To view the source code for org.apache.lucene.util Constants JRE_IS_64BIT.

Click Source Link

Document

True iff running on a 64bit JVM

Usage

From source file:com.b2international.index.lucene.Directories.java

License:Apache License

/**
 * Just like {@link #openFile(File)}, but allows you to also specify a custom {@link LockFactory}.
 *//* w w  w . j av a2 s .c o  m*/
public static FSDirectory openFile(final Path path, final LockFactory lockFactory) throws IOException {
    if ((Constants.WINDOWS || Constants.SUN_OS || Constants.LINUX || Constants.MAC_OS_X)
            && Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) {

        return new MMapDirectory(path, lockFactory);
    } else if (Constants.WINDOWS) {
        return new SimpleFSDirectory(path, lockFactory);
    } else {
        return new NIOFSDirectory(path, lockFactory);
    }
}

From source file:org.apache.solr.BaseDistributedSearchTestCase.java

License:Apache License

@BeforeClass
public static void initialize() {
    assumeFalse("SOLR-4147: ibm 64bit has jvm bugs!",
            Constants.JRE_IS_64BIT && Constants.JAVA_VENDOR.startsWith("IBM"));
    r = new Random(random().nextLong());
}

From source file:org.carrot2.workbench.core.NativeLibrariesTest.java

License:Open Source License

public void testNativeInterfaceLoaded() {
    // Can't use assumeTrue here because PDE uses junit3.x and it cannot be changed?
    if (Constants.WINDOWS && !Constants.JRE_IS_64BIT) {
        assertTrue("NNI BLAS not loaded.", NNIInterface.isNativeBlasAvailable());
        assertTrue("NNI LAPACK not loaded.", NNIInterface.isNativeLapackAvailable());
    }/* w  w w  .  j ava  2 s  .  c om*/
}

From source file:org.elasticsearch.common.io.stream.BytesStreamsTests.java

License:Apache License

@Test
public void testSimpleStreams() throws Exception {
    assumeTrue("requires a 64-bit JRE ... ?!", Constants.JRE_IS_64BIT);
    BytesStreamOutput out = new BytesStreamOutput();
    out.writeBoolean(false);/*w ww .  j a  v  a2  s . com*/
    out.writeByte((byte) 1);
    out.writeShort((short) -1);
    out.writeInt(-1);
    out.writeVInt(2);
    out.writeLong(-3);
    out.writeVLong(4);
    out.writeFloat(1.1f);
    out.writeDouble(2.2);
    int[] intArray = { 1, 2, 3 };
    out.writeGenericValue(intArray);
    int[] vIntArray = { 4, 5, 6 };
    out.writeVIntArray(vIntArray);
    long[] longArray = { 1, 2, 3 };
    out.writeGenericValue(longArray);
    long[] vLongArray = { 4, 5, 6 };
    out.writeVLongArray(vLongArray);
    float[] floatArray = { 1.1f, 2.2f, 3.3f };
    out.writeGenericValue(floatArray);
    double[] doubleArray = { 1.1, 2.2, 3.3 };
    out.writeGenericValue(doubleArray);
    out.writeString("hello");
    out.writeString("goodbye");
    out.writeGenericValue(BytesRefs.toBytesRef("bytesref"));
    final byte[] bytes = out.bytes().toBytes();
    StreamInput in = StreamInput.wrap(out.bytes().toBytes());
    assertEquals(in.available(), bytes.length);
    assertThat(in.readBoolean(), equalTo(false));
    assertThat(in.readByte(), equalTo((byte) 1));
    assertThat(in.readShort(), equalTo((short) -1));
    assertThat(in.readInt(), equalTo(-1));
    assertThat(in.readVInt(), equalTo(2));
    assertThat(in.readLong(), equalTo((long) -3));
    assertThat(in.readVLong(), equalTo((long) 4));
    assertThat((double) in.readFloat(), closeTo(1.1, 0.0001));
    assertThat(in.readDouble(), closeTo(2.2, 0.0001));
    assertThat(in.readGenericValue(), equalTo((Object) intArray));
    assertThat(in.readVIntArray(), equalTo(vIntArray));
    assertThat(in.readGenericValue(), equalTo((Object) longArray));
    assertThat(in.readVLongArray(), equalTo(vLongArray));
    assertThat(in.readGenericValue(), equalTo((Object) floatArray));
    assertThat(in.readGenericValue(), equalTo((Object) doubleArray));
    assertThat(in.readString(), equalTo("hello"));
    assertThat(in.readString(), equalTo("goodbye"));
    assertThat(in.readGenericValue(), equalTo((Object) BytesRefs.toBytesRef("bytesref")));
    in.close();
    out.close();
}

From source file:org.elasticsearch.common.io.streams.BytesStreamsTests.java

License:Apache License

@Test
public void testSimpleStreams() throws Exception {
    assumeTrue(Constants.JRE_IS_64BIT);
    BytesStreamOutput out = new BytesStreamOutput();
    out.writeBoolean(false);//from   w w  w.  jav  a 2 s  .c om
    out.writeByte((byte) 1);
    out.writeShort((short) -1);
    out.writeInt(-1);
    out.writeVInt(2);
    out.writeLong(-3);
    out.writeVLong(4);
    out.writeFloat(1.1f);
    out.writeDouble(2.2);
    int[] intArray = { 1, 2, 3 };
    out.writeGenericValue(intArray);
    long[] longArray = { 1, 2, 3 };
    out.writeGenericValue(longArray);
    float[] floatArray = { 1.1f, 2.2f, 3.3f };
    out.writeGenericValue(floatArray);
    double[] doubleArray = { 1.1, 2.2, 3.3 };
    out.writeGenericValue(doubleArray);
    out.writeString("hello");
    out.writeString("goodbye");
    BytesStreamInput in = new BytesStreamInput(out.bytes().toBytes(), false);
    assertThat(in.readBoolean(), equalTo(false));
    assertThat(in.readByte(), equalTo((byte) 1));
    assertThat(in.readShort(), equalTo((short) -1));
    assertThat(in.readInt(), equalTo(-1));
    assertThat(in.readVInt(), equalTo(2));
    assertThat(in.readLong(), equalTo((long) -3));
    assertThat(in.readVLong(), equalTo((long) 4));
    assertThat((double) in.readFloat(), closeTo(1.1, 0.0001));
    assertThat(in.readDouble(), closeTo(2.2, 0.0001));
    assertThat(in.readGenericValue(), equalTo((Object) intArray));
    assertThat(in.readGenericValue(), equalTo((Object) longArray));
    assertThat(in.readGenericValue(), equalTo((Object) floatArray));
    assertThat(in.readGenericValue(), equalTo((Object) doubleArray));
    assertThat(in.readString(), equalTo("hello"));
    assertThat(in.readString(), equalTo("goodbye"));
}

From source file:org.elasticsearch.common.io.streams.BytesStreamsTests.java

License:Apache License

@Test
public void testGrowLogic() throws Exception {
    assumeTrue(Constants.JRE_IS_64BIT);
    BytesStreamOutput out = new BytesStreamOutput();
    out.writeBytes(new byte[BytesStreamOutput.DEFAULT_SIZE - 5]);
    assertThat(out.bufferSize(), equalTo(2048)); // remains the default
    out.writeBytes(new byte[1 * 1024]);
    assertThat(out.bufferSize(), equalTo(4608));
    out.writeBytes(new byte[32 * 1024]);
    assertThat(out.bufferSize(), equalTo(40320));
    out.writeBytes(new byte[32 * 1024]);
    assertThat(out.bufferSize(), equalTo(90720));
}

From source file:org.elasticsearch.index.store.IndexStoreModule.java

License:Apache License

@Override
public Iterable<? extends Module> spawnModules() {
    Class<? extends Module> indexStoreModule = NioFsIndexStoreModule.class;
    // Same logic as FSDirectory#open ...
    if ((Constants.WINDOWS || Constants.SUN_OS || Constants.LINUX) && Constants.JRE_IS_64BIT
            && MMapDirectory.UNMAP_SUPPORTED) {
        indexStoreModule = MmapFsIndexStoreModule.class;
    } else if (Constants.WINDOWS) {
        indexStoreModule = SimpleFsIndexStoreModule.class;
    }//from  ww  w .j  av  a2s .c o m
    String storeType = settings.get("index.store.type");
    if ("ram".equalsIgnoreCase(storeType)) {
        indexStoreModule = RamIndexStoreModule.class;
    } else if ("memory".equalsIgnoreCase(storeType)) {
        indexStoreModule = RamIndexStoreModule.class;
    } else if ("fs".equalsIgnoreCase(storeType)) {
        // nothing to set here ... (we default to fs)
    } else if ("simplefs".equalsIgnoreCase(storeType) || "simple_fs".equals(storeType)) {
        indexStoreModule = SimpleFsIndexStoreModule.class;
    } else if ("niofs".equalsIgnoreCase(storeType) || "nio_fs".equalsIgnoreCase(storeType)) {
        indexStoreModule = NioFsIndexStoreModule.class;
    } else if ("mmapfs".equalsIgnoreCase(storeType) || "mmap_fs".equalsIgnoreCase(storeType)) {
        indexStoreModule = MmapFsIndexStoreModule.class;
    } else if (storeType != null) {
        indexStoreModule = settings.getAsClass("index.store.type", indexStoreModule,
                "org.elasticsearch.index.store.", "IndexStoreModule");
    }
    return ImmutableList.of(Modules.createModule(indexStoreModule, settings));
}

From source file:org.elasticsearch.index.store.IndexStoreTests.java

License:Apache License

public void testStoreDirectory() throws IOException {
    final Path tempDir = createTempDir().resolve("foo").resolve("0");
    final IndexStoreModule.Type[] values = IndexStoreModule.Type.values();
    final IndexStoreModule.Type type = RandomPicks.randomFrom(random(), values);
    Settings settings = Settings.settingsBuilder()
            .put(IndexStoreModule.STORE_TYPE, type.name().toLowerCase(Locale.ROOT)).build();
    FsDirectoryService service = new FsDirectoryService(settings, null,
            new ShardPath(false, tempDir, tempDir, "foo", new ShardId("foo", 0)));
    try (final Directory directory = service.newFSDirectory(tempDir, NoLockFactory.INSTANCE)) {
        switch (type) {
        case NIOFS:
            assertTrue(type + " " + directory.toString(), directory instanceof NIOFSDirectory);
            break;
        case MMAPFS:
            assertTrue(type + " " + directory.toString(), directory instanceof MMapDirectory);
            break;
        case SIMPLEFS:
            assertTrue(type + " " + directory.toString(), directory instanceof SimpleFSDirectory);
            break;
        case FS:/*from  w  w  w .j  a v a 2  s.co  m*/
        case DEFAULT:
            if (Constants.WINDOWS) {
                if (Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) {
                    assertTrue(type + " " + directory.toString(), directory instanceof MMapDirectory);
                } else {
                    assertTrue(type + " " + directory.toString(), directory instanceof SimpleFSDirectory);
                }
            } else if (Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) {
                assertTrue(type + " " + directory.toString(), directory instanceof FileSwitchDirectory);
            } else {
                assertTrue(type + " " + directory.toString(), directory instanceof NIOFSDirectory);
            }
            break;
        }
    }
}

From source file:org.elasticsearch.index.store.IndexStoreTests.java

License:Apache License

public void testStoreDirectoryDefault() throws IOException {
    final Path tempDir = createTempDir().resolve("foo").resolve("0");
    Settings settings = Settings.EMPTY;//from  ww w .  j  a v a2  s  . c o m
    FsDirectoryService service = new FsDirectoryService(settings, null,
            new ShardPath(false, tempDir, tempDir, "foo", new ShardId("foo", 0)));
    try (final Directory directory = service.newFSDirectory(tempDir, NoLockFactory.INSTANCE)) {
        if (Constants.WINDOWS) {
            assertTrue(directory.toString(),
                    directory instanceof MMapDirectory || directory instanceof SimpleFSDirectory);
        } else if (Constants.JRE_IS_64BIT) {
            assertTrue(directory.toString(), directory instanceof FileSwitchDirectory);
        } else {
            assertTrue(directory.toString(), directory instanceof NIOFSDirectory);
        }
    }
}

From source file:org.elasticsearch.index.store.mock.MockDirectoryHelper.java

License:Apache License

public FsDirectoryService randomDirectorService(IndexStore indexStore) {
    if ((Constants.WINDOWS || Constants.SUN_OS) && Constants.JRE_IS_64BIT && MMapDirectory.UNMAP_SUPPORTED) {
        return new MmapFsDirectoryService(shardId, indexSettings, indexStore);
    } else if (Constants.WINDOWS) {
        return new SimpleFsDirectoryService(shardId, indexSettings, indexStore);
    }// www  .  j a  v a  2 s  .c  o m
    switch (random.nextInt(3)) {
    case 1:
        return new MmapFsDirectoryService(shardId, indexSettings, indexStore);
    case 0:
        return new SimpleFsDirectoryService(shardId, indexSettings, indexStore);
    default:
        return new NioFsDirectoryService(shardId, indexSettings, indexStore);
    }
}