Java Code Examples for java.io.DataInput#readBoolean()

The following examples show how to use java.io.DataInput#readBoolean() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StringRecord.java    From stratosphere with Apache License 2.0 6 votes vote down vote up
/**
 * Read a UTF8 encoded string from in
 */
public static String readString(final DataInput in) throws IOException {

	if (in.readBoolean()) {
		final int length = in.readInt();
		if (length < 0) {
			throw new IOException("length of StringRecord is " + length);
		}

		final byte[] bytes = new byte[length];
		in.readFully(bytes, 0, length);
		return decode(bytes);
	}

	return null;
}
 
Example 2
Source File: LocatableInputSplit.java    From stratosphere with Apache License 2.0 6 votes vote down vote up
@Override
public void read(final DataInput in) throws IOException {

	// Read the split number
	this.splitNumber = in.readInt();

	// Read hostnames
	if (in.readBoolean()) {
		final int numHosts = in.readInt();
		this.hostnames = new String[numHosts];
		for (int i = 0; i < numHosts; i++) {
			this.hostnames[i] = StringRecord.readString(in);
		}
	} else {
		this.hostnames = null;
	}
}
 
Example 3
Source File: Path.java    From stratosphere with Apache License 2.0 6 votes vote down vote up
@Override
public void read(DataInput in) throws IOException {

	final boolean isNotNull = in.readBoolean();
	if (isNotNull) {
		final String scheme = StringRecord.readString(in);
		final String userInfo = StringRecord.readString(in);
		final String host = StringRecord.readString(in);
		final int port = in.readInt();
		final String path = StringRecord.readString(in);
		final String query = StringRecord.readString(in);
		final String fragment = StringRecord.readString(in);

		try {
			uri = new URI(scheme, userInfo, host, port, path, query, fragment);
		} catch (URISyntaxException e) {
			throw new IOException("Error reconstructing URI: " + StringUtils.stringifyException(e));
		}

	}
}
 
Example 4
Source File: BooleanArraySerializer.java    From util with Apache License 2.0 5 votes vote down vote up
@Override
public boolean[] read(DataInput in) throws IOException {
    final int length = lengthSerializer.read(in);
    final boolean[] values = new boolean[length];
    for (int i = 0; i < values.length; i++) {
        values[i] = in.readBoolean();
    }
    return values;
}
 
Example 5
Source File: Reference.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * @deprecated Writables are going away. Use the pb serialization methods instead.
 * Remove in a release after 0.96 goes out.  This is here only to migrate
 * old Reference files written with Writables before 0.96.
 */
@Deprecated
public void readFields(DataInput in) throws IOException {
  boolean tmp = in.readBoolean();
  // If true, set region to top.
  this.region = tmp? Range.top: Range.bottom;
  this.splitkey = Bytes.readByteArray(in);
}
 
Example 6
Source File: jMutRepair_0029_t.java    From coming with MIT License 5 votes vote down vote up
static OfYear readFrom(DataInput in) throws IOException {
    return new OfYear((char)in.readUnsignedByte(),
                      (int)in.readUnsignedByte(),
                      (int)in.readByte(),
                      (int)in.readUnsignedByte(),
                      in.readBoolean(),
                      (int)readMillis(in));
}
 
Example 7
Source File: NamesQueryFilter.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
public NamesQueryFilter deserialize(DataInput in, int version) throws IOException
{
    int size = in.readInt();
    SortedSet<CellName> columns = new TreeSet<CellName>(type);
    ISerializer<CellName> serializer = type.cellSerializer();
    for (int i = 0; i < size; ++i)
        columns.add(serializer.deserialize(in));
    boolean countCQL3Rows = in.readBoolean();
    return new NamesQueryFilter(columns, countCQL3Rows);
}
 
Example 8
Source File: RemoteBridgeServer.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void fromData(DataInput in)
  throws IOException, ClassNotFoundException {
 
  this.port = in.readInt();
  this.notifyBySubscription = in.readBoolean();
  this.isRunning = in.readBoolean();
  this.maxConnections = in.readInt();
  this.id = in.readInt();
  this.maximumTimeBetweenPings = in .readInt();
  this.maximumMessageCount = in.readInt();
  this.messageTimeToLive = in.readInt();
  this.maxThreads = in.readInt();
  setBindAddress(DataSerializer.readString(in));
  setGroups(DataSerializer.readStringArray(in));
  setHostnameForClients(DataSerializer.readString(in));
  setLoadProbe((ServerLoadProbe)DataSerializer.readObject(in));
  setLoadPollInterval(DataSerializer.readPrimitiveLong(in));
  this.socketBufferSize = in.readInt();
  if (InternalDataSerializer.getVersionForDataStream(in).compareTo(Version.GFXD_14) >= 0) {
    this.tcpNoDelay = in.readBoolean();
  }
  this.getClientSubscriptionConfig().setCapacity(in.readInt());
  this.getClientSubscriptionConfig().setEvictionPolicy(
      DataSerializer.readString(in));
  String diskStoreName = DataSerializer.readString(in);
  if (diskStoreName != null) {
    this.getClientSubscriptionConfig().setDiskStoreName(diskStoreName);
  } else {
    this.getClientSubscriptionConfig().setOverflowDirectory(
        DataSerializer.readString(in));
  }
}
 
Example 9
Source File: RegionWithHDFSBasicDUnitTest.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
public void fromDelta(DataInput in) throws IOException,
    InvalidDeltaException {
  boolean nameC = in.readBoolean();
  if (nameC) {
    this.name = in.readUTF();
  }
  boolean addressC = in.readBoolean();
  if (addressC) {
    this.address = in.readUTF();
  }
}
 
Example 10
Source File: CreateRegionProcessor.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@Override
public void fromData(DataInput in)
throws IOException, ClassNotFoundException {
  super.fromData(in);
  if (in.readBoolean()) {
    // this.profile = new CacheProfile();
    // this.profile.fromData(in);
    this.profile = (CacheProfile) DataSerializer.readObject(in);
  }
  int size = in.readInt();
  if (size == 0) {
    this.bucketProfiles = null;
  }
  else {
    this.bucketProfiles = new ArrayList(size);
    for (int i=0; i < size; i++) {
      RegionAdvisor.BucketProfileAndId bp =
        new RegionAdvisor.BucketProfileAndId();
      InternalDataSerializer.invokeFromData(bp, in);
      this.bucketProfiles.add(bp);
    }
  }
  if (in.readBoolean()) {
    this.eventState = EventStateHelper.fromData(in, false);
  }
  if(in.readBoolean()) {
    this.destroyedId = new PersistentMemberID();
    InternalDataSerializer.invokeFromData(this.destroyedId, in);
  }
  this.skippedCompatibilityChecks = in.readBoolean();
  this.hasActiveTransaction = in.readBoolean();
  this.seqKeyForWan = in.readLong();
}
 
Example 11
Source File: InternalDataSerializer.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
/** read a set of Long objects */
public static List<Long> readListOfLongs(DataInput in) throws IOException {
  int size = in.readInt();
  if (size < 0) {
    return null;
  } else {
    List result = new LinkedList();
    boolean longIDs = in.readBoolean();
    for (int i=0; i<size; i++) {
      long l = longIDs? in.readLong() : in.readInt();
      result.add(Long.valueOf(l));
    }
    return result;
  }
}
 
Example 12
Source File: ManageBucketMessage.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@Override  
public void fromData(DataInput in)
  throws IOException, ClassNotFoundException {
  super.fromData(in);
  this.acceptedBucket = in.readBoolean();
  this.notYetInitialized = in.readBoolean();
}
 
Example 13
Source File: JGenProg2017_0042_s.java    From coming with MIT License 5 votes vote down vote up
static PrecalculatedZone readFrom(DataInput in, String id) throws IOException {
    // Read string pool.
    int poolSize = in.readUnsignedShort();
    String[] pool = new String[poolSize];
    for (int i=0; i<poolSize; i++) {
        pool[i] = in.readUTF();
    }

    int size = in.readInt();
    long[] transitions = new long[size];
    int[] wallOffsets = new int[size];
    int[] standardOffsets = new int[size];
    String[] nameKeys = new String[size];
    
    for (int i=0; i<size; i++) {
        transitions[i] = readMillis(in);
        wallOffsets[i] = (int)readMillis(in);
        standardOffsets[i] = (int)readMillis(in);
        try {
            int index;
            if (poolSize < 256) {
                index = in.readUnsignedByte();
            } else {
                index = in.readUnsignedShort();
            }
            nameKeys[i] = pool[index];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new IOException("Invalid encoding");
        }
    }

    DSTZone tailZone = null;
    if (in.readBoolean()) {
        tailZone = DSTZone.readFrom(in, id);
    }

    return new PrecalculatedZone
        (id, transitions, wallOffsets, standardOffsets, nameKeys, tailZone);
}
 
Example 14
Source File: Cardumen_0069_t.java    From coming with MIT License 5 votes vote down vote up
static PrecalculatedZone readFrom(DataInput in, String id) throws IOException {
    // Read string pool.
    int poolSize = in.readUnsignedShort();
    String[] pool = new String[poolSize];
    for (int i=0; i<poolSize; i++) {
        pool[i] = in.readUTF();
    }

    int size = in.readInt();
    long[] transitions = new long[size];
    int[] wallOffsets = new int[size];
    int[] standardOffsets = new int[size];
    String[] nameKeys = new String[size];
    
    for (int i=0; i<size; i++) {
        transitions[i] = readMillis(in);
        wallOffsets[i] = (int)readMillis(in);
        standardOffsets[i] = (int)readMillis(in);
        try {
            int index;
            if (poolSize < 256) {
                index = in.readUnsignedByte();
            } else {
                index = in.readUnsignedShort();
            }
            nameKeys[i] = pool[index];
        } catch (ArrayIndexOutOfBoundsException e) {
            throw new IOException("Invalid encoding");
        }
    }

    DSTZone tailZone = null;
    if (in.readBoolean()) {
        tailZone = DSTZone.readFrom(in, id);
    }

    return new PrecalculatedZone
        (id, transitions, wallOffsets, standardOffsets, nameKeys, tailZone);
}
 
Example 15
Source File: JGenProg2017_0042_s.java    From coming with MIT License 5 votes vote down vote up
static OfYear readFrom(DataInput in) throws IOException {
    return new OfYear((char)in.readUnsignedByte(),
                      (int)in.readUnsignedByte(),
                      (int)in.readByte(),
                      (int)in.readUnsignedByte(),
                      in.readBoolean(),
                      (int)readMillis(in));
}
 
Example 16
Source File: Elixir_0038_s.java    From coming with MIT License 5 votes vote down vote up
static OfYear readFrom(DataInput in) throws IOException {
    return new OfYear((char)in.readUnsignedByte(),
                      (int)in.readUnsignedByte(),
                      (int)in.readByte(),
                      (int)in.readUnsignedByte(),
                      in.readBoolean(),
                      (int)readMillis(in));
}
 
Example 17
Source File: ManageBackupBucketMessage.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
@Override
public void fromData(DataInput in)
  throws IOException, ClassNotFoundException {
  super.fromData(in);
  this.acceptedBucket = in.readBoolean();
  this.notYetInitialized = in.readBoolean();
}
 
Example 18
Source File: RemoteRegionAttributes.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
  this.cacheLoaderDesc = DataSerializer.readString(in);
  this.cacheWriterDesc = DataSerializer.readString(in);
  this.cacheListenerDescs = DataSerializer.readStringArray(in);
  this.capacityControllerDesc = DataSerializer.readString(in);
  this.keyConstraint = (Class) DataSerializer.readObject(in);
  this.valueConstraint = (Class) DataSerializer.readObject(in);
  this.rTtl = (ExpirationAttributes) DataSerializer.readObject(in);
  this.rIdleTimeout = (ExpirationAttributes) DataSerializer.readObject(in);
  this.eTtl = (ExpirationAttributes) DataSerializer.readObject(in);
  this.customEttlDesc = DataSerializer.readString(in);
  this.eIdleTimeout = (ExpirationAttributes) DataSerializer.readObject(in);
  this.customEIdleDesc = DataSerializer.readString(in);
  this.dataPolicy = (DataPolicy) DataSerializer.readObject(in);
  this.scope = (Scope) DataSerializer.readObject(in);
  this.statsEnabled = in.readBoolean();
  this.ignoreJTA = in.readBoolean();
  this.concurrencyLevel = in.readInt();
  this.loadFactor = in.readFloat();
  this.initialCapacity = in.readInt();
  this.earlyAck = in.readBoolean();
  this.multicastEnabled = in.readBoolean();
  this.enableGateway = in.readBoolean();
  this.gatewayHubId = DataSerializer.readString(in);
  this.enableSubscriptionConflation = in.readBoolean();
  this.publisher = in.readBoolean();
  this.enableAsyncConflation = in.readBoolean();

  this.diskWriteAttributes = (DiskWriteAttributes) DataSerializer.readObject(in);
  this.diskDirs = (File[]) DataSerializer.readObject(in);
  this.diskSizes = (int[] )DataSerializer.readObject(in);
  this.indexMaintenanceSynchronous = in.readBoolean();
  this.partitionAttributes = (PartitionAttributes) DataSerializer
  .readObject(in);
  this.membershipAttributes = (MembershipAttributes) DataSerializer
      .readObject(in);
  this.subscriptionAttributes = (SubscriptionAttributes) DataSerializer
      .readObject(in);
  this.evictionAttributes = (EvictionAttributesImpl) DataSerializer.readObject(in);
  this.cloningEnable = in.readBoolean();
  this.diskStoreName = DataSerializer.readString(in);
  this.isDiskSynchronous = in.readBoolean();
  this.gatewaySendersDescs = DataSerializer.readStringArray(in);
  this.isGatewaySenderEnabled = in.readBoolean();
  this.concurrencyChecksEnabled = in.readBoolean();
  this.hdfsStoreName = DataSerializer.readString(in);
  this.compressorDesc = DataSerializer.readString(in);
  this.enableOffHeapMemory = in.readBoolean();
}
 
Example 19
Source File: BooleanWritable.java    From DataVec with Apache License 2.0 4 votes vote down vote up
/**
 */
public void readFields(DataInput in) throws IOException {
    value = in.readBoolean();
}
 
Example 20
Source File: Fact.java    From rya with Apache License 2.0 4 votes vote down vote up
@Override
public void readFields(final DataInput in) throws IOException {
    derivation = null;
    final int tripleLength = in.readInt();
    if (tripleLength == 0) {
        triple = null;
    }
    else {
        final byte[] tripleBytes = new byte[tripleLength];
        in.readFully(tripleBytes);
        final String tripleString = new String(tripleBytes, StandardCharsets.UTF_8);
        final String[] parts = tripleString.split(SEP);
        final ValueFactory factory = SimpleValueFactory.getInstance();
        final String context = parts[0];
        Resource s = null;
        final IRI p = factory.createIRI(parts[2]);
        Value o = null;
        // Subject: either bnode or URI
        if (parts[1].startsWith("_")) {
            s = factory.createBNode(parts[1].substring(2));
        }
        else {
            s = factory.createIRI(parts[1]);
        }
        // Object: literal, bnode, or URI
        if (parts[3].startsWith("_")) {
            o = factory.createBNode(parts[3].substring(2));
        }
        else if (parts[3].startsWith("\"")) {
            //literal: may have language or datatype
            final int close = parts[3].lastIndexOf("\"");
            final int length = parts[3].length();
            final String label = parts[3].substring(1, close);
            if (close == length - 1) {
                // Just a string enclosed in quotes
                o = factory.createLiteral(label);
            }
            else {
                final String data = parts[3].substring(close + 1);
                if (data.startsWith(LiteralLanguageUtils.LANGUAGE_DELIMITER)) {
                    final String lang = data.substring(1);
                    o = factory.createLiteral(label, lang);
                }
                else if (data.startsWith("^^<")) {
                    o = factory.createLiteral(label, factory.createIRI(
                        data.substring(3, data.length() - 1)));
                }
            }
        }
        else {
            o = factory.createIRI(parts[3]);
        }
        // Create a statement with or without context
        if (context.isEmpty()) {
            triple = VF.createStatement(s, p, o);
        }
        else {
            triple = VF.createStatement(s, p, o, factory.createIRI(context));
        }
    }
    useful = in.readBoolean();
    if (in.readBoolean()) {
        derivation = new Derivation();
        derivation.readFields(in);
    }
}